summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormsramek <msramek@chromium.org>2015-11-18 06:57:43 -0800
committerCommit bot <commit-bot@chromium.org>2015-11-18 14:58:25 +0000
commitbf5ac583bf02c0b627f3a9c32798a74c1b83b68b (patch)
treee56de982cf3c44db314ab31efc28e6e5933a1d54
parent1a1598471650523d629cee98ebc57b72ced98846 (diff)
downloadchromium_src-bf5ac583bf02c0b627f3a9c32798a74c1b83b68b.zip
chromium_src-bf5ac583bf02c0b627f3a9c32798a74c1b83b68b.tar.gz
chromium_src-bf5ac583bf02c0b627f3a9c32798a74c1b83b68b.tar.bz2
Revert of Bind Application in renderer (patchset #14 id:260001 of https://codereview.chromium.org/1452823003/ )
Reason for revert: Speculatively reverting this, as this CL landed exactly at the time when renderer started crashing on linux_chromium_rel_ng. Original issue's description: > Bind Application in renderer. > > This involved changing how we get the client handle to the renderer. In the first iteration I was passing this on the command line but that turns out not to work with the sandbox. So instead I an approach used by the Mojo-in-Chrome MojoApplication class and pass the primordial handle via Chrome IPC. > > I had to twiddle a bunch of BUILD.gn files in content to get this to work without crashing due to inconsistencies in how MOJO_SHELL_CLIENT was defined. > > R=jam@chromium.org,tsepez@chromium.org > http://crbug.com/551253 > > Committed: https://crrev.com/3edb97198bc5fbc22c5cf13286e8af80449ddfb9 > Cr-Commit-Position: refs/heads/master@{#360293} TBR=jam@chromium.org,tsepez@chromium.org,ben@chromium.org NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=557732 Review URL: https://codereview.chromium.org/1460713002 Cr-Commit-Position: refs/heads/master@{#360331}
-rw-r--r--components/mus/example/window_type_launcher/main.cc12
-rw-r--r--content/app/BUILD.gn1
-rw-r--r--content/browser/BUILD.gn10
-rw-r--r--content/browser/child_process_launcher.cc59
-rw-r--r--content/browser/mojo/mojo_shell_client_host.cc72
-rw-r--r--content/browser/mojo/mojo_shell_client_host.h27
-rw-r--r--content/browser/renderer_host/render_process_host_impl.cc10
-rw-r--r--content/child/BUILD.gn5
-rw-r--r--content/child/child_thread_impl.cc23
-rw-r--r--content/child/child_thread_impl.h12
-rw-r--r--content/common/BUILD.gn2
-rw-r--r--content/common/mojo/mojo_messages.h5
-rw-r--r--content/common/mojo/mojo_shell_connection_impl.cc15
-rw-r--r--content/common/mojo/mojo_shell_connection_impl.h9
-rw-r--r--content/gpu/BUILD.gn5
-rw-r--r--content/plugin/BUILD.gn5
-rw-r--r--content/ppapi_plugin/BUILD.gn5
-rw-r--r--content/public/browser/BUILD.gn1
-rw-r--r--content/public/common/BUILD.gn9
-rw-r--r--content/public/renderer/BUILD.gn5
-rw-r--r--content/renderer/BUILD.gn1
-rw-r--r--content/test/BUILD.gn6
-rw-r--r--content/utility/BUILD.gn5
-rw-r--r--mojo/runner/child/runner_connection.cc51
-rw-r--r--mojo/runner/child/runner_connection.h3
-rw-r--r--mojo/runner/child/test_native_main.cc8
26 files changed, 116 insertions, 250 deletions
diff --git a/components/mus/example/window_type_launcher/main.cc b/components/mus/example/window_type_launcher/main.cc
index c2e94f9..9cecc39 100644
--- a/components/mus/example/window_type_launcher/main.cc
+++ b/components/mus/example/window_type_launcher/main.cc
@@ -61,17 +61,19 @@ int main(int argc, char** argv) {
io_thread.task_runner().get(),
mojo::embedder::ScopedPlatformHandle());
- base::MessageLoop loop(mojo::common::MessagePumpMojo::Create());
+ mojo::InterfaceRequest<mojo::Application> application_request;
+ scoped_ptr<mojo::runner::RunnerConnection> connection(
+ mojo::runner::RunnerConnection::ConnectToRunner(&application_request));
+
WindowTypeLauncher delegate;
{
- mojo::InterfaceRequest<mojo::Application> application_request;
- scoped_ptr<mojo::runner::RunnerConnection> connection(
- mojo::runner::RunnerConnection::ConnectToRunner(
- &application_request, mojo::ScopedMessagePipeHandle()));
+ base::MessageLoop loop(mojo::common::MessagePumpMojo::Create());
mojo::ApplicationImpl impl(&delegate, application_request.Pass());
loop.Run();
}
+ connection.reset();
+
mojo::embedder::ShutdownIPCSupport();
}
diff --git a/content/app/BUILD.gn b/content/app/BUILD.gn
index 021c51f..b83b529 100644
--- a/content/app/BUILD.gn
+++ b/content/app/BUILD.gn
@@ -70,7 +70,6 @@ if (is_ios) {
content_app_extra_configs = [
"//build/config/compiler:wexit_time_destructors",
"//content:content_implementation",
- "//content/public/common:mojo_shell_client",
"//v8:external_startup_data",
]
diff --git a/content/browser/BUILD.gn b/content/browser/BUILD.gn
index 66a7ab9..9990e72 100644
--- a/content/browser/BUILD.gn
+++ b/content/browser/BUILD.gn
@@ -12,10 +12,7 @@ source_set("browser") {
# internal content ones) should depend on the public one.
visibility = [ "//content/public/browser:browser_sources" ]
- configs += [
- "//build/config:precompiled_headers",
- "//content/public/common:mojo_shell_client",
- ]
+ configs += [ "//build/config:precompiled_headers" ]
defines = []
libs = []
ldflags = []
@@ -107,10 +104,7 @@ source_set("browser") {
],
".")
- sources += [
- "mojo/mojo_shell_client_host.cc",
- "mojo/mojo_shell_client_host.h",
- ]
+ defines += [ "MOJO_SHELL_CLIENT" ]
# Non-iOS deps.
deps += [
diff --git a/content/browser/child_process_launcher.cc b/content/browser/child_process_launcher.cc
index e54cada..830d5b9 100644
--- a/content/browser/child_process_launcher.cc
+++ b/content/browser/child_process_launcher.cc
@@ -48,6 +48,17 @@
#include "gin/v8_initializer.h"
#endif
+#if defined(MOJO_SHELL_CLIENT)
+#include "base/thread_task_runner_handle.h"
+#include "content/public/common/mojo_shell_connection.h"
+#include "mojo/application/public/cpp/application_impl.h"
+#include "mojo/converters/network/network_type_converters.h"
+#include "mojo/shell/application_manager.mojom.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/scoped_platform_handle.h"
+#endif
+
namespace content {
namespace {
@@ -322,6 +333,10 @@ void SetProcessBackgroundedOnLauncherThread(base::Process process,
#endif
}
+#if defined(MOJO_SHELL_CLIENT)
+void DidCreateChannel(mojo::embedder::ChannelInfo* info) {}
+#endif
+
} // namespace
ChildProcessLauncher::ChildProcessLauncher(
@@ -365,6 +380,10 @@ void ChildProcessLauncher::Launch(
int child_process_id) {
DCHECK(CalledOnValidThread());
+#if defined(MOJO_SHELL_CLIENT)
+ CreateMojoShellChannel(cmd_line, child_process_id);
+#endif
+
#if defined(OS_ANDROID)
// Android only supports renderer, sandboxed utility and gpu.
std::string process_type =
@@ -504,6 +523,46 @@ void ChildProcessLauncher::Notify(
}
}
+#if defined(MOJO_SHELL_CLIENT)
+void ChildProcessLauncher::CreateMojoShellChannel(
+ base::CommandLine* command_line,
+ int child_process_id) {
+ // Some process types get created before the main message loop.
+ if (!MojoShellConnection::Get())
+ return;
+
+ // Create the channel to be shared with the target process.
+ mojo::embedder::HandlePassingInformation handle_passing_info;
+ mojo::embedder::PlatformChannelPair platform_channel_pair;
+
+ // Give one end to the shell so that it can create an instance.
+ mojo::embedder::ScopedPlatformHandle platform_channel =
+ platform_channel_pair.PassServerHandle();
+ mojo::ScopedMessagePipeHandle handle(mojo::embedder::CreateChannel(
+ platform_channel.Pass(), base::Bind(&DidCreateChannel),
+ base::ThreadTaskRunnerHandle::Get()));
+ mojo::shell::mojom::ApplicationManagerPtr application_manager;
+ MojoShellConnection::Get()->GetApplication()->ConnectToService(
+ mojo::URLRequest::From(std::string("mojo:shell")),
+ &application_manager);
+ // The content of the URL/qualifier we pass is actually meaningless, it's only
+ // important that they're unique per process.
+ // TODO(beng): We need to specify a restrictive CapabilityFilter here that
+ // matches the needs of the target process. Figure out where that
+ // specification is best determined (not here, this is a common
+ // chokepoint for all process types) and how to wire it through.
+ // http://crbug.com/555393
+ application_manager->CreateInstanceForHandle(
+ mojo::ScopedHandle(mojo::Handle(handle.release().value())),
+ "exe:chrome_renderer", // See above about how this string is meaningless.
+ base::IntToString(child_process_id));
+
+ // Put the other end on the command line used to launch the target.
+ platform_channel_pair.PrepareToPassClientHandleToChildProcess(
+ command_line, &handle_passing_info);
+}
+#endif // defined(MOJO_SHELL_CLIENT)
+
bool ChildProcessLauncher::IsStarting() {
// TODO(crbug.com/469248): This fails in some tests.
// DCHECK(CalledOnValidThread());
diff --git a/content/browser/mojo/mojo_shell_client_host.cc b/content/browser/mojo/mojo_shell_client_host.cc
deleted file mode 100644
index 7c2c8ac..0000000
--- a/content/browser/mojo/mojo_shell_client_host.cc
+++ /dev/null
@@ -1,72 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "base/thread_task_runner_handle.h"
-#include "content/browser/mojo/mojo_shell_client_host.h"
-#include "content/common/mojo/mojo_messages.h"
-#include "content/public/common/mojo_shell_connection.h"
-#include "ipc/ipc_sender.h"
-#include "mojo/application/public/cpp/application_impl.h"
-#include "mojo/converters/network/network_type_converters.h"
-#include "mojo/shell/application_manager.mojom.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/scoped_platform_handle.h"
-
-namespace content {
-namespace {
-void DidCreateChannel(mojo::embedder::ChannelInfo* info) {}
-
-base::PlatformFile PlatformFileFromScopedPlatformHandle(
- mojo::embedder::ScopedPlatformHandle handle) {
-#if defined(OS_POSIX)
- return handle.release().fd;
-#elif defined(OS_WIN)
- return handle.release().handle;
-#endif
-}
-
-} // namespace
-
-void RegisterChildWithExternalShell(int child_process_id,
- base::ProcessHandle process_handle,
- IPC::Sender* sender) {
- // Some process types get created before the main message loop.
- if (!MojoShellConnection::Get())
- return;
-
- // Create the channel to be shared with the target process.
- mojo::embedder::HandlePassingInformation handle_passing_info;
- mojo::embedder::PlatformChannelPair platform_channel_pair;
-
- // Give one end to the shell so that it can create an instance.
- mojo::embedder::ScopedPlatformHandle platform_channel =
- platform_channel_pair.PassServerHandle();
- mojo::ScopedMessagePipeHandle handle(mojo::embedder::CreateChannel(
- platform_channel.Pass(), base::Bind(&DidCreateChannel),
- base::ThreadTaskRunnerHandle::Get()));
- mojo::shell::mojom::ApplicationManagerPtr application_manager;
- MojoShellConnection::Get()->GetApplication()->ConnectToService(
- mojo::URLRequest::From(std::string("mojo:shell")),
- &application_manager);
- // The content of the URL/qualifier we pass is actually meaningless, it's only
- // important that they're unique per process.
- // TODO(beng): We need to specify a restrictive CapabilityFilter here that
- // matches the needs of the target process. Figure out where that
- // specification is best determined (not here, this is a common
- // chokepoint for all process types) and how to wire it through.
- // http://crbug.com/555393
- application_manager->CreateInstanceForHandle(
- mojo::ScopedHandle(mojo::Handle(handle.release().value())),
- "exe:chrome_renderer", // See above about how this string is meaningless.
- base::IntToString(child_process_id));
-
- // Send the other end to the child via Chrome IPC.
- base::PlatformFile client_file = PlatformFileFromScopedPlatformHandle(
- platform_channel_pair.PassClientHandle());
- sender->Send(new MojoMsg_BindControllerHandle(
- IPC::GetFileHandleForProcess(client_file, process_handle, true)));
-}
-
-} // namespace content
diff --git a/content/browser/mojo/mojo_shell_client_host.h b/content/browser/mojo/mojo_shell_client_host.h
deleted file mode 100644
index 3f2b4da..0000000
--- a/content/browser/mojo/mojo_shell_client_host.h
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CONTENT_BROWSER_MOJO_MOJO_SHELL_CLIENT_HOST_H_
-#define CONTENT_BROWSER_MOJO_MOJO_SHELL_CLIENT_HOST_H_
-
-#include "base/process/process_handle.h"
-
-namespace IPC {
-class Sender;
-}
-
-namespace content {
-
-// Creates a communication channel between the external Mojo shell and the
-// child. The server handle of this channel is shared with the external shell
-// via Mojo IPC and the client handle is shared with the child via Chrome IPC.
-// |child_process_id| is used to uniquify the child in the external shell's
-// instance map.
-void RegisterChildWithExternalShell(int child_process_id,
- base::ProcessHandle process_handle,
- IPC::Sender* sender);
-
-} // namespace content
-
-#endif // CONTENT_BROWSER_MOJO_MOJO_SHELL_CLIENT_HOST_H_
diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc
index 0aa3ee339..75334a2 100644
--- a/content/browser/renderer_host/render_process_host_impl.cc
+++ b/content/browser/renderer_host/render_process_host_impl.cc
@@ -221,10 +221,6 @@
#include "content/common/media/media_stream_messages.h"
#endif
-#if defined(MOJO_SHELL_CLIENT)
-#include "content/browser/mojo/mojo_shell_client_host.h"
-#endif
-
#if defined(OS_WIN)
#define IntToStringType base::IntToString16
#else
@@ -2454,12 +2450,6 @@ void RenderProcessHostImpl::OnProcessLaunched() {
Source<RenderProcessHost>(this),
NotificationService::NoDetails());
-#if defined(MOJO_SHELL_CLIENT)
- // Send a handle that the external Mojo shell can use to pass an Application
- // request to the child.
- RegisterChildWithExternalShell(id_, GetHandle(), this);
-#endif
-
// TODO(erikchen): Remove ScopedTracker below once http://crbug.com/465841
// is fixed.
tracked_objects::ScopedTracker tracking_profile4(
diff --git a/content/child/BUILD.gn b/content/child/BUILD.gn
index 3ebac31..02dec55 100644
--- a/content/child/BUILD.gn
+++ b/content/child/BUILD.gn
@@ -15,10 +15,7 @@ source_set("child") {
".",
"//content")
- configs += [
- "//build/config:precompiled_headers",
- "//content/public/common:mojo_shell_client",
- ]
+ configs += [ "//build/config:precompiled_headers" ]
public_deps = [
"//third_party/mojo/src/mojo/edk/system",
diff --git a/content/child/child_thread_impl.cc b/content/child/child_thread_impl.cc
index 845eabd..01cf63a 100644
--- a/content/child/child_thread_impl.cc
+++ b/content/child/child_thread_impl.cc
@@ -73,11 +73,6 @@
#include "ui/ozone/public/client_native_pixmap_factory.h"
#endif
-#if defined(MOJO_SHELL_CLIENT)
-#include "content/common/mojo/mojo_messages.h"
-#include "content/common/mojo/mojo_shell_connection_impl.h"
-#endif
-
using tracked_objects::ThreadData;
namespace content {
@@ -659,9 +654,6 @@ bool ChildThreadImpl::OnMessageReceived(const IPC::Message& msg) {
#if defined(USE_TCMALLOC)
IPC_MESSAGE_HANDLER(ChildProcessMsg_GetTcmallocStats, OnGetTcmallocStats)
#endif
-#if defined(MOJO_SHELL_CLIENT)
- IPC_MESSAGE_HANDLER(MojoMsg_BindControllerHandle, OnBindControllerHandle)
-#endif
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
@@ -726,21 +718,6 @@ void ChildThreadImpl::OnGetTcmallocStats() {
}
#endif
-#if defined(MOJO_SHELL_CLIENT)
-void ChildThreadImpl::OnBindControllerHandle(
- const IPC::PlatformFileForTransit& file) {
-#if defined(OS_POSIX)
- base::PlatformFile handle = file.fd;
-#elif defined(OS_WIN)
- base::PlatformFile handle = file;
-#endif
- mojo::ScopedMessagePipeHandle message_pipe =
- mojo_shell_channel_init_.Init(handle, GetIOTaskRunner());
- DCHECK(message_pipe.is_valid());
- MojoShellConnectionImpl::CreateWithMessagePipe(message_pipe.Pass());
-}
-#endif
-
ChildThreadImpl* ChildThreadImpl::current() {
return g_lazy_tls.Pointer()->Get();
}
diff --git a/content/child/child_thread_impl.h b/content/child/child_thread_impl.h
index 8d2b45c..2914b00 100644
--- a/content/child/child_thread_impl.h
+++ b/content/child/child_thread_impl.h
@@ -20,11 +20,6 @@
#include "content/public/child/child_thread.h"
#include "ipc/ipc_message.h" // For IPC_MESSAGE_LOG_ENABLED.
-#if defined(MOJO_SHELL_CLIENT)
-#include "content/common/mojo/channel_init.h"
-#include "ipc/ipc_platform_file.h"
-#endif
-
namespace base {
class MessageLoop;
@@ -240,9 +235,6 @@ class CONTENT_EXPORT ChildThreadImpl
#if defined(USE_TCMALLOC)
void OnGetTcmallocStats();
#endif
-#if defined(MOJO_SHELL_CLIENT)
- void OnBindControllerHandle(const IPC::PlatformFileForTransit& file);
-#endif
void EnsureConnected();
@@ -305,10 +297,6 @@ class CONTENT_EXPORT ChildThreadImpl
scoped_refptr<base::SequencedTaskRunner> browser_process_io_runner_;
-#if defined(MOJO_SHELL_CLIENT)
- ChannelInit mojo_shell_channel_init_;
-#endif
-
base::WeakPtrFactory<ChildThreadImpl> channel_connected_factory_;
DISALLOW_COPY_AND_ASSIGN(ChildThreadImpl);
diff --git a/content/common/BUILD.gn b/content/common/BUILD.gn
index f9f4600..fbe711a 100644
--- a/content/common/BUILD.gn
+++ b/content/common/BUILD.gn
@@ -208,7 +208,7 @@ source_set("common") {
]
}
- defines = []
+ defines = [ "MOJO_SHELL_CLIENT" ]
include_dirs = []
libs = []
ldflags = []
diff --git a/content/common/mojo/mojo_messages.h b/content/common/mojo/mojo_messages.h
index 89c94f3..45133d7 100644
--- a/content/common/mojo/mojo_messages.h
+++ b/content/common/mojo/mojo_messages.h
@@ -21,8 +21,3 @@
// Mojo IPC is bootstrapped over Chrome IPC via this message.
IPC_MESSAGE_CONTROL1(MojoMsg_Activate,
IPC::PlatformFileForTransit /* handle */)
-
-// Mojo IPC to an external shell is bootstrapped over Chrome IPC via this
-// message.
-IPC_MESSAGE_CONTROL1(MojoMsg_BindControllerHandle,
- IPC::PlatformFileForTransit /* handle */)
diff --git a/content/common/mojo/mojo_shell_connection_impl.cc b/content/common/mojo/mojo_shell_connection_impl.cc
index 25c8be1..5125df3 100644
--- a/content/common/mojo/mojo_shell_connection_impl.cc
+++ b/content/common/mojo/mojo_shell_connection_impl.cc
@@ -31,26 +31,19 @@ bool IsRunningInMojoShell() {
// static
void MojoShellConnectionImpl::Create() {
DCHECK(IsRunningInMojoShell());
- CreateWithMessagePipe(mojo::ScopedMessagePipeHandle());
-}
-
-// static
-void MojoShellConnectionImpl::CreateWithMessagePipe(
- mojo::ScopedMessagePipeHandle handle) {
DCHECK(!lazy_tls_ptr.Pointer()->Get());
MojoShellConnectionImpl* connection = new MojoShellConnectionImpl;
lazy_tls_ptr.Pointer()->Set(connection);
- connection->WaitForShell(handle.Pass());
+ connection->WaitForShell();
}
MojoShellConnectionImpl::MojoShellConnectionImpl() : initialized_(false) {}
MojoShellConnectionImpl::~MojoShellConnectionImpl() {}
-void MojoShellConnectionImpl::WaitForShell(
- mojo::ScopedMessagePipeHandle handle) {
+void MojoShellConnectionImpl::WaitForShell() {
mojo::InterfaceRequest<mojo::Application> application_request;
- runner_connection_.reset(mojo::runner::RunnerConnection::ConnectToRunner(
- &application_request, handle.Pass()));
+ runner_connection_.reset(
+ mojo::runner::RunnerConnection::ConnectToRunner(&application_request));
application_impl_.reset(new mojo::ApplicationImpl(
this, application_request.Pass()));
application_impl_->WaitForInitialize();
diff --git a/content/common/mojo/mojo_shell_connection_impl.h b/content/common/mojo/mojo_shell_connection_impl.h
index 8891acb..484e2ab7 100644
--- a/content/common/mojo/mojo_shell_connection_impl.h
+++ b/content/common/mojo/mojo_shell_connection_impl.h
@@ -11,7 +11,6 @@
#include "base/memory/scoped_ptr.h"
#include "content/public/common/mojo_shell_connection.h"
#include "mojo/application/public/cpp/application_delegate.h"
-#include "mojo/public/cpp/system/message_pipe.h"
namespace mojo {
namespace runner {
@@ -21,7 +20,8 @@ class RunnerConnection;
namespace content {
-// Returns true for processes launched from an external mojo shell.
+// Returns true if the Chrome browser process was launched from the external
+// Mojo shell.
bool IsRunningInMojoShell();
class MojoShellConnectionImpl : public MojoShellConnection,
@@ -32,9 +32,6 @@ class MojoShellConnectionImpl : public MojoShellConnection,
// thread until calling GetApplication() will return an Initialized()
// application with a bound ShellPtr.
static void Create();
- // Same as Create(), but receives a handle instead of looking for one on the
- // command line.
- static void CreateWithMessagePipe(mojo::ScopedMessagePipeHandle handle);
private:
MojoShellConnectionImpl();
@@ -53,7 +50,7 @@ class MojoShellConnectionImpl : public MojoShellConnection,
// Blocks the calling thread until a connection to the spawning shell is
// established, an Application request from it is bound, and the Initialize()
// method on that application is called.
- void WaitForShell(mojo::ScopedMessagePipeHandle handle);
+ void WaitForShell();
bool initialized_;
scoped_ptr<mojo::runner::RunnerConnection> runner_connection_;
diff --git a/content/gpu/BUILD.gn b/content/gpu/BUILD.gn
index ea70fe5..74c0142 100644
--- a/content/gpu/BUILD.gn
+++ b/content/gpu/BUILD.gn
@@ -38,10 +38,7 @@ source_set("gpu_sources") {
"in_process_gpu_thread.h",
]
- configs += [
- "//content:content_implementation",
- "//content/public/common:mojo_shell_client",
- ]
+ configs += [ "//content:content_implementation" ]
deps = [
"//base",
diff --git a/content/plugin/BUILD.gn b/content/plugin/BUILD.gn
index 096b3ce..32b6e03 100644
--- a/content/plugin/BUILD.gn
+++ b/content/plugin/BUILD.gn
@@ -28,10 +28,7 @@ if (enable_plugins && !is_linux) {
"webplugin_proxy.h",
]
- configs += [
- "//content:content_implementation",
- "//content/public/common:mojo_shell_client",
- ]
+ configs += [ "//content:content_implementation" ]
deps = [
"//content:export",
diff --git a/content/ppapi_plugin/BUILD.gn b/content/ppapi_plugin/BUILD.gn
index 6ce967d..ef4dcdf 100644
--- a/content/ppapi_plugin/BUILD.gn
+++ b/content/ppapi_plugin/BUILD.gn
@@ -32,10 +32,7 @@ source_set("ppapi_plugin_sources") {
"ppapi_thread.h",
]
- configs += [
- "//content:content_implementation",
- "//content/public/common:mojo_shell_client",
- ]
+ configs += [ "//content:content_implementation" ]
deps = [
"//base",
diff --git a/content/public/browser/BUILD.gn b/content/public/browser/BUILD.gn
index aaa0ae4..89fdec1 100644
--- a/content/public/browser/BUILD.gn
+++ b/content/public/browser/BUILD.gn
@@ -46,7 +46,6 @@ source_set("browser_sources") {
configs += [
"//build/config:precompiled_headers",
"//content:content_implementation",
- "//content/public/common:mojo_shell_client",
]
public_deps = [
diff --git a/content/public/common/BUILD.gn b/content/public/common/BUILD.gn
index 9c1e0f7..63f5fa9 100644
--- a/content/public/common/BUILD.gn
+++ b/content/public/common/BUILD.gn
@@ -44,15 +44,6 @@ config("static_switches_defines") {
defines = [ "COMPILE_CONTENT_STATICALLY" ]
}
-# Set in GN builds, triggering behavior in content when run from an external
-# Mojo shell.
-config("mojo_shell_client") {
- # This configuration has only been tested on these platforms.
- if (is_win || is_linux || is_chromeos) {
- defines = [ "MOJO_SHELL_CLIENT" ]
- }
-}
-
# This target allows you to use the content_switches constants and statically
# link to it, without depending on the rest of content. This is only for use
# without content, or you will get multiply defined symbols.
diff --git a/content/public/renderer/BUILD.gn b/content/public/renderer/BUILD.gn
index 778d66f..0ab2d33 100644
--- a/content/public/renderer/BUILD.gn
+++ b/content/public/renderer/BUILD.gn
@@ -25,10 +25,7 @@ source_set("renderer_sources") {
".",
"//content")
- configs += [
- "//content:content_implementation",
- "//content/public/common:mojo_shell_client",
- ]
+ configs += [ "//content:content_implementation" ]
deps = [
"//content/public/common:common_sources",
diff --git a/content/renderer/BUILD.gn b/content/renderer/BUILD.gn
index d105612..42da81ac 100644
--- a/content/renderer/BUILD.gn
+++ b/content/renderer/BUILD.gn
@@ -18,7 +18,6 @@ source_set("renderer") {
configs += [
"//content:content_implementation",
- "//content/public/common:mojo_shell_client",
"//build/config/compiler:no_size_t_to_int_warning",
]
diff --git a/content/test/BUILD.gn b/content/test/BUILD.gn
index c6d764c..c9f5fa0 100644
--- a/content/test/BUILD.gn
+++ b/content/test/BUILD.gn
@@ -349,7 +349,6 @@ test("content_browsertests") {
configs += [
"//build/config:precompiled_headers",
"//build/config/compiler:no_size_t_to_int_warning",
- "//content/public/common:mojo_shell_client",
]
deps = [
@@ -550,10 +549,7 @@ test("content_unittests") {
}
}
- configs += [
- "//build/config:precompiled_headers",
- "//content/public/common:mojo_shell_client",
- ]
+ configs += [ "//build/config:precompiled_headers" ]
deps = [
":test_support",
diff --git a/content/utility/BUILD.gn b/content/utility/BUILD.gn
index 9bfe941..65012ac 100644
--- a/content/utility/BUILD.gn
+++ b/content/utility/BUILD.gn
@@ -13,10 +13,7 @@ source_set("utility") {
sources =
rebase_path(content_utility_gypi_values.utility_sources, ".", "//content")
- configs += [
- "//content:content_implementation",
- "//content/public/common:mojo_shell_client",
- ]
+ configs += [ "//content:content_implementation" ]
deps = [
"//base",
diff --git a/mojo/runner/child/runner_connection.cc b/mojo/runner/child/runner_connection.cc
index ca0c7fc..c7758c4 100644
--- a/mojo/runner/child/runner_connection.cc
+++ b/mojo/runner/child/runner_connection.cc
@@ -23,8 +23,6 @@ namespace mojo {
namespace runner {
namespace {
-void DidCreateChannel(embedder::ChannelInfo* channel_info) {}
-
// Blocks a thread until another thread unblocks it, at which point it unblocks
// and runs a closure provided by that thread.
class Blocker {
@@ -91,8 +89,7 @@ class RunnerConnectionImpl : public RunnerConnection {
// Returns true if a connection to the runner has been established and
// |request| has been modified, false if no connection was established.
- bool WaitForApplicationRequest(InterfaceRequest<Application>* request,
- ScopedMessagePipeHandle handle);
+ bool WaitForApplicationRequest(InterfaceRequest<Application>* request);
ChildControllerImpl* controller() const { return controller_.get(); }
@@ -136,15 +133,23 @@ class ChildControllerImpl : public ChildController {
// etc.
static void Create(RunnerConnectionImpl* connection,
const GotApplicationRequestCallback& callback,
- ScopedMessagePipeHandle runner_handle,
+ embedder::ScopedPlatformHandle platform_channel,
const Blocker::Unblocker& unblocker) {
DCHECK(connection);
+ DCHECK(platform_channel.is_valid());
+
DCHECK(!connection->controller());
scoped_ptr<ChildControllerImpl> impl(
new ChildControllerImpl(connection, callback, unblocker));
- impl->Bind(runner_handle.Pass());
+ ScopedMessagePipeHandle host_message_pipe(embedder::CreateChannel(
+ platform_channel.Pass(),
+ base::Bind(&ChildControllerImpl::DidCreateChannel,
+ base::Unretained(impl.get())),
+ base::ThreadTaskRunnerHandle::Get()));
+
+ impl->Bind(host_message_pipe.Pass());
connection->set_controller(impl.Pass());
}
@@ -186,6 +191,13 @@ class ChildControllerImpl : public ChildController {
binding_.set_connection_error_handler([this]() { OnConnectionError(); });
}
+ // Callback for |embedder::CreateChannel()|.
+ void DidCreateChannel(embedder::ChannelInfo* channel_info) {
+ DVLOG(2) << "ChildControllerImpl::DidCreateChannel()";
+ DCHECK(thread_checker_.CalledOnValidThread());
+ channel_info_ = channel_info;
+ }
+
static void ReturnApplicationRequestOnMainThread(
const GotApplicationRequestCallback& callback,
InterfaceRequest<Application> application_request) {
@@ -205,20 +217,12 @@ class ChildControllerImpl : public ChildController {
};
bool RunnerConnectionImpl::WaitForApplicationRequest(
- InterfaceRequest<Application>* request,
- ScopedMessagePipeHandle handle) {
- // If a valid message pipe to the runner was not provided, look for one on the
- // command line.
- if (!handle.is_valid()) {
- embedder::ScopedPlatformHandle platform_channel =
- embedder::PlatformChannelPair::PassClientHandleFromParentProcess(
- *base::CommandLine::ForCurrentProcess());
- if (!platform_channel.is_valid())
- return false;
- handle = embedder::CreateChannel(platform_channel.Pass(),
- base::Bind(&DidCreateChannel),
- base::ThreadTaskRunnerHandle::Get());
- }
+ InterfaceRequest<Application>* request) {
+ embedder::ScopedPlatformHandle platform_channel =
+ embedder::PlatformChannelPair::PassClientHandleFromParentProcess(
+ *base::CommandLine::ForCurrentProcess());
+ if (!platform_channel.is_valid())
+ return false;
Blocker blocker;
controller_runner_->PostTask(
@@ -226,7 +230,7 @@ bool RunnerConnectionImpl::WaitForApplicationRequest(
base::Bind(
&ChildControllerImpl::Create, base::Unretained(this),
base::Bind(&OnGotApplicationRequest, base::Unretained(request)),
- base::Passed(&handle), blocker.GetUnblocker()));
+ base::Passed(&platform_channel), blocker.GetUnblocker()));
blocker.Block();
return true;
@@ -238,10 +242,9 @@ RunnerConnection::~RunnerConnection() {}
// static
RunnerConnection* RunnerConnection::ConnectToRunner(
- InterfaceRequest<Application>* request,
- ScopedMessagePipeHandle handle) {
+ InterfaceRequest<Application>* request) {
RunnerConnectionImpl* connection = new RunnerConnectionImpl;
- if (!connection->WaitForApplicationRequest(request, handle.Pass())) {
+ if (!connection->WaitForApplicationRequest(request)) {
delete connection;
return nullptr;
}
diff --git a/mojo/runner/child/runner_connection.h b/mojo/runner/child/runner_connection.h
index 68202e1..8ca8778 100644
--- a/mojo/runner/child/runner_connection.h
+++ b/mojo/runner/child/runner_connection.h
@@ -24,8 +24,7 @@ class RunnerConnection {
// If a connection to the runner cannot be established, |request| will not be
// modified and this function will return null.
static RunnerConnection* ConnectToRunner(
- InterfaceRequest<Application>* request,
- ScopedMessagePipeHandle handle);
+ InterfaceRequest<Application>* request);
protected:
RunnerConnection();
diff --git a/mojo/runner/child/test_native_main.cc b/mojo/runner/child/test_native_main.cc
index a7e57b4..c9bf253 100644
--- a/mojo/runner/child/test_native_main.cc
+++ b/mojo/runner/child/test_native_main.cc
@@ -56,17 +56,19 @@ int TestNativeMain(mojo::ApplicationDelegate* application_delegate) {
mojo::embedder::ProcessType::NONE, &process_delegate,
io_thread.task_runner().get(), mojo::embedder::ScopedPlatformHandle());
- base::MessageLoop loop(mojo::common::MessagePumpMojo::Create());
mojo::InterfaceRequest<mojo::Application> application_request;
scoped_ptr<mojo::runner::RunnerConnection> connection(
- mojo::runner::RunnerConnection::ConnectToRunner(
- &application_request, ScopedMessagePipeHandle()));
+ mojo::runner::RunnerConnection::ConnectToRunner(&application_request));
+
+ base::MessageLoop loop(mojo::common::MessagePumpMojo::Create());
{
mojo::ApplicationImpl impl(application_delegate,
application_request.Pass());
loop.Run();
}
+ connection.reset();
+
mojo::embedder::ShutdownIPCSupport();
}