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

Unified Diff: ipc/ipc_sync_channel.cc

Issue 8417054: Allow proxy channels to be created without initializing the underlying channel. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 9 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ipc/ipc_sync_channel.h ('k') | ipc/ipc_sync_channel_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ipc/ipc_sync_channel.cc
diff --git a/ipc/ipc_sync_channel.cc b/ipc/ipc_sync_channel.cc
index 163c7ca6a7fdf9e9d20ed9145189cd482d53ecd7..f3c538421386a3fc03c076501e4b7d7eb10be632 100644
--- a/ipc/ipc_sync_channel.cc
+++ b/ipc/ipc_sync_channel.cc
@@ -378,18 +378,19 @@ SyncChannel::SyncChannel(
base::MessageLoopProxy* ipc_message_loop,
bool create_pipe_now,
WaitableEvent* shutdown_event)
- : ChannelProxy(
- channel_handle, mode, ipc_message_loop,
- new SyncContext(listener, ipc_message_loop, shutdown_event),
- create_pipe_now),
+ : ChannelProxy(new SyncContext(listener, ipc_message_loop, shutdown_event)),
sync_messages_with_no_timeout_allowed_(true) {
- // Ideally we only want to watch this object when running a nested message
- // loop. However, we don't know when it exits if there's another nested
- // message loop running under it or not, so we wouldn't know whether to
- // stop or keep watching. So we always watch it, and create the event as
- // manual reset since the object watcher might otherwise reset the event
- // when we're doing a WaitMany.
- dispatch_watcher_.StartWatching(sync_context()->GetDispatchEvent(), this);
+ ChannelProxy::Init(channel_handle, mode, create_pipe_now);
+ StartWatching();
+}
+
+SyncChannel::SyncChannel(
+ Channel::Listener* listener,
+ base::MessageLoopProxy* ipc_message_loop,
+ WaitableEvent* shutdown_event)
+ : ChannelProxy(new SyncContext(listener, ipc_message_loop, shutdown_event)),
+ sync_messages_with_no_timeout_allowed_(true) {
+ StartWatching();
}
SyncChannel::~SyncChannel() {
@@ -514,4 +515,14 @@ void SyncChannel::OnWaitableEventSignaled(WaitableEvent* event) {
sync_context()->DispatchMessages();
}
+void SyncChannel::StartWatching() {
+ // Ideally we only want to watch this object when running a nested message
+ // loop. However, we don't know when it exits if there's another nested
+ // message loop running under it or not, so we wouldn't know whether to
+ // stop or keep watching. So we always watch it, and create the event as
+ // manual reset since the object watcher might otherwise reset the event
+ // when we're doing a WaitMany.
+ dispatch_watcher_.StartWatching(sync_context()->GetDispatchEvent(), this);
+}
+
} // namespace IPC
« no previous file with comments | « ipc/ipc_sync_channel.h ('k') | ipc/ipc_sync_channel_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698