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 "ipc/ipc_sync_message.h" | |
6 | |
5 #include "build/build_config.h" | 7 #include "build/build_config.h" |
Tom Sepez
2015/09/03 19:53:09
nit: this needs to move down and be alphabetized.
tfarina
2015/09/04 14:01:14
Done.
| |
6 | 8 |
7 #if defined(OS_WIN) | |
8 #include <windows.h> | |
9 #endif | |
10 #include <stack> | 9 #include <stack> |
11 | 10 |
12 #include "base/atomic_sequence_num.h" | 11 #include "base/atomic_sequence_num.h" |
13 #include "base/lazy_instance.h" | 12 #include "base/lazy_instance.h" |
14 #include "base/logging.h" | 13 #include "base/logging.h" |
15 #include "base/synchronization/waitable_event.h" | 14 #include "base/synchronization/waitable_event.h" |
16 #include "ipc/ipc_sync_message.h" | |
17 | 15 |
18 namespace { | 16 namespace { |
19 | 17 |
20 struct WaitableEventLazyInstanceTraits | 18 struct WaitableEventLazyInstanceTraits |
21 : public base::DefaultLazyInstanceTraits<base::WaitableEvent> { | 19 : public base::DefaultLazyInstanceTraits<base::WaitableEvent> { |
22 static base::WaitableEvent* New(void* instance) { | 20 static base::WaitableEvent* New(void* instance) { |
23 // Use placement new to initialize our instance in our preallocated space. | 21 // Use placement new to initialize our instance in our preallocated space. |
24 return new (instance) base::WaitableEvent(true, true); | 22 return new (instance) base::WaitableEvent(true, true); |
25 } | 23 } |
26 }; | 24 }; |
27 | 25 |
28 base::LazyInstance<base::WaitableEvent, WaitableEventLazyInstanceTraits> | 26 base::LazyInstance<base::WaitableEvent, WaitableEventLazyInstanceTraits> |
29 dummy_event = LAZY_INSTANCE_INITIALIZER; | 27 dummy_event = LAZY_INSTANCE_INITIALIZER; |
30 | 28 |
31 base::StaticAtomicSequenceNumber g_next_id; | 29 base::StaticAtomicSequenceNumber g_next_id; |
32 | 30 |
33 } // namespace | 31 } // namespace |
34 | 32 |
35 namespace IPC { | 33 namespace IPC { |
36 | 34 |
37 #define kSyncMessageHeaderSize 4 | 35 #define kSyncMessageHeaderSize 4 |
38 | 36 |
39 SyncMessage::SyncMessage( | 37 SyncMessage::SyncMessage(int32_t routing_id, |
40 int32 routing_id, | 38 uint32_t type, |
41 uint32 type, | 39 PriorityValue priority, |
42 PriorityValue priority, | 40 MessageReplyDeserializer* deserializer) |
43 MessageReplyDeserializer* deserializer) | |
44 : Message(routing_id, type, priority), | 41 : Message(routing_id, type, priority), |
45 deserializer_(deserializer), | 42 deserializer_(deserializer), |
46 pump_messages_event_(NULL) | 43 pump_messages_event_(NULL) { |
47 { | |
48 set_sync(); | 44 set_sync(); |
49 set_unblock(true); | 45 set_unblock(true); |
50 | 46 |
51 // Add synchronous message data before the message payload. | 47 // Add synchronous message data before the message payload. |
52 SyncHeader header; | 48 SyncHeader header; |
53 header.message_id = g_next_id.GetNext(); | 49 header.message_id = g_next_id.GetNext(); |
54 WriteSyncHeader(this, header); | 50 WriteSyncHeader(this, header); |
55 } | 51 } |
56 | 52 |
57 SyncMessage::~SyncMessage() { | 53 SyncMessage::~SyncMessage() { |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
136 | 132 |
137 return true; | 133 return true; |
138 } | 134 } |
139 | 135 |
140 | 136 |
141 bool MessageReplyDeserializer::SerializeOutputParameters(const Message& msg) { | 137 bool MessageReplyDeserializer::SerializeOutputParameters(const Message& msg) { |
142 return SerializeOutputParameters(msg, SyncMessage::GetDataIterator(&msg)); | 138 return SerializeOutputParameters(msg, SyncMessage::GetDataIterator(&msg)); |
143 } | 139 } |
144 | 140 |
145 } // namespace IPC | 141 } // namespace IPC |
OLD | NEW |