diff options
author | alancutter <alancutter@chromium.org> | 2015-11-18 15:54:20 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-11-18 23:55:18 +0000 |
commit | 1b3bd8ec1752e2c0442746c0f1f60e693601b4f2 (patch) | |
tree | ce03b66b71b9d344e2d67da7ed5ffefa19836b88 | |
parent | c9a2c739d2bc6d1ce7e8a01f55ecd47a89593f24 (diff) | |
download | chromium_src-1b3bd8ec1752e2c0442746c0f1f60e693601b4f2.zip chromium_src-1b3bd8ec1752e2c0442746c0f1f60e693601b4f2.tar.gz chromium_src-1b3bd8ec1752e2c0442746c0f1f60e693601b4f2.tar.bz2 |
Revert of Bind Application in renderer (patchset #15 id:280001 of https://codereview.chromium.org/1452823003/ )
Reason for revert:
This change is making hundreds of webkit_tests crash on linux_chromium_rel_ng with:
[1:1:1118/141621:108326049405:FATAL:lock.cc(32)] Check failed: owning_thread_ref_.is_null().
#0 0x00000067e2de base::debug::StackTrace::StackTrace()
#1 0x00000057a71f logging::LogMessage::~LogMessage()
#2 0x0000005eb69b base::Lock::CheckUnheldAndMark()
#3 0x000000518e1c base::Lock::Acquire()
#4 0x000000518b43 base::AutoLock::AutoLock()
#5 0x0000005b4014 base::SequenceCheckerImpl::CalledOnValidSequencedThread()
#6 0x000006f074ae IDMap<>::Lookup()
#7 0x000006f0598c content::RendererBlinkPlatformImpl::SetPlatformEventObserverForTesting()
#8 0x000008459264 content::SetMockGamepadProvider()
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}
>
> Committed: https://crrev.com/2c716f9d5ebff610641f4506c17ec81d4b89b7bb
> Cr-Commit-Position: refs/heads/master@{#360396}
TBR=jam@chromium.org,tsepez@chromium.org,ben@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
Review URL: https://codereview.chromium.org/1457173002
Cr-Commit-Position: refs/heads/master@{#360446}
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 fef64c5..be9766f 100644 --- a/content/common/BUILD.gn +++ b/content/common/BUILD.gn @@ -209,7 +209,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(); } |