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

Unified Diff: mojo/runner/host/child_process.cc

Issue 1554443003: Stop linking in the old Mojo EDK. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge and fix new flaky test Created 4 years, 11 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 | « mojo/runner/host/BUILD.gn ('k') | mojo/runner/host/child_process_host.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/runner/host/child_process.cc
diff --git a/mojo/runner/host/child_process.cc b/mojo/runner/host/child_process.cc
index 1cb0d6291af26112b340b9516f7040df488a0945..06a70fa4244dd3733e451cb41129bbe16d061187 100644
--- a/mojo/runner/host/child_process.cc
+++ b/mojo/runner/host/child_process.cc
@@ -28,6 +28,8 @@
#include "base/threading/thread_checker.h"
#include "mojo/edk/embedder/embedder.h"
#include "mojo/edk/embedder/platform_channel_pair.h"
+#include "mojo/edk/embedder/process_delegate.h"
+#include "mojo/edk/embedder/scoped_platform_handle.h"
#include "mojo/message_pump/message_pump_mojo.h"
#include "mojo/public/cpp/bindings/binding.h"
#include "mojo/public/cpp/system/core.h"
@@ -35,10 +37,6 @@
#include "mojo/runner/host/native_application_support.h"
#include "mojo/runner/host/switches.h"
#include "mojo/runner/init.h"
-#include "third_party/mojo/src/mojo/edk/embedder/embedder.h"
-#include "third_party/mojo/src/mojo/edk/embedder/platform_channel_pair.h"
-#include "third_party/mojo/src/mojo/edk/embedder/process_delegate.h"
-#include "third_party/mojo/src/mojo/edk/embedder/scoped_platform_handle.h"
#if defined(OS_LINUX) && !defined(OS_ANDROID)
#include "base/rand_util.h"
@@ -51,10 +49,6 @@ namespace runner {
namespace {
-void DidCreateChannel(embedder::ChannelInfo* channel_info) {
- DVLOG(2) << "ChildControllerImpl::DidCreateChannel()";
-}
-
// Blocker ---------------------------------------------------------------------
// Blocks a thread until another thread unblocks it, at which point it unblocks
@@ -104,18 +98,16 @@ class Blocker {
class ChildControllerImpl;
// Should be created and initialized on the main thread.
-// TODO(use_chrome_edk)
-// class AppContext : public edk::ProcessDelegate {
-class AppContext : public embedder::ProcessDelegate {
+class AppContext : public edk::ProcessDelegate {
public:
AppContext()
: io_thread_("io_thread"), controller_thread_("controller_thread") {}
~AppContext() override {}
void Init() {
- embedder::PreInitializeChildProcess();
+ edk::PreInitializeChildProcess();
// Initialize Mojo before starting any threads.
- embedder::Init();
+ edk::Init();
// Create and start our I/O thread.
base::Thread::Options io_thread_options(base::MessageLoop::TYPE_IO, 0);
@@ -123,11 +115,9 @@ class AppContext : public embedder::ProcessDelegate {
io_runner_ = io_thread_.task_runner().get();
CHECK(io_runner_.get());
- // TODO(vtl): This should be SLAVE, not NONE.
// This must be created before controller_thread_ since MessagePumpMojo will
// create a message pipe which requires this code to be run first.
- embedder::InitIPCSupport(embedder::ProcessType::NONE, this, io_runner_,
- embedder::ScopedPlatformHandle());
+ edk::InitIPCSupport(this, io_runner_);
}
void StartControllerThread() {
@@ -169,7 +159,7 @@ class AppContext : public embedder::ProcessDelegate {
controller_.reset();
// Next shutdown IPC. We'll unblock the main thread in OnShutdownComplete().
- embedder::ShutdownIPCSupport();
+ edk::ShutdownIPCSupport();
}
// ProcessDelegate implementation.
@@ -301,39 +291,34 @@ scoped_ptr<mojo::runner::LinuxSandbox> InitializeSandbox() {
#endif
ScopedMessagePipeHandle InitializeHostMessagePipe(
- embedder::ScopedPlatformHandle platform_channel,
+ edk::ScopedPlatformHandle platform_channel,
scoped_refptr<base::TaskRunner> io_task_runner) {
- ScopedMessagePipeHandle host_message_pipe(
- embedder::CreateChannel(std::move(platform_channel),
- base::Bind(&DidCreateChannel), io_task_runner));
-
- if (base::CommandLine::ForCurrentProcess()->HasSwitch("use-new-edk")) {
- // When using the new Mojo EDK, each message pipe is backed by a platform
- // handle. The one platform handle that comes on the command line is used
- // to bind to the ChildController interface. However we also want a
- // platform handle to setup the communication channel by which we exchange
- // handles to/from tokens, which is needed for sandboxed Windows
- // processes.
- char broker_handle[10];
- MojoHandleSignalsState state;
- MojoResult rv =
- MojoWait(host_message_pipe.get().value(), MOJO_HANDLE_SIGNAL_READABLE,
- MOJO_DEADLINE_INDEFINITE, &state);
- CHECK_EQ(MOJO_RESULT_OK, rv);
- uint32_t num_bytes = arraysize(broker_handle);
- rv = MojoReadMessage(host_message_pipe.get().value(),
- broker_handle, &num_bytes, nullptr, 0,
- MOJO_READ_MESSAGE_FLAG_NONE);
- CHECK_EQ(MOJO_RESULT_OK, rv);
-
- edk::ScopedPlatformHandle broker_channel =
- edk::PlatformChannelPair::PassClientHandleFromParentProcessFromString(
- std::string(broker_handle, num_bytes));
- CHECK(broker_channel.is_valid());
- embedder::SetParentPipeHandle(
- mojo::embedder::ScopedPlatformHandle(mojo::embedder::PlatformHandle(
- broker_channel.release().handle)));
- }
+ ScopedMessagePipeHandle host_message_pipe(edk::CreateMessagePipe(
+ std::move(platform_channel)));
+
+ // When using the new Mojo EDK, each message pipe is backed by a platform
+ // handle. The one platform handle that comes on the command line is used
+ // to bind to the ChildController interface. However we also want a
+ // platform handle to setup the communication channel by which we exchange
+ // handles to/from tokens, which is needed for sandboxed Windows
+ // processes.
+ char broker_handle[10];
+ MojoHandleSignalsState state;
+ MojoResult rv =
+ MojoWait(host_message_pipe.get().value(), MOJO_HANDLE_SIGNAL_READABLE,
+ MOJO_DEADLINE_INDEFINITE, &state);
+ CHECK_EQ(MOJO_RESULT_OK, rv);
+ uint32_t num_bytes = arraysize(broker_handle);
+ rv = MojoReadMessage(host_message_pipe.get().value(),
+ broker_handle, &num_bytes, nullptr, 0,
+ MOJO_READ_MESSAGE_FLAG_NONE);
+ CHECK_EQ(MOJO_RESULT_OK, rv);
+
+ edk::ScopedPlatformHandle broker_channel =
+ edk::PlatformChannelPair::PassClientHandleFromParentProcessFromString(
+ std::string(broker_handle, num_bytes));
+ CHECK(broker_channel.is_valid());
+ edk::SetParentPipeHandle(std::move(broker_channel)) ;
return host_message_pipe;
}
@@ -365,8 +350,8 @@ int ChildProcessMain() {
sandbox = InitializeSandbox();
#endif
- embedder::ScopedPlatformHandle platform_channel =
- embedder::PlatformChannelPair::PassClientHandleFromParentProcess(
+ edk::ScopedPlatformHandle platform_channel =
+ edk::PlatformChannelPair::PassClientHandleFromParentProcess(
command_line);
CHECK(platform_channel.is_valid());
« no previous file with comments | « mojo/runner/host/BUILD.gn ('k') | mojo/runner/host/child_process_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698