Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(81)

Side by Side Diff: ipc/ipc_sync_message.cc

Issue 1601005: Allow synchronous messages to be sent from threads other than the main thread... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ipc/ipc_sync_message.h ('k') | ipc/ipc_sync_message_filter.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "build/build_config.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <windows.h> 8 #include <windows.h>
9 #endif 9 #endif
10 #include <stack> 10 #include <stack>
11 11
12 #include "base/atomic_sequence_num.h"
12 #include "base/logging.h" 13 #include "base/logging.h"
13 #include "base/waitable_event.h" 14 #include "base/waitable_event.h"
14 #include "ipc/ipc_sync_message.h" 15 #include "ipc/ipc_sync_message.h"
15 16
16 namespace IPC { 17 namespace IPC {
17 18
18 uint32 SyncMessage::next_id_ = 0;
19 #define kSyncMessageHeaderSize 4 19 #define kSyncMessageHeaderSize 4
20 20
21 base::WaitableEvent* dummy_event = new base::WaitableEvent(true, true); 21 static base::AtomicSequenceNumber g_next_id(base::LINKER_INITIALIZED);
22
23 static base::WaitableEvent* dummy_event = new base::WaitableEvent(true, true);
22 24
23 SyncMessage::SyncMessage( 25 SyncMessage::SyncMessage(
24 int32 routing_id, 26 int32 routing_id,
25 uint32 type, 27 uint32 type,
26 PriorityValue priority, 28 PriorityValue priority,
27 MessageReplyDeserializer* deserializer) 29 MessageReplyDeserializer* deserializer)
28 : Message(routing_id, type, priority), 30 : Message(routing_id, type, priority),
29 deserializer_(deserializer), 31 deserializer_(deserializer),
30 pump_messages_event_(NULL) 32 pump_messages_event_(NULL)
31 { 33 {
32 set_sync(); 34 set_sync();
33 set_unblock(true); 35 set_unblock(true);
34 36
35 // Add synchronous message data before the message payload. 37 // Add synchronous message data before the message payload.
36 SyncHeader header; 38 SyncHeader header;
37 header.message_id = ++next_id_; 39 header.message_id = g_next_id.GetNext();
38 WriteSyncHeader(this, header); 40 WriteSyncHeader(this, header);
39 } 41 }
40 42
41 MessageReplyDeserializer* SyncMessage::GetReplyDeserializer() { 43 MessageReplyDeserializer* SyncMessage::GetReplyDeserializer() {
42 MessageReplyDeserializer* rv = deserializer_; 44 MessageReplyDeserializer* rv = deserializer_;
43 DCHECK(rv); 45 DCHECK(rv);
44 deserializer_ = NULL; 46 deserializer_ = NULL;
45 return rv; 47 return rv;
46 } 48 }
47 49
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 119
118 return true; 120 return true;
119 } 121 }
120 122
121 123
122 bool MessageReplyDeserializer::SerializeOutputParameters(const Message& msg) { 124 bool MessageReplyDeserializer::SerializeOutputParameters(const Message& msg) {
123 return SerializeOutputParameters(msg, SyncMessage::GetDataIterator(&msg)); 125 return SerializeOutputParameters(msg, SyncMessage::GetDataIterator(&msg));
124 } 126 }
125 127
126 } // namespace IPC 128 } // namespace IPC
OLDNEW
« no previous file with comments | « ipc/ipc_sync_message.h ('k') | ipc/ipc_sync_message_filter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698