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

Side by Side Diff: chrome/common/ipc_sync_channel.cc

Issue 42113: Ensure that a listener's OnChannelConnected is called before OnMessageReceive... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 9 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 | « chrome/common/ipc_channel_proxy.cc ('k') | no next file » | 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) 2006-2008 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 "chrome/common/ipc_sync_channel.h" 5 #include "chrome/common/ipc_sync_channel.h"
6 6
7 #include "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/thread_local.h" 9 #include "base/thread_local.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
11 #include "base/waitable_event.h" 11 #include "base/waitable_event.h"
12 #include "base/waitable_event_watcher.h" 12 #include "base/waitable_event_watcher.h"
13 #include "chrome/common/ipc_logging.h"
14 #include "chrome/common/ipc_sync_message.h" 13 #include "chrome/common/ipc_sync_message.h"
15 14
16 using base::TimeDelta; 15 using base::TimeDelta;
17 using base::TimeTicks; 16 using base::TimeTicks;
18 using base::WaitableEvent; 17 using base::WaitableEvent;
19 18
20 namespace IPC { 19 namespace IPC {
21 // When we're blocked in a Send(), we need to process incoming synchronous 20 // When we're blocked in a Send(), we need to process incoming synchronous
22 // messages right away because it could be blocking our reply (either 21 // messages right away because it could be blocking our reply (either
23 // directly from the same object we're calling, or indirectly through one or 22 // directly from the same object we're calling, or indirectly through one or
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 { 96 {
98 AutoLock auto_lock(message_lock_); 97 AutoLock auto_lock(message_lock_);
99 if (message_queue_.empty()) 98 if (message_queue_.empty())
100 break; 99 break;
101 100
102 message = message_queue_.front().message; 101 message = message_queue_.front().message;
103 context = message_queue_.front().context; 102 context = message_queue_.front().context;
104 message_queue_.pop_front(); 103 message_queue_.pop_front();
105 } 104 }
106 105
107 #ifdef IPC_MESSAGE_LOG_ENABLED 106 context->OnDispatchMessage(*message);
108 Logging* logger = Logging::current();
109 if (logger->Enabled())
110 logger->OnPreDispatchMessage(*message);
111 #endif
112
113 if (context->listener())
114 context->listener()->OnMessageReceived(*message);
115
116 #ifdef IPC_MESSAGE_LOG_ENABLED
117 if (logger->Enabled())
118 logger->OnPostDispatchMessage(*message, context->channel_id());
119 #endif
120
121 delete message; 107 delete message;
122 } 108 }
123 } 109 }
124 110
125 // SyncChannel calls this in its destructor. 111 // SyncChannel calls this in its destructor.
126 void RemoveContext(SyncContext* context) { 112 void RemoveContext(SyncContext* context) {
127 AutoLock auto_lock(message_lock_); 113 AutoLock auto_lock(message_lock_);
128 114
129 SyncMessageQueue::iterator iter = message_queue_.begin(); 115 SyncMessageQueue::iterator iter = message_queue_.begin();
130 while (iter != message_queue_.end()) { 116 while (iter != message_queue_.end()) {
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 dispatch_watcher_.StartWatching(dispatch_event, this); 444 dispatch_watcher_.StartWatching(dispatch_event, this);
459 sync_context()->DispatchMessages(); 445 sync_context()->DispatchMessages();
460 } else { 446 } else {
461 // We got the reply, timed out or the process shutdown. 447 // We got the reply, timed out or the process shutdown.
462 DCHECK(event == sync_context()->GetSendDoneEvent()); 448 DCHECK(event == sync_context()->GetSendDoneEvent());
463 MessageLoop::current()->Quit(); 449 MessageLoop::current()->Quit();
464 } 450 }
465 } 451 }
466 452
467 } // namespace IPC 453 } // namespace IPC
OLDNEW
« no previous file with comments | « chrome/common/ipc_channel_proxy.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698