diff options
author | kkania@chromium.org <kkania@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-16 01:06:46 +0000 |
---|---|---|
committer | kkania@chromium.org <kkania@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-16 01:06:46 +0000 |
commit | 952394afc0a0dc5e3e6a1f3c2e1c0fa99b7b681f (patch) | |
tree | 85d8246efdada076c5dda1b0a561d6c3322f37d1 /ipc/ipc_sync_channel.cc | |
parent | 8bbba87862f0ce45234380cebf60e3ded5d88147 (diff) | |
download | chromium_src-952394afc0a0dc5e3e6a1f3c2e1c0fa99b7b681f.zip chromium_src-952394afc0a0dc5e3e6a1f3c2e1c0fa99b7b681f.tar.gz chromium_src-952394afc0a0dc5e3e6a1f3c2e1c0fa99b7b681f.tar.bz2 |
Allow proxy channels to be created without initializing the underlying channel.
This fixes a bug where a client needed to guarantee a message filter was in
place before any messages were received.
It also follows the style of not having constructors that do complex
initialization.
BUG=102894
TEST=none
Review URL: http://codereview.chromium.org/8417054
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@110229 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ipc/ipc_sync_channel.cc')
-rw-r--r-- | ipc/ipc_sync_channel.cc | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/ipc/ipc_sync_channel.cc b/ipc/ipc_sync_channel.cc index 163c7ca..f3c5384 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 |