OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "build/build_config.h" | 5 #include "ipc/ipc_sync_message.h" |
6 | 6 |
7 #if defined(OS_WIN) | |
8 #include <windows.h> | |
9 #endif | |
10 #include <stack> | 7 #include <stack> |
11 | 8 |
12 #include "base/atomic_sequence_num.h" | 9 #include "base/atomic_sequence_num.h" |
13 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
14 #include "base/logging.h" | 11 #include "base/logging.h" |
15 #include "base/synchronization/waitable_event.h" | 12 #include "base/synchronization/waitable_event.h" |
16 #include "ipc/ipc_sync_message.h" | 13 #include "build/build_config.h" |
17 | 14 |
18 namespace { | 15 namespace { |
19 | 16 |
20 struct WaitableEventLazyInstanceTraits | 17 struct WaitableEventLazyInstanceTraits |
21 : public base::DefaultLazyInstanceTraits<base::WaitableEvent> { | 18 : public base::DefaultLazyInstanceTraits<base::WaitableEvent> { |
22 static base::WaitableEvent* New(void* instance) { | 19 static base::WaitableEvent* New(void* instance) { |
23 // Use placement new to initialize our instance in our preallocated space. | 20 // Use placement new to initialize our instance in our preallocated space. |
24 return new (instance) base::WaitableEvent(true, true); | 21 return new (instance) base::WaitableEvent(true, true); |
25 } | 22 } |
26 }; | 23 }; |
27 | 24 |
28 base::LazyInstance<base::WaitableEvent, WaitableEventLazyInstanceTraits> | 25 base::LazyInstance<base::WaitableEvent, WaitableEventLazyInstanceTraits> |
29 dummy_event = LAZY_INSTANCE_INITIALIZER; | 26 dummy_event = LAZY_INSTANCE_INITIALIZER; |
30 | 27 |
31 base::StaticAtomicSequenceNumber g_next_id; | 28 base::StaticAtomicSequenceNumber g_next_id; |
32 | 29 |
33 } // namespace | 30 } // namespace |
34 | 31 |
35 namespace IPC { | 32 namespace IPC { |
36 | 33 |
37 #define kSyncMessageHeaderSize 4 | 34 #define kSyncMessageHeaderSize 4 |
38 | 35 |
39 SyncMessage::SyncMessage( | 36 SyncMessage::SyncMessage(int32_t routing_id, |
40 int32 routing_id, | 37 uint32_t type, |
41 uint32 type, | 38 PriorityValue priority, |
42 PriorityValue priority, | 39 MessageReplyDeserializer* deserializer) |
43 MessageReplyDeserializer* deserializer) | |
44 : Message(routing_id, type, priority), | 40 : Message(routing_id, type, priority), |
45 deserializer_(deserializer), | 41 deserializer_(deserializer), |
46 pump_messages_event_(NULL) | 42 pump_messages_event_(NULL) { |
47 { | |
48 set_sync(); | 43 set_sync(); |
49 set_unblock(true); | 44 set_unblock(true); |
50 | 45 |
51 // Add synchronous message data before the message payload. | 46 // Add synchronous message data before the message payload. |
52 SyncHeader header; | 47 SyncHeader header; |
53 header.message_id = g_next_id.GetNext(); | 48 header.message_id = g_next_id.GetNext(); |
54 WriteSyncHeader(this, header); | 49 WriteSyncHeader(this, header); |
55 } | 50 } |
56 | 51 |
57 SyncMessage::~SyncMessage() { | 52 SyncMessage::~SyncMessage() { |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 | 131 |
137 return true; | 132 return true; |
138 } | 133 } |
139 | 134 |
140 | 135 |
141 bool MessageReplyDeserializer::SerializeOutputParameters(const Message& msg) { | 136 bool MessageReplyDeserializer::SerializeOutputParameters(const Message& msg) { |
142 return SerializeOutputParameters(msg, SyncMessage::GetDataIterator(&msg)); | 137 return SerializeOutputParameters(msg, SyncMessage::GetDataIterator(&msg)); |
143 } | 138 } |
144 | 139 |
145 } // namespace IPC | 140 } // namespace IPC |
OLD | NEW |