Skip to content

Commit

Permalink
chromeos: changes --mash to run ServiceManager in Chrome process
Browse files Browse the repository at this point in the history
Additionally all services that are launched run using the utility
process.

BUG=763529
TEST=none

Change-Id: I82ca2cef75335de7a85c7c7d3cb7362530a9ad56
Reviewed-on: https://chromium-review.googlesource.com/685979
Commit-Queue: Scott Violet <sky@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Ken Rockot <rockot@chromium.org>
Cr-Commit-Position: refs/heads/master@{#505252}
  • Loading branch information
Scott Violet authored and Commit Bot committed Sep 29, 2017
1 parent ff9d46f commit 776edf8
Show file tree
Hide file tree
Showing 43 changed files with 433 additions and 948 deletions.
1 change: 1 addition & 0 deletions ash/autoclick/mus/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "accessibility_autoclick",
"display_name": "Autoclick",
"sandbox_type": "none",
"interface_provider_specs": {
"service_manager:connector": {
"provides": {
Expand Down
1 change: 1 addition & 0 deletions ash/mus/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "ash",
"display_name": "Ash Window Manager and Shell",
"sandbox_type": "none",
"interface_provider_specs": {
"service_manager:connector": {
"provides": {
Expand Down
1 change: 1 addition & 0 deletions ash/touch_hud/mus/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "touch_hud",
"display_name": "Touch Hud",
"sandbox_type": "none",
"interface_provider_specs": {
"service_manager:connector": {
"provides": { "mash:launchable": [ "mash::mojom::Launchable" ] },
Expand Down
6 changes: 6 additions & 0 deletions chrome/app/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -425,9 +425,15 @@ service_manifest("chrome_content_packaged_services_manifest_overlay") {
source =
"//chrome/browser/chrome_content_packaged_services_manifest_overlay.json"
packaged_services = chrome_packaged_services
if (enable_package_mash_services) {
packaged_services += [ "//mash/quick_launch:manifest" ]
}
if (is_chromeos) {
packaged_services += [
"//ash/autoclick/mus:manifest",
"//ash/mus:manifest",
"//ash/touch_hud/mus:manifest",
"//components/font_service:manifest",
"//services/ui:manifest",
]
}
Expand Down
3 changes: 2 additions & 1 deletion chrome/app/chrome_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ int ChromeMain(int argc, const char** argv) {
#endif // defined(OS_LINUX) || defined(OS_MACOSX) || defined(OS_WIN)

#if defined(OS_CHROMEOS) && BUILDFLAG(ENABLE_PACKAGE_MASH_SERVICES)
if (service_manager::ServiceManagerIsRemote()) {
if (service_manager::ServiceManagerIsRemote() ||
command_line->HasSwitch(switches::kMash)) {
params.create_discardable_memory = false;
params.env_mode = aura::Env::Mode::MUS;
}
Expand Down
98 changes: 6 additions & 92 deletions chrome/app/chrome_main_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -107,19 +107,13 @@
#include "chromeos/chromeos_paths.h"
#include "chromeos/chromeos_switches.h"
#include "chromeos/hugepage_text/hugepage_text.h"
#include "components/metrics/leak_detector/leak_detector.h"
#endif

#if BUILDFLAG(ENABLE_PACKAGE_MASH_SERVICES)
#include "chrome/app/mash/chrome_mash_catalog.h"
#include "chrome/app/mash/embedded_services.h"
#include "mash/common/config.h" // nogncheck
#include "mash/quick_launch/public/interfaces/constants.mojom.h" // nogncheck
#include "services/ui/public/interfaces/constants.mojom.h" // nogncheck

#if defined(OS_CHROMEOS)
#include "chrome/app/mash/chrome_mus_catalog.h"
#endif

#endif // BUILDFLAG(ENABLE_PACKAGE_MASH_SERVICES)

#if defined(OS_ANDROID)
Expand Down Expand Up @@ -151,10 +145,6 @@
#include "components/crash/content/app/crashpad.h"
#endif

#if defined(OS_CHROMEOS)
#include "components/metrics/leak_detector/leak_detector.h"
#endif

#if BUILDFLAG(ENABLE_NACL)
#include "components/nacl/common/nacl_switches.h"
#include "components/nacl/renderer/plugin/ppapi_entrypoints.h"
Expand Down Expand Up @@ -315,6 +305,11 @@ void AdjustLinuxOOMScore(const std::string& process_type) {
// Returns true if this subprocess type needs the ResourceBundle initialized
// and resources loaded.
bool SubprocessNeedsResourceBundle(const std::string& process_type) {
if (process_type == switches::kUtilityProcess &&
base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableServiceProcessResourceLoading)) {
return false;
}
return
#if defined(OS_POSIX) && !defined(OS_MACOSX)
// The zygote process opens the resources for the renderers.
Expand Down Expand Up @@ -1135,53 +1130,9 @@ service_manager::ProcessType ChromeMainDelegate::OverrideProcessType() {
// Don't mess with embedded service command lines.
return service_manager::ProcessType::kDefault;
}

#if BUILDFLAG(ENABLE_PACKAGE_MASH_SERVICES)
if (command_line.HasSwitch(switches::kMash))
return service_manager::ProcessType::kServiceManager;
#endif

return service_manager::ProcessType::kDefault;
}

std::unique_ptr<base::Value> ChromeMainDelegate::CreateServiceCatalog() {
if (!g_service_catalog_factory.Get().is_null())
return g_service_catalog_factory.Get().Run();
#if BUILDFLAG(ENABLE_PACKAGE_MASH_SERVICES)
const auto& command_line = *base::CommandLine::ForCurrentProcess();
#if defined(OS_CHROMEOS)
if (command_line.HasSwitch(switches::kMus))
return CreateChromeMusCatalog();
#endif // defined(OS_CHROMEOS)
if (command_line.HasSwitch(switches::kMash))
return CreateChromeMashCatalog();
#endif // BUILDFLAG(ENABLE_PACKAGE_MASH_SERVICES)
return nullptr;
}

void ChromeMainDelegate::AdjustServiceProcessCommandLine(
const service_manager::Identity& identity,
base::CommandLine* command_line) {
#if BUILDFLAG(ENABLE_PACKAGE_MASH_SERVICES)
// Add kMusConfig so that launched processes know what config they are
// running in.
const bool is_mash = command_line->HasSwitch(switches::kMash);
command_line->AppendSwitchASCII(switches::kMusConfig,
is_mash ? switches::kMash : switches::kMus);

if (identity.name() == content::mojom::kPackagedServicesServiceName) {
// Ensure the browser process doesn't inherit mash or mus flags, since these
// flags would cause the process to run as a Service Manager instead.
base::CommandLine::SwitchMap switches = command_line->GetSwitches();
switches.erase(switches::kMash);
switches.erase(switches::kMus);
*command_line = base::CommandLine(command_line->GetProgram());
for (const auto& sw : switches)
command_line->AppendSwitchNative(sw.first, sw.second);
}
#endif
}

bool ChromeMainDelegate::ShouldTerminateServiceManagerOnInstanceQuit(
const service_manager::Identity& identity,
int* exit_code) {
Expand All @@ -1200,40 +1151,3 @@ bool ChromeMainDelegate::ShouldTerminateServiceManagerOnInstanceQuit(

return false;
}

void ChromeMainDelegate::OnServiceManagerInitialized(
const base::Closure& quit_closure,
service_manager::BackgroundServiceManager* service_manager) {
#if defined(OS_POSIX)
// Quit the main process in response to shutdown signals (like SIGTERM).
// These signals are used by Linux distributions to request clean shutdown.
// On Chrome OS the SIGTERM signal is sent by session_manager.
InstallShutdownSignalHandlers(quit_closure,
base::ThreadTaskRunnerHandle::Get());
#endif

#if BUILDFLAG(ENABLE_PACKAGE_MASH_SERVICES)
// Start services that we know we want to launch on startup (UI service,
// window manager, quick launch app).
service_manager->StartService(
service_manager::Identity(ui::mojom::kServiceName));
service_manager->StartService(
service_manager::Identity(content::mojom::kPackagedServicesServiceName));
if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kMash)) {
service_manager->StartService(
service_manager::Identity(mash::common::GetWindowManagerServiceName()));
service_manager->StartService(
service_manager::Identity(mash::quick_launch::mojom::kServiceName));
}
#endif // BUILDFLAG(ENABLE_PACKAGE_MASH_SERVICES)
}

std::unique_ptr<service_manager::Service>
ChromeMainDelegate::CreateEmbeddedService(const std::string& service_name) {
#if BUILDFLAG(ENABLE_PACKAGE_MASH_SERVICES)
auto mash_service = CreateEmbeddedMashService(service_name);
if (mash_service)
return mash_service;
#endif // BUILDFLAG(ENABLE_PACKAGE_MASH_SERVICES)
return nullptr;
}
9 changes: 0 additions & 9 deletions chrome/app/chrome_main_delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,9 @@ class ChromeMainDelegate : public content::ContentMainDelegate {
#endif
bool ShouldEnableProfilerRecording() override;
service_manager::ProcessType OverrideProcessType() override;
std::unique_ptr<base::Value> CreateServiceCatalog() override;
void AdjustServiceProcessCommandLine(
const service_manager::Identity& identity,
base::CommandLine* command_line) override;
bool ShouldTerminateServiceManagerOnInstanceQuit(
const service_manager::Identity& identity,
int* exit_code) override;
void OnServiceManagerInitialized(
const base::Closure& quit_closure,
service_manager::BackgroundServiceManager* service_manager) override;
std::unique_ptr<service_manager::Service> CreateEmbeddedService(
const std::string& service_name) override;

content::ContentBrowserClient* CreateContentBrowserClient() override;
content::ContentGpuClient* CreateContentGpuClient() override;
Expand Down
14 changes: 7 additions & 7 deletions chrome/app/mash/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,14 @@ import("//services/service_manager/public/service_manifest.gni")

assert(enable_package_mash_services)

source_set("embedded_services") {
sources = [
"embedded_services.cc",
"embedded_services.h",
]

# TODO(sky): clean this and catalog entries up.
group("embedded_services") {
deps = [
":chrome_mash_catalog",
"//base:i18n",
"//chrome/common:constants",
"//components/tracing:startup_tracing",
"//content/public/browser",
"//content/public/common",
"//mash/catalog_viewer:lib",
"//mash/catalog_viewer/public/interfaces:constants",
Expand Down Expand Up @@ -62,7 +59,10 @@ source_set("embedded_services") {
}

if (is_linux && !is_android) {
deps += [ "//components/font_service:lib" ]
deps += [
"//components/font_service:lib",
"//components/font_service/public/interfaces",
]
}
}

Expand Down
1 change: 1 addition & 0 deletions chrome/app/mash/DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ include_rules = [
"+chrome/common/chrome_switches.h",
"+components/font_service",
"+components/tracing",
"+content/public",
"+services/ui",
"+mash",
"+mojo/edk/embedder",
Expand Down
62 changes: 0 additions & 62 deletions chrome/app/mash/embedded_services.cc

This file was deleted.

16 changes: 0 additions & 16 deletions chrome/app/mash/embedded_services.h

This file was deleted.

22 changes: 22 additions & 0 deletions chrome/browser/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -3989,6 +3989,28 @@ split_static_library("browser") {
"password_manager/password_store_signin_notifier_impl.h",
]
}

if (enable_package_mash_services) {
sources += [
"mash_service_registry.cc",
"mash_service_registry.h",
]

deps += [
"//mash/quick_launch/public/interfaces:constants",
"//services/ui/public/interfaces",
]

if (is_linux && !is_android) {
deps += [
"//components/font_service:lib",
"//components/font_service/public/interfaces",
]
}
if (is_chromeos) {
deps += [ "//ash/public/cpp:ash_public_cpp" ]
}
}
}

if (is_android) {
Expand Down
5 changes: 5 additions & 0 deletions chrome/browser/DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ include_rules = [
# Should be removed once the actual network service ships.
"+content/public/network",

"+mash/quick_launch/public/interfaces",

# Other libraries.
"+libxml",
"+third_party/google_toolbox_for_mac/src",
Expand Down Expand Up @@ -179,5 +181,8 @@ specific_include_rules = {
"fullscreen_chromeos\.cc": [
"+ash/root_window_controller.h",
"+ash/shell.h",
],
"mash_service_registry.cc": [
"+mash/quick_launch/quick_launch.h",
]
}
Loading

0 comments on commit 776edf8

Please sign in to comment.