summaryrefslogtreecommitdiffstats
path: root/ipc
diff options
context:
space:
mode:
authortbreisacher@chromium.org <tbreisacher@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-03 21:48:43 +0000
committertbreisacher@chromium.org <tbreisacher@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-03 21:48:43 +0000
commit76a6d45dc439e8567c48a97e1b6a035f90a640fe (patch)
tree7e5f2bd669bbcc05bd654b5fa26d026e3e9ac5a9 /ipc
parent947b39a720fa43841eb1c1c4904119e6adb357f7 (diff)
downloadchromium_src-76a6d45dc439e8567c48a97e1b6a035f90a640fe.zip
chromium_src-76a6d45dc439e8567c48a97e1b6a035f90a640fe.tar.gz
chromium_src-76a6d45dc439e8567c48a97e1b6a035f90a640fe.tar.bz2
Remove static initializer in dummy_event
BUG=94925 TEST=sizes Review URL: http://codereview.chromium.org/9297009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@120405 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ipc')
-rw-r--r--ipc/ipc_sync_message.cc22
1 files changed, 18 insertions, 4 deletions
diff --git a/ipc/ipc_sync_message.cc b/ipc/ipc_sync_message.cc
index e276263..875f97b 100644
--- a/ipc/ipc_sync_message.cc
+++ b/ipc/ipc_sync_message.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -10,18 +10,32 @@
#include <stack>
#include "base/atomic_sequence_num.h"
+#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/synchronization/waitable_event.h"
#include "ipc/ipc_sync_message.h"
+namespace {
+
+struct WaitableEventLazyInstanceTraits
+ : public base::DefaultLazyInstanceTraits<base::WaitableEvent> {
+ static base::WaitableEvent* New(void* instance) {
+ // Use placement new to initialize our instance in our preallocated space.
+ return new (instance) base::WaitableEvent(true, true);
+ }
+};
+
+static base::LazyInstance<base::WaitableEvent, WaitableEventLazyInstanceTraits>
+ dummy_event = LAZY_INSTANCE_INITIALIZER;
+
+}
+
namespace IPC {
#define kSyncMessageHeaderSize 4
static base::AtomicSequenceNumber g_next_id(base::LINKER_INITIALIZED);
-static base::WaitableEvent* dummy_event = new base::WaitableEvent(true, true);
-
SyncMessage::SyncMessage(
int32 routing_id,
uint32 type,
@@ -50,7 +64,7 @@ MessageReplyDeserializer* SyncMessage::GetReplyDeserializer() {
void SyncMessage::EnableMessagePumping() {
DCHECK(!pump_messages_event_);
- set_pump_messages_event(dummy_event);
+ set_pump_messages_event(dummy_event.Pointer());
}
bool SyncMessage::IsMessageReplyTo(const Message& msg, int request_id) {