Index: components/nacl/loader/nacl_listener.cc |
diff --git a/components/nacl/loader/nacl_listener.cc b/components/nacl/loader/nacl_listener.cc |
index 98444678e2869d2546c95eae3fea4e1b0653ba21..a094d6b97b3320c1f7ffedb7e0a4a819c314197e 100644 |
--- a/components/nacl/loader/nacl_listener.cc |
+++ b/components/nacl/loader/nacl_listener.cc |
@@ -26,17 +26,23 @@ |
#include "components/nacl/loader/nacl_ipc_adapter.h" |
#include "components/nacl/loader/nacl_validation_db.h" |
#include "components/nacl/loader/nacl_validation_query.h" |
+#include "content/public/common/mojo_channel_switches.h" |
#include "ipc/attachment_broker_unprivileged.h" |
#include "ipc/ipc_channel_handle.h" |
#include "ipc/ipc_switches.h" |
#include "ipc/ipc_sync_channel.h" |
#include "ipc/ipc_sync_message_filter.h" |
+#include "ipc/mojo/ipc_channel_mojo.h" |
+#include "ipc/mojo/scoped_ipc_support.h" |
+#include "mojo/edk/embedder/embedder.h" |
#include "native_client/src/public/chrome_main.h" |
#include "native_client/src/public/nacl_app.h" |
#include "native_client/src/public/nacl_desc.h" |
#if defined(OS_POSIX) |
#include "base/file_descriptor_posix.h" |
+#include "base/posix/global_descriptors.h" |
+#include "content/public/common/content_descriptors.h" |
#endif |
#if defined(OS_LINUX) |
@@ -47,6 +53,7 @@ |
#include <io.h> |
#include "content/public/common/sandbox_init.h" |
+#include "mojo/edk/embedder/platform_channel_pair.h" |
#endif |
namespace { |
@@ -170,6 +177,10 @@ NaClListener::NaClListener() |
base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); |
DCHECK(g_listener == NULL); |
g_listener = this; |
+ |
+ mojo::edk::Init(); |
+ mojo_ipc_support_.reset(new IPC::ScopedIPCSupport( |
+ io_thread_.task_runner().get())); |
} |
NaClListener::~NaClListener() { |
@@ -218,9 +229,23 @@ class FileTokenMessageFilter : public IPC::MessageFilter { |
}; |
void NaClListener::Listen() { |
- std::string channel_name = |
- base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
- switches::kProcessChannelID); |
+#if defined(OS_WIN) |
+ mojo::edk::ScopedPlatformHandle platform_channel( |
+ mojo::edk::PlatformChannelPair::PassClientHandleFromParentProcess( |
+ *base::CommandLine::ForCurrentProcess()); |
+#else |
+ mojo::edk::ScopedPlatformHandle platform_channel( |
+ mojo::edk::PlatformHandle( |
+ base::GlobalDescriptors::GetInstance()->Get(kMojoIPCChannel))); |
+#endif |
+ |
+ mojo::edk::SetParentPipeHandle(std::move(platform_channel)); |
+ mojo::ScopedMessagePipeHandle handle( |
+ mojo::edk::CreateChildMessagePipe( |
+ base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
+ switches::kMojoChannelToken))); |
+ DCHECK(handle.is_valid()); |
+ |
channel_ = IPC::SyncChannel::Create(this, io_thread_.task_runner().get(), |
&shutdown_event_); |
filter_ = channel_->CreateSyncMessageFilter(); |
@@ -228,7 +253,8 @@ void NaClListener::Listen() { |
IPC::AttachmentBroker* global = IPC::AttachmentBroker::GetGlobal(); |
if (global && !global->IsPrivilegedBroker()) |
global->RegisterBrokerCommunicationChannel(channel_.get()); |
- channel_->Init(channel_name, IPC::Channel::MODE_CLIENT, true); |
+ channel_->Init(IPC::ChannelMojo::CreateClientFactory(std::move(handle)), |
+ true); |
main_loop_ = base::MessageLoop::current(); |
main_loop_->Run(); |
} |