Chromium Code Reviews| Index: components/nacl/loader/nacl_listener.cc |
| diff --git a/components/nacl/loader/nacl_listener.cc b/components/nacl/loader/nacl_listener.cc |
| index 5b6291158c1d8cd7d12964c3d9fec4d5e8450d68..daf5766c80a8fd7a25819dd2f73796f6aba52bc4 100644 |
| --- a/components/nacl/loader/nacl_listener.cc |
| +++ b/components/nacl/loader/nacl_listener.cc |
| @@ -29,17 +29,22 @@ |
| #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 "mojo/edk/embedder/embedder.h" |
| +#include "mojo/edk/embedder/scoped_ipc_support.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) |
| @@ -50,6 +55,7 @@ |
| #include <io.h> |
| #include "content/public/common/sandbox_init.h" |
| +#include "mojo/edk/embedder/platform_channel_pair.h" |
| #endif |
| namespace { |
| @@ -173,6 +179,20 @@ NaClListener::NaClListener() |
| base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); |
| DCHECK(g_listener == NULL); |
| g_listener = this; |
| + |
| + mojo_ipc_support_.reset(new mojo::edk::ScopedIPCSupport( |
| + io_thread_.task_runner().get())); |
|
dcheng
2016/09/21 05:18:33
No .get() to avoid a scoped_refptr -> raw ptr -> s
Sam McNally
2016/09/21 07:49:46
Done.
|
| +#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 |
| + DCHECK(platform_channel.is_valid()); |
| + mojo::edk::SetParentPipeHandle(std::move(platform_channel)); |
| } |
| NaClListener::~NaClListener() { |
| @@ -221,9 +241,13 @@ class FileTokenMessageFilter : public IPC::MessageFilter { |
| }; |
| void NaClListener::Listen() { |
| - std::string channel_name = |
| - base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| - switches::kProcessChannelID); |
| + mojo::ScopedMessagePipeHandle handle( |
| + mojo::edk::CreateChildMessagePipe( |
| + base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| + switches::kMojoChannelToken))); |
| + DCHECK(handle.is_valid()); |
| + IPC::ChannelHandle channel_handle(handle.release()); |
| + |
| channel_ = IPC::SyncChannel::Create(this, io_thread_.task_runner().get(), |
| &shutdown_event_); |
| filter_ = channel_->CreateSyncMessageFilter(); |
| @@ -231,7 +255,7 @@ 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(channel_handle, IPC::Channel::MODE_CLIENT, true); |
| main_task_runner_ = base::ThreadTaskRunnerHandle::Get(); |
| base::RunLoop().Run(); |
| } |