| Index: ipc/ipc_channel_proxy.cc
|
| diff --git a/ipc/ipc_channel_proxy.cc b/ipc/ipc_channel_proxy.cc
|
| index 7441c6543b6caaab7aa34ef18c8a439aedd233a1..d33b043ab59c2315a6f15b54839b0219aa8ab357 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_builder.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<ChannelBuilder> builder) {
|
| DCHECK(!channel_);
|
| - channel_id_ = handle.name;
|
| - channel_ = Channel::Create(handle, mode, this);
|
| + channel_id_ = builder->GetName();
|
| + channel_ = builder->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<ChannelBuilder> builder,
|
| + Listener* listener,
|
| + base::SingleThreadTaskRunner* ipc_task_runner) {
|
| + scoped_ptr<ChannelProxy> channel(new ChannelProxy(listener, ipc_task_runner));
|
| + channel->Init(builder.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(ChannelBuilder::CreatePlatformBuilder(channel_handle, mode),
|
| + create_pipe_now);
|
| +}
|
| +
|
| +void ChannelProxy::Init(scoped_ptr<ChannelBuilder> builder,
|
| + 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(builder.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(builder.Pass())));
|
| }
|
|
|
| // complete initialization on the background thread
|
|
|