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

Unified Diff: ipc/ipc_channel_proxy.cc

Issue 301973003: Introduce IPC::ChannelProxy::Create*() and IPC::SynChannel::Create*() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixing mac build Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ipc/ipc_channel_proxy.h ('k') | ipc/ipc_sync_channel.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ipc/ipc_channel_proxy.cc
diff --git a/ipc/ipc_channel_proxy.cc b/ipc/ipc_channel_proxy.cc
index e88bb5d0e72abd0e508fb4b1c1fc96833e6d9699..cf28ed6a2e8b62dff51f57cace56bc7a0a8c9073 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());
« no previous file with comments | « ipc/ipc_channel_proxy.h ('k') | ipc/ipc_sync_channel.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698