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

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: more fixes 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
Index: mojo/runner/host/child_process.cc
diff --git a/mojo/runner/host/child_process.cc b/mojo/runner/host/child_process.cc
index 76fa7394e7b48a7359e54ae5c58bddfaaa786333..f439a23873085ec2f3b884c0ad9854b217d4216a 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.
@@ -257,7 +247,6 @@ class ChildControllerImpl : public ChildController {
: app_context_(app_context),
app_library_(app_library),
unblocker_(unblocker),
- channel_info_(nullptr),
binding_(this) {}
static void StartAppOnMainThread(
@@ -274,7 +263,6 @@ class ChildControllerImpl : public ChildController {
Blocker::Unblocker unblocker_;
StartAppCallback on_app_complete_;
- embedder::ChannelInfo* channel_info_;
Binding<ChildController> binding_;
DISALLOW_COPY_AND_ASSIGN(ChildControllerImpl);
@@ -307,39 +295,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;
}
@@ -371,8 +354,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());

Powered by Google App Engine
This is Rietveld 408576698