Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(269)

Unified Diff: components/nacl/loader/nonsfi/nonsfi_listener.cc

Issue 2305913002: Use ChannelMojo from the browser to NaCl loader process. (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/nacl/loader/nonsfi/nonsfi_listener.cc
diff --git a/components/nacl/loader/nonsfi/nonsfi_listener.cc b/components/nacl/loader/nonsfi/nonsfi_listener.cc
index 90d662bb22405d17bd39f93994c8bb5fa2c1a407..db1ff8b53dda669c0b2da287ee20c8ebfc098438 100644
--- a/components/nacl/loader/nonsfi/nonsfi_listener.cc
+++ b/components/nacl/loader/nonsfi/nonsfi_listener.cc
@@ -4,9 +4,13 @@
#include "components/nacl/loader/nonsfi/nonsfi_listener.h"
+#include <utility>
+
#include "base/command_line.h"
#include "base/file_descriptor_posix.h"
#include "base/logging.h"
+#include "base/memory/ptr_util.h"
+#include "base/posix/global_descriptors.h"
#include "base/rand_util.h"
#include "base/run_loop.h"
#include "build/build_config.h"
@@ -14,10 +18,14 @@
#include "components/nacl/common/nacl_types.h"
#include "components/nacl/loader/nacl_trusted_listener.h"
#include "components/nacl/loader/nonsfi/nonsfi_main.h"
+#include "content/public/common/content_descriptors.h"
+#include "content/public/common/mojo_channel_switches.h"
#include "ipc/ipc_channel.h"
#include "ipc/ipc_channel_handle.h"
#include "ipc/ipc_switches.h"
#include "ipc/ipc_sync_channel.h"
+#include "mojo/edk/embedder/embedder.h"
+#include "mojo/edk/embedder/scoped_ipc_support.h"
#include "native_client/src/public/nonsfi/irt_random.h"
#include "ppapi/nacl_irt/irt_manifest.h"
#include "ppapi/nacl_irt/plugin_startup.h"
@@ -36,15 +44,29 @@ NonSfiListener::NonSfiListener()
key_fd_map_(new std::map<std::string, int>) {
io_thread_.StartWithOptions(
base::Thread::Options(base::MessageLoop::TYPE_IO, 0));
+
+ mojo_ipc_support_ =
+ base::MakeUnique<mojo::edk::ScopedIPCSupport>(io_thread_.task_runner());
+ mojo::edk::ScopedPlatformHandle platform_channel(
+ mojo::edk::PlatformHandle(
+ base::GlobalDescriptors::GetInstance()->Get(kMojoIPCChannel)));
+ DCHECK(platform_channel.is_valid());
+ mojo::edk::SetParentPipeHandle(std::move(platform_channel));
}
NonSfiListener::~NonSfiListener() {
}
void NonSfiListener::Listen() {
+ mojo::ScopedMessagePipeHandle handle(
+ mojo::edk::CreateChildMessagePipe(
+ base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
+ switches::kMojoChannelToken)));
+ DCHECK(handle.is_valid());
+ IPC::ChannelHandle channel_handle = IPC::ChannelHandle(handle.release());
+
channel_ = IPC::SyncChannel::Create(
- base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
- switches::kProcessChannelID),
+ channel_handle,
IPC::Channel::MODE_CLIENT,
this, // As a Listener.
io_thread_.task_runner().get(),

Powered by Google App Engine
This is Rietveld 408576698