Skip to content

Commit

Permalink
Move Shell connection to content.
Browse files Browse the repository at this point in the history
I want to be able to use Mojo in content, so I think it makes sense that the shell bind step lives in content too.

1. Moves MojoRunnerState to content/common and renames it to MojoShellConnection. This class will be available in any process that creates an impl prior to running the main message loop.

2. Modifies ChildProcessLauncher to create a platform channel pair and put the client handle on the command line of the child process, and registers the server handle with the external shell. This will allow the child process to bind an Application request if it wants.

TODO: What if the child process doesn't bind it? What happens to the instance created in the external shell?
TODO: ChildProcessLauncher is a convenient chokepoint. It means the shell handle is passed to all child processes created by content. Do we want to do this? I think it's OK for now since this code is only triggered if Chrome itself is run from within the external shell. Before we can move this to production I think CreateInstanceForHandle is going to have to take a CapabilityFilter.

R=jam@chromium.org
http://crbug.com/551253

Review URL: https://codereview.chromium.org/1442893002

Cr-Commit-Position: refs/heads/master@{#359770}
  • Loading branch information
ben authored and Commit bot committed Nov 15, 2015
1 parent e9b72dd commit 03b7b9d
Show file tree
Hide file tree
Showing 36 changed files with 407 additions and 167 deletions.
9 changes: 3 additions & 6 deletions chrome/browser/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -575,22 +575,19 @@ source_set("browser") {
# These files are only built in a GN build because they bring in
# dependencies that don't build with GYP.
sources += [
"mojo_runner_state.cc",
"mojo_runner_state.h",
"ui/views/frame/browser_frame_mus.cc",
"ui/views/frame/browser_frame_mus.h",
]
deps += [
"//components/mus/public/interfaces",
"//content/public/common",
"//mojo/runner/child:lib",
"//mojo/converters/network",
"//ui/aura",
"//ui/compositor",
"//ui/keyboard",
"//ui/keyboard:keyboard_with_content",
"//ui/views/mus",
"//ui/views/mus:for_component",
]
defines += [ "MOJO_RUNNER_CLIENT" ]
defines += [ "MOJO_SHELL_CLIENT" ]
data_deps += [ "//components/mus/example/wm:example_wm" ]
}
if (ui_compositor_image_transport) {
Expand Down
12 changes: 0 additions & 12 deletions chrome/browser/chrome_browser_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
#include "chrome/browser/memory/tab_manager.h"
#include "chrome/browser/metrics/field_trial_synchronizer.h"
#include "chrome/browser/metrics/thread_watcher.h"
#include "chrome/browser/mojo_runner_util.h"
#include "chrome/browser/nacl_host/nacl_browser_delegate_impl.h"
#include "chrome/browser/net/crl_set_fetcher.h"
#include "chrome/browser/performance_monitor/performance_monitor.h"
Expand Down Expand Up @@ -248,10 +247,6 @@
#include "components/webusb/webusb_detector.h"
#endif

#if defined(MOJO_RUNNER_CLIENT)
#include "chrome/browser/mojo_runner_state.h"
#endif

using content::BrowserThread;

namespace {
Expand Down Expand Up @@ -1217,13 +1212,6 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
SCOPED_UMA_HISTOGRAM_LONG_TIMER("Startup.PreMainMessageLoopRunImplLongTime");
const base::TimeTicks start_time_step1 = base::TimeTicks::Now();

#if defined(MOJO_RUNNER_CLIENT)
if (IsRunningInMojoRunner()) {
mojo_runner_state_.reset(new MojoRunnerState);
mojo_runner_state_->WaitForConnection();
}
#endif // defined(MOJO_RUNNER_CLIENT)

#if defined(OS_WIN)
// Windows parental controls calls can be slow, so we do an early init here
// that calculates this value off of the UI thread.
Expand Down
5 changes: 0 additions & 5 deletions chrome/browser/chrome_browser_main.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ class BrowserProcessImpl;
class ChromeBrowserMainExtraParts;
class FieldTrialSynchronizer;
class MetricsService;
class MojoRunnerState;
class PrefService;
class ProcessPowerCollector;
class Profile;
Expand Down Expand Up @@ -192,10 +191,6 @@ class ChromeBrowserMainParts : public content::BrowserMainParts {
// Members needed across shutdown methods.
bool restart_last_session_;

#if defined(MOJO_RUNNER_CLIENT)
scoped_ptr<MojoRunnerState> mojo_runner_state_;
#endif

DISALLOW_COPY_AND_ASSIGN(ChromeBrowserMainParts);
};

Expand Down
46 changes: 0 additions & 46 deletions chrome/browser/mojo_runner_state.cc

This file was deleted.

41 changes: 0 additions & 41 deletions chrome/browser/mojo_runner_state.h

This file was deleted.

12 changes: 0 additions & 12 deletions chrome/browser/mojo_runner_util.cc

This file was deleted.

11 changes: 0 additions & 11 deletions chrome/browser/mojo_runner_util.h

This file was deleted.

1 change: 1 addition & 0 deletions chrome/browser/ui/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ source_set("ui") {
"//ui/keyboard:resources",
"//ui/wm",
]
defines += [ "MOJO_SHELL_CLIENT" ]
if (!is_chromeos) {
sources += rebase_path(gypi_values.chrome_browser_ui_aura_non_chromeos,
".",
Expand Down
9 changes: 7 additions & 2 deletions chrome/browser/ui/views/frame/browser_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#include "chrome/browser/extensions/extension_util.h"
#include "chrome/browser/extensions/tab_helper.h"
#include "chrome/browser/infobars/infobar_service.h"
#include "chrome/browser/mojo_runner_util.h"
#include "chrome/browser/native_window_notification_source.h"
#include "chrome/browser/profiles/avatar_menu.h"
#include "chrome/browser/profiles/profile.h"
Expand Down Expand Up @@ -171,6 +170,10 @@
#include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h"
#endif

#if defined(MOJO_SHELL_CLIENT)
#include "content/public/common/mojo_shell_connection.h"
#endif

using base::TimeDelta;
using base::UserMetricsAction;
using content::NativeWebKeyboardEvent;
Expand Down Expand Up @@ -2389,8 +2392,10 @@ void BrowserView::LoadAccelerators() {
// TODO(beng): for some reason GetFocusManager() returns null in this case,
// investigate, but for now just disable accelerators in this
// mode.
if (IsRunningInMojoRunner())
#if defined(MOJO_SHELL_CLIENT)
if (content::MojoShellConnection::Get())
return;
#endif

views::FocusManager* focus_manager = GetFocusManager();
DCHECK(focus_manager);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@

#include "chrome/browser/ui/views/frame/native_browser_frame_factory.h"

#include "chrome/browser/mojo_runner_util.h"
#include "chrome/browser/ui/views/frame/browser_frame_ash.h"
#include "chrome/browser/ui/views/frame/desktop_browser_frame_auralinux.h"

#if defined(MOJO_RUNNER_CLIENT)
#if defined(MOJO_SHELL_CLIENT)
#include "chrome/browser/ui/views/frame/browser_frame_mus.h"
#include "content/public/common/mojo_shell_connection.h"
#endif

NativeBrowserFrame* NativeBrowserFrameFactory::Create(
BrowserFrame* browser_frame,
BrowserView* browser_view) {
#if defined(MOJO_RUNNER_CLIENT)
if (IsRunningInMojoRunner())
#if defined(MOJO_SHELL_CLIENT)
if (content::MojoShellConnection::Get())
return new BrowserFrameMus(browser_frame, browser_view);
#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@
#include "chrome/browser/ui/views/frame/native_browser_frame_factory.h"

#include "ash/shell.h"
#include "chrome/browser/mojo_runner_util.h"
#include "chrome/browser/ui/views/frame/browser_frame_ashwin.h"
#include "chrome/browser/ui/views/frame/desktop_browser_frame_aura.h"

#if defined(MOJO_RUNNER_CLIENT)
#if defined(MOJO_SHELL_CLIENT)
#include "chrome/browser/ui/views/frame/browser_frame_mus.h"
#include "content/public/common/mojo_shell_connection.h"
#endif

NativeBrowserFrame* NativeBrowserFrameFactory::Create(
BrowserFrame* browser_frame,
BrowserView* browser_view) {
#if defined(MOJO_RUNNER_CLIENT)
if (IsRunningInMojoRunner())
#if defined(MOJO_SHELL_CLIENT)
if (content::MojoShellConnection::Get())
return new BrowserFrameMus(browser_frame, browser_view);
#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@

#include "chrome/browser/ui/views/frame/native_browser_frame_factory.h"

#include "chrome/browser/mojo_runner_util.h"
#include "chrome/browser/ui/views/frame/browser_frame_ash.h"

#if defined(MOJO_RUNNER_CLIENT)
#if defined(MOJO_SHELL_CLIENT)
#include "chrome/browser/ui/views/frame/browser_frame_mus.h"
#include "content/public/common/mojo_shell_connection.h"
#endif

NativeBrowserFrame* NativeBrowserFrameFactory::Create(
BrowserFrame* browser_frame,
BrowserView* browser_view) {
#if defined(MOJO_RUNNER_CLIENT)
if (IsRunningInMojoRunner())
#if defined(MOJO_SHELL_CLIENT)
if (content::MojoShellConnection::Get())
return new BrowserFrameMus(browser_frame, browser_view);
#endif
return new BrowserFrameAsh(browser_frame, browser_view);
Expand Down
2 changes: 0 additions & 2 deletions chrome/chrome_browser.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -671,8 +671,6 @@
'browser/memory_details_win.cc',
'browser/mod_pagespeed/mod_pagespeed_metrics.cc',
'browser/mod_pagespeed/mod_pagespeed_metrics.h',
'browser/mojo_runner_util.cc',
'browser/mojo_runner_util.h',
'browser/native_window_notification_source.h',
'browser/net/predictor_tab_helper.cc',
'browser/net/predictor_tab_helper.h',
Expand Down
2 changes: 1 addition & 1 deletion components/mus/example/mock_sysui/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ mojo_native_application("mock_sysui") {
"//mojo/converters/network",
"//skia",
"//ui/views",
"//ui/views/mus",
"//ui/views/mus:for_mojo_application",
]

resources = [ "$root_out_dir/views_mus_resources.pak" ]
Expand Down
2 changes: 1 addition & 1 deletion components/mus/example/views_examples/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ mojo_native_application("views_examples") {
"//ui/gfx/geometry",
"//ui/views",
"//ui/views/examples:views_examples_lib",
"//ui/views/mus",
"//ui/views/mus:for_mojo_application",
]

resources = [ "$root_out_dir/views_mus_resources.pak" ]
Expand Down
2 changes: 1 addition & 1 deletion components/mus/example/window_type_launcher/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ executable("window_type_launcher") {
"//ui/gfx",
"//ui/gfx/geometry",
"//ui/views",
"//ui/views/mus",
"//ui/views/mus:for_shared_library",
]

data_deps = [
Expand Down
2 changes: 1 addition & 1 deletion components/mus/example/wm/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ source_set("example_wm_lib") {
"//skia",
"//ui/mojo/init",
"//ui/views",
"//ui/views/mus",
"//ui/views/mus:for_mojo_application",
]
}

Expand Down
4 changes: 4 additions & 0 deletions components/mus/public/cpp/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,8 @@ source_set("cpp") {
data_deps = [
"//components/mus",
]

if (is_component_build) {
deps += [ "//mojo/gles2" ]
}
}
3 changes: 3 additions & 0 deletions content/browser/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ source_set("browser") {
],
".")

defines += [ "MOJO_SHELL_CLIENT" ]

# Non-iOS deps.
deps += [
"//cc",
Expand Down Expand Up @@ -417,6 +419,7 @@ source_set("browser") {
"//ui/aura",
"//ui/aura_extra",
"//ui/strings",
"//ui/views/mus:for_component",
"//ui/wm",
]
} else { # Not aura.
Expand Down
2 changes: 2 additions & 0 deletions content/browser/DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ include_rules = [
# Allow inclusion of specific components that we depend on. We may only
# depend on components which we share with the mojo html_viewer.
"+components/mime_util",
"+components/mus/public/interfaces",
"+components/scheduler/common",
"+components/tracing",
"+components/url_formatter",
Expand All @@ -20,6 +21,7 @@ include_rules = [
"+mojo",
"+sql",
"+ui/aura_extra",
"+ui/views/mus", # http://crbug.com/555767
"+ui/webui",
"+win8/util",

Expand Down
Loading

0 comments on commit 03b7b9d

Please sign in to comment.