diff options
author | morrita@chromium.org <morrita@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-02 19:41:12 +0000 |
---|---|---|
committer | morrita@chromium.org <morrita@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-02 19:41:12 +0000 |
commit | cf178fb755d0fda06fd770c1a94eb8696063c001 (patch) | |
tree | 6e78f195f4731ec0231c538fc8377a3a41e8482b /ipc/ipc_channel_proxy.cc | |
parent | 7d1c92a65a91100f4cae59626107b7b74aba536b (diff) | |
download | chromium_src-cf178fb755d0fda06fd770c1a94eb8696063c001.zip chromium_src-cf178fb755d0fda06fd770c1a94eb8696063c001.tar.gz chromium_src-cf178fb755d0fda06fd770c1a94eb8696063c001.tar.bz2 |
Introduce IPC::ChannelProxy::Create*() and IPC::SynChannel::Create*()
This change hides constructors of these classes so that we can turn
them polymorphic classes.
Note that having almost identical ChannelProxy::Init*() isn't great
and they will be replaced by a factory-like abstraction in coming
changes.
TEST=none
R=darin,cpu
BUG=377980
Review URL: https://codereview.chromium.org/301973003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@274310 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ipc/ipc_channel_proxy.cc')
-rw-r--r-- | ipc/ipc_channel_proxy.cc | 90 |
1 files changed, 80 insertions, 10 deletions
diff --git a/ipc/ipc_channel_proxy.cc b/ipc/ipc_channel_proxy.cc index e88bb5d..cf28ed6 100644 --- a/ipc/ipc_channel_proxy.cc +++ b/ipc/ipc_channel_proxy.cc @@ -304,13 +304,56 @@ void ChannelProxy::Context::OnDispatchBadMessage(const Message& message) { //----------------------------------------------------------------------------- -ChannelProxy::ChannelProxy(const IPC::ChannelHandle& channel_handle, - Channel::Mode mode, - Listener* listener, - base::SingleThreadTaskRunner* ipc_task_runner) - : context_(new Context(listener, ipc_task_runner)), - did_init_(false) { - Init(channel_handle, mode, true); +// static +scoped_ptr<ChannelProxy> ChannelProxy::Create( + Listener* listener, + base::SingleThreadTaskRunner* ipc_task_runner) { + return make_scoped_ptr(new ChannelProxy( + listener, ipc_task_runner)); +} + +// static +scoped_ptr<ChannelProxy> ChannelProxy::CreateClient( + const IPC::ChannelHandle& channel_handle, + Listener* listener, + base::SingleThreadTaskRunner* ipc_task_runner) { + scoped_ptr<ChannelProxy> channel = Create( + listener, ipc_task_runner); + channel->InitClient(channel_handle, true); + return channel.Pass(); +} + +// static +scoped_ptr<ChannelProxy> ChannelProxy::CreateServer( + const IPC::ChannelHandle& channel_handle, + Listener* listener, + base::SingleThreadTaskRunner* ipc_task_runner) { + scoped_ptr<ChannelProxy> channel = Create( + listener, ipc_task_runner); + channel->InitServer(channel_handle, true); + return channel.Pass(); +} + +// static +scoped_ptr<ChannelProxy> ChannelProxy::CreateNamedClient( + const IPC::ChannelHandle& channel_handle, + Listener* listener, + base::SingleThreadTaskRunner* ipc_task_runner) { + scoped_ptr<ChannelProxy> channel = Create( + listener, ipc_task_runner); + channel->InitNamedClient(channel_handle, true); + return channel.Pass(); +} + +// static +scoped_ptr<ChannelProxy> ChannelProxy::CreateNamedServer( + const IPC::ChannelHandle& channel_handle, + Listener* listener, + base::SingleThreadTaskRunner* ipc_task_runner) { + scoped_ptr<ChannelProxy> channel = Create( + listener, ipc_task_runner); + channel->InitNamedServer(channel_handle, true); + return channel.Pass(); } ChannelProxy::ChannelProxy(Context* context) @@ -318,15 +361,22 @@ ChannelProxy::ChannelProxy(Context* context) did_init_(false) { } +ChannelProxy::ChannelProxy(Listener* listener, + base::SingleThreadTaskRunner* ipc_task_runner) + : context_(new Context(listener, ipc_task_runner)), + did_init_(false) { +} + ChannelProxy::~ChannelProxy() { DCHECK(CalledOnValidThread()); Close(); } -void ChannelProxy::Init(const IPC::ChannelHandle& channel_handle, - Channel::Mode mode, - bool create_pipe_now) { +void ChannelProxy::InitByMode( + const IPC::ChannelHandle& channel_handle, + Channel::Mode mode, + bool create_pipe_now) { DCHECK(CalledOnValidThread()); DCHECK(!did_init_); #if defined(OS_POSIX) @@ -358,6 +408,26 @@ void ChannelProxy::Init(const IPC::ChannelHandle& channel_handle, did_init_ = true; } +void ChannelProxy::InitClient(const IPC::ChannelHandle& channel_handle, + bool create_pipe_now) { + InitByMode(channel_handle, Channel::MODE_CLIENT, create_pipe_now); +} + +void ChannelProxy::InitServer(const IPC::ChannelHandle& channel_handle, + bool create_pipe_now) { + InitByMode(channel_handle, Channel::MODE_SERVER, create_pipe_now); +} + +void ChannelProxy::InitNamedClient(const IPC::ChannelHandle& channel_handle, + bool create_pipe_now) { + InitByMode(channel_handle, Channel::MODE_NAMED_CLIENT, create_pipe_now); +} + +void ChannelProxy::InitNamedServer(const IPC::ChannelHandle& channel_handle, + bool create_pipe_now) { + InitByMode(channel_handle, Channel::MODE_NAMED_SERVER, create_pipe_now); +} + void ChannelProxy::Close() { DCHECK(CalledOnValidThread()); |