| Index: ipc/mojo/ipc_channel_mojo.cc
|
| diff --git a/ipc/mojo/ipc_channel_mojo.cc b/ipc/mojo/ipc_channel_mojo.cc
|
| index d13f78bdfb3d7a9ace3c30fb346be48bee7185c6..8e205ac4e233d6b4d68c67b276ca6eebb3406d21 100644
|
| --- a/ipc/mojo/ipc_channel_mojo.cc
|
| +++ b/ipc/mojo/ipc_channel_mojo.cc
|
| @@ -272,7 +272,7 @@ bool ChannelMojo::MessageReader::Send(scoped_ptr<Message> message) {
|
|
|
| //------------------------------------------------------------------------------
|
|
|
| -// MessagePipeReader implemenation for control messages.
|
| +// MessagePipeReader implementation for control messages.
|
| // Actual message handling is implemented by sublcasses.
|
| class ChannelMojo::ControlReader : public internal::MessagePipeReader {
|
| public:
|
| @@ -488,26 +488,12 @@ ChannelMojo::ChannelMojo(
|
| bootstrap_(bootstrap.Pass()),
|
| mode_(mode), listener_(listener),
|
| peer_pid_(base::kNullProcessId) {
|
| - DCHECK(mode_ == MODE_SERVER || mode_ == MODE_CLIENT);
|
| - mojo::ScopedMessagePipeHandle control_pipe
|
| - = mojo::embedder::CreateChannel(
|
| - mojo::embedder::ScopedPlatformHandle(
|
| - ToPlatformHandle(bootstrap_->TakePipeHandle())),
|
| - io_thread_task_runner,
|
| - base::Bind(&ChannelMojo::DidCreateChannel, base::Unretained(this)),
|
| - io_thread_task_runner);
|
| -
|
| - // MessagePipeReader, that is crated in InitOnIOThread(), should live only in
|
| - // IO thread, but IPC::Channel can be instantiated outside of it.
|
| - // So we move the creation to the appropriate thread.
|
| if (base::MessageLoopProxy::current() == io_thread_task_runner) {
|
| - InitOnIOThread(control_pipe.Pass());
|
| + InitOnIOThread();
|
| } else {
|
| - io_thread_task_runner->PostTask(
|
| - FROM_HERE,
|
| - base::Bind(&ChannelMojo::InitOnIOThread,
|
| - weak_factory_.GetWeakPtr(),
|
| - base::Passed(control_pipe.Pass())));
|
| + io_thread_task_runner->PostTask(FROM_HERE,
|
| + base::Bind(&ChannelMojo::InitOnIOThread,
|
| + weak_factory_.GetWeakPtr()));
|
| }
|
| }
|
|
|
| @@ -515,20 +501,26 @@ ChannelMojo::~ChannelMojo() {
|
| Close();
|
| }
|
|
|
| -void ChannelMojo::InitOnIOThread(mojo::ScopedMessagePipeHandle control_pipe) {
|
| - control_reader_ = CreateControlReader(control_pipe.Pass());
|
| -}
|
| -
|
| -scoped_ptr<ChannelMojo::ControlReader> ChannelMojo::CreateControlReader(
|
| - mojo::ScopedMessagePipeHandle pipe) {
|
| - if (MODE_SERVER == mode_) {
|
| - return make_scoped_ptr(
|
| - new ServerControlReader(pipe.Pass(), this)).PassAs<ControlReader>();
|
| +void ChannelMojo::InitOnIOThread() {
|
| + mojo::embedder::ChannelInfo* channel_info;
|
| + mojo::ScopedMessagePipeHandle control_pipe =
|
| + mojo::embedder::CreateChannelOnIOThread(
|
| + mojo::embedder::ScopedPlatformHandle(
|
| + ToPlatformHandle(bootstrap_->TakePipeHandle())),
|
| + &channel_info);
|
| + channel_info_.reset(channel_info);
|
| +
|
| + switch (mode_) {
|
| + case MODE_SERVER:
|
| + control_reader_.reset(new ServerControlReader(control_pipe.Pass(), this));
|
| + break;
|
| + case MODE_CLIENT:
|
| + control_reader_.reset(new ClientControlReader(control_pipe.Pass(), this));
|
| + break;
|
| + default:
|
| + NOTREACHED();
|
| + break;
|
| }
|
| -
|
| - DCHECK(mode_ == MODE_CLIENT);
|
| - return make_scoped_ptr(
|
| - new ClientControlReader(pipe.Pass(), this)).PassAs<ControlReader>();
|
| }
|
|
|
| bool ChannelMojo::Connect() {
|
| @@ -585,10 +577,6 @@ ChannelHandle ChannelMojo::TakePipeHandle() {
|
| return bootstrap_->TakePipeHandle();
|
| }
|
|
|
| -void ChannelMojo::DidCreateChannel(mojo::embedder::ChannelInfo* info) {
|
| - channel_info_.reset(info);
|
| -}
|
| -
|
| void ChannelMojo::OnMessageReceived(Message& message) {
|
| listener_->OnMessageReceived(message);
|
| if (message.dispatch_error())
|
|
|