diff options
author | morrita@chromium.org <morrita@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-05 16:15:38 +0000 |
---|---|---|
committer | morrita@chromium.org <morrita@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-05 16:15:38 +0000 |
commit | fca876a107b04f46eabeff93dbd09e3612d96c61 (patch) | |
tree | 5f851173c0418a9653f43d72618a34aba9cd01f4 /ipc/ipc_sync_channel.cc | |
parent | 3408115e2fd1fcfb264d8a47498c9cc376e977c1 (diff) | |
download | chromium_src-fca876a107b04f46eabeff93dbd09e3612d96c61.zip chromium_src-fca876a107b04f46eabeff93dbd09e3612d96c61.tar.gz chromium_src-fca876a107b04f46eabeff93dbd09e3612d96c61.tar.bz2 |
Add IPC::ChannelProxy::Create() and IPC::SyncChannel::Create()
This change replaces constructors with Create() methods of
ChannelProxy and SyncChannel. This open the possibility to introduce
polymorphism to these classes.
This is a revision of r274310 (https://codereview.chromium.org/301973003/)
in which I added bunch of Create*() method variants.
The chagne was reverted. This change no longer does it and just keeps
using Channel::Mode to specify the channel type.
TEST=none
BUG=377980
R=darin@chromium.org,jam@chromium.org
Review URL: https://codereview.chromium.org/310853003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@275140 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ipc/ipc_sync_channel.cc')
-rw-r--r-- | ipc/ipc_sync_channel.cc | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/ipc/ipc_sync_channel.cc b/ipc/ipc_sync_channel.cc index 0e0018c..a7ed230 100644 --- a/ipc/ipc_sync_channel.cc +++ b/ipc/ipc_sync_channel.cc @@ -404,19 +404,27 @@ base::WaitableEventWatcher::EventCallback return base::Bind(&SyncChannel::SyncContext::OnWaitableEventSignaled, this); } -SyncChannel::SyncChannel( +// static +scoped_ptr<SyncChannel> SyncChannel::Create( const IPC::ChannelHandle& channel_handle, Channel::Mode mode, Listener* listener, base::SingleThreadTaskRunner* ipc_task_runner, bool create_pipe_now, - WaitableEvent* shutdown_event) - : ChannelProxy(new SyncContext(listener, ipc_task_runner, shutdown_event)) { - // The current (listener) thread must be distinct from the IPC thread, or else - // sending synchronous messages will deadlock. - DCHECK_NE(ipc_task_runner, base::ThreadTaskRunnerHandle::Get()); - ChannelProxy::Init(channel_handle, mode, create_pipe_now); - StartWatching(); + base::WaitableEvent* shutdown_event) { + scoped_ptr<SyncChannel> channel = + Create(listener, ipc_task_runner, shutdown_event); + channel->Init(channel_handle, mode, create_pipe_now); + return channel.Pass(); +} + +// static +scoped_ptr<SyncChannel> SyncChannel::Create( + Listener* listener, + base::SingleThreadTaskRunner* ipc_task_runner, + WaitableEvent* shutdown_event) { + return make_scoped_ptr( + new SyncChannel(listener, ipc_task_runner, shutdown_event)); } SyncChannel::SyncChannel( |