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

Unified Diff: components/nacl/loader/nacl_listener.cc

Issue 2081183005: Use ChannelMojo from the browser to NaCl loader process. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mojo-ipc-channel-handle
Patch Set: rebase Created 4 years, 5 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
« no previous file with comments | « components/nacl/loader/nacl_listener.h ('k') | components/nacl/loader/nonsfi/nonsfi_listener.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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()));
+#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();
}
« no previous file with comments | « components/nacl/loader/nacl_listener.h ('k') | components/nacl/loader/nonsfi/nonsfi_listener.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698