| Index: third_party/mojo/src/mojo/edk/embedder/embedder.cc
|
| diff --git a/third_party/mojo/src/mojo/edk/embedder/embedder.cc b/third_party/mojo/src/mojo/edk/embedder/embedder.cc
|
| index 0150dcb8c57a66e062fcede9dbe14d6e1f07ec2e..d0a5135e8d0e03cb9647e9f177c45b488f7d416f 100644
|
| --- a/third_party/mojo/src/mojo/edk/embedder/embedder.cc
|
| +++ b/third_party/mojo/src/mojo/edk/embedder/embedder.cc
|
| @@ -13,7 +13,6 @@
|
| #include "mojo/edk/embedder/embedder_internal.h"
|
| #include "mojo/edk/embedder/platform_support.h"
|
| #include "mojo/edk/system/channel.h"
|
| -#include "mojo/edk/system/channel_endpoint.h"
|
| #include "mojo/edk/system/channel_manager.h"
|
| #include "mojo/edk/system/configuration.h"
|
| #include "mojo/edk/system/core.h"
|
| @@ -55,9 +54,15 @@ namespace internal {
|
| PlatformSupport* g_platform_support = nullptr;
|
| system::Core* g_core = nullptr;
|
| system::ChannelManager* g_channel_manager = nullptr;
|
| +MasterProcessDelegate* g_master_process_delegate = nullptr;
|
| +SlaveProcessDelegate* g_slave_process_delegate = nullptr;
|
|
|
| } // namespace internal
|
|
|
| +Configuration* GetConfiguration() {
|
| + return system::GetMutableConfiguration();
|
| +}
|
| +
|
| void Init(scoped_ptr<PlatformSupport> platform_support) {
|
| DCHECK(platform_support);
|
|
|
| @@ -72,8 +77,27 @@ void Init(scoped_ptr<PlatformSupport> platform_support) {
|
| new system::ChannelManager(internal::g_platform_support);
|
| }
|
|
|
| -Configuration* GetConfiguration() {
|
| - return system::GetMutableConfiguration();
|
| +void InitMaster(scoped_refptr<base::TaskRunner> delegate_thread_task_runner,
|
| + MasterProcessDelegate* master_process_delegate,
|
| + scoped_refptr<base::TaskRunner> io_thread_task_runner) {
|
| + // |Init()| must have already been called.
|
| + DCHECK(internal::g_core);
|
| +
|
| + // TODO(vtl): This is temporary. We really want to construct a
|
| + // |MasterConnectionManager| here, which will in turn hold on to the delegate.
|
| + internal::g_master_process_delegate = master_process_delegate;
|
| +}
|
| +
|
| +void InitSlave(scoped_refptr<base::TaskRunner> delegate_thread_task_runner,
|
| + SlaveProcessDelegate* slave_process_delegate,
|
| + scoped_refptr<base::TaskRunner> io_thread_task_runner,
|
| + ScopedPlatformHandle platform_handle) {
|
| + // |Init()| must have already been called.
|
| + DCHECK(internal::g_core);
|
| +
|
| + // TODO(vtl): This is temporary. We really want to construct a
|
| + // |SlaveConnectionManager| here, which will in turn hold on to the delegate.
|
| + internal::g_slave_process_delegate = slave_process_delegate;
|
| }
|
|
|
| // TODO(vtl): Write tests for this.
|
| @@ -83,18 +107,16 @@ ScopedMessagePipeHandle CreateChannelOnIOThread(
|
| DCHECK(platform_handle.is_valid());
|
| DCHECK(channel_info);
|
|
|
| - scoped_refptr<system::ChannelEndpoint> channel_endpoint;
|
| + *channel_info = new ChannelInfo(MakeChannelId());
|
| scoped_refptr<system::MessagePipeDispatcher> dispatcher =
|
| - system::MessagePipeDispatcher::CreateRemoteMessagePipe(&channel_endpoint);
|
| + internal::g_channel_manager->CreateChannelOnIOThread(
|
| + (*channel_info)->channel_id, platform_handle.Pass());
|
|
|
| - DCHECK(internal::g_core);
|
| ScopedMessagePipeHandle rv(
|
| MessagePipeHandle(internal::g_core->AddDispatcher(dispatcher)));
|
| -
|
| - *channel_info = new ChannelInfo(MakeChannelId());
|
| - internal::g_channel_manager->CreateChannelOnIOThread(
|
| - (*channel_info)->channel_id, platform_handle.Pass(), channel_endpoint);
|
| -
|
| + CHECK(rv.is_valid());
|
| + // TODO(vtl): The |.Pass()| below is only needed due to an MSVS bug; remove it
|
| + // once that's fixed.
|
| return rv.Pass();
|
| }
|
|
|
| @@ -107,31 +129,19 @@ ScopedMessagePipeHandle CreateChannel(
|
| DCHECK(io_thread_task_runner);
|
| DCHECK(!callback.is_null());
|
|
|
| - scoped_refptr<system::ChannelEndpoint> channel_endpoint;
|
| + system::ChannelId channel_id = MakeChannelId();
|
| + scoped_ptr<ChannelInfo> channel_info(new ChannelInfo(channel_id));
|
| scoped_refptr<system::MessagePipeDispatcher> dispatcher =
|
| - system::MessagePipeDispatcher::CreateRemoteMessagePipe(&channel_endpoint);
|
| + internal::g_channel_manager->CreateChannel(
|
| + channel_id, platform_handle.Pass(), io_thread_task_runner,
|
| + base::Bind(callback, base::Unretained(channel_info.release())),
|
| + callback_thread_task_runner);
|
|
|
| - DCHECK(internal::g_core);
|
| ScopedMessagePipeHandle rv(
|
| MessagePipeHandle(internal::g_core->AddDispatcher(dispatcher)));
|
| -
|
| - // We'll have to set |channel_info->channel_id| on the I/O thread.
|
| - scoped_ptr<ChannelInfo> channel_info(new ChannelInfo());
|
| -
|
| - if (rv.is_valid()) {
|
| - system::ChannelId channel_id = MakeChannelId();
|
| - channel_info->channel_id = channel_id;
|
| - internal::g_channel_manager->CreateChannel(
|
| - channel_id, platform_handle.Pass(), channel_endpoint,
|
| - io_thread_task_runner,
|
| - base::Bind(callback, base::Unretained(channel_info.release())),
|
| - callback_thread_task_runner);
|
| - } else {
|
| - (callback_thread_task_runner ? callback_thread_task_runner
|
| - : io_thread_task_runner)
|
| - ->PostTask(FROM_HERE, base::Bind(callback, channel_info.release()));
|
| - }
|
| -
|
| + CHECK(rv.is_valid());
|
| + // TODO(vtl): The |.Pass()| below is only needed due to an MSVS bug; remove it
|
| + // once that's fixed.
|
| return rv.Pass();
|
| }
|
|
|
|
|