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

Unified Diff: ipc/ipc_channel_proxy.cc

Issue 382333002: Introduce ChannelMojo (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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
Index: ipc/ipc_channel_proxy.cc
diff --git a/ipc/ipc_channel_proxy.cc b/ipc/ipc_channel_proxy.cc
index 7441c6543b6caaab7aa34ef18c8a439aedd233a1..2ea722df79b086f1cd1ba6f728a53052026bae07 100644
--- a/ipc/ipc_channel_proxy.cc
+++ b/ipc/ipc_channel_proxy.cc
@@ -11,6 +11,7 @@
#include "base/memory/scoped_ptr.h"
#include "base/single_thread_task_runner.h"
#include "base/thread_task_runner_handle.h"
+#include "ipc/ipc_channel_factory.h"
#include "ipc/ipc_listener.h"
#include "ipc/ipc_logging.h"
#include "ipc/ipc_message_macros.h"
@@ -48,11 +49,10 @@ void ChannelProxy::Context::ClearIPCTaskRunner() {
ipc_task_runner_ = NULL;
}
-void ChannelProxy::Context::CreateChannel(const IPC::ChannelHandle& handle,
- const Channel::Mode& mode) {
+void ChannelProxy::Context::CreateChannel(scoped_ptr<ChannelFactory> factory) {
DCHECK(!channel_);
- channel_id_ = handle.name;
- channel_ = Channel::Create(handle, mode, this);
+ channel_id_ = factory->GetName();
+ channel_ = factory->BuildChannel(this);
}
bool ChannelProxy::Context::TryFilters(const Message& message) {
@@ -315,6 +315,16 @@ scoped_ptr<ChannelProxy> ChannelProxy::Create(
return channel.Pass();
}
+// static
+scoped_ptr<ChannelProxy> ChannelProxy::Create(
+ scoped_ptr<ChannelFactory> factory,
+ Listener* listener,
+ base::SingleThreadTaskRunner* ipc_task_runner) {
+ scoped_ptr<ChannelProxy> channel(new ChannelProxy(listener, ipc_task_runner));
+ channel->Init(factory.Pass(), true);
+ return channel.Pass();
+}
+
ChannelProxy::ChannelProxy(Context* context)
: context_(context),
did_init_(false) {
@@ -334,8 +344,6 @@ ChannelProxy::~ChannelProxy() {
void ChannelProxy::Init(const IPC::ChannelHandle& channel_handle,
Channel::Mode mode,
bool create_pipe_now) {
- DCHECK(CalledOnValidThread());
- DCHECK(!did_init_);
#if defined(OS_POSIX)
// When we are creating a server on POSIX, we need its file descriptor
// to be created immediately so that it can be accessed and passed
@@ -345,17 +353,25 @@ void ChannelProxy::Init(const IPC::ChannelHandle& channel_handle,
create_pipe_now = true;
}
#endif // defined(OS_POSIX)
+ Init(ChannelFactory::Create(channel_handle, mode),
+ create_pipe_now);
+}
+
+void ChannelProxy::Init(scoped_ptr<ChannelFactory> factory,
+ bool create_pipe_now) {
+ DCHECK(CalledOnValidThread());
+ DCHECK(!did_init_);
if (create_pipe_now) {
// Create the channel immediately. This effectively sets up the
// low-level pipe so that the client can connect. Without creating
// the pipe immediately, it is possible for a listener to attempt
// to connect and get an error since the pipe doesn't exist yet.
- context_->CreateChannel(channel_handle, mode);
+ context_->CreateChannel(factory.Pass());
} else {
context_->ipc_task_runner()->PostTask(
- FROM_HERE, base::Bind(&Context::CreateChannel, context_.get(),
- channel_handle, mode));
+ FROM_HERE, base::Bind(&Context::CreateChannel,
+ context_.get(), Passed(factory.Pass())));
}
// complete initialization on the background thread
« ipc/ipc_channel.h ('K') | « ipc/ipc_channel_proxy.h ('k') | ipc/ipc_channel_reader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698