Commit b9df819c authored by James Cook's avatar James Cook Committed by Commit Bot

Clean up mash mojo service registration

Ensure that code associated with the UI Service, which is used on both
chromeos and linux-ozone, uses files and functions named *mus*.

Reserve *mash* for chromeos-only code that runs under --mash and uses
the ash window manager.

Bug: 722527
Test: chrome, chrome --mus, and chrome --mash run with target_os="chromeos" and linux-ozone still compiles (I can't run linux-ozone due to xkb issues)
Change-Id: I452e80dffb16d6445f40757d1198ff98233bb528
Reviewed-on: https://chromium-review.googlesource.com/822455
Commit-Queue: James Cook <jamescook@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Reviewed-by: default avatarKen Rockot <rockot@chromium.org>
Cr-Commit-Position: refs/heads/master@{#524010}
parent 89ae89fb
......@@ -2763,6 +2763,8 @@ split_static_library("browser") {
"download/notification/download_notification_manager.h",
"feedback/feedback_util_chromeos.cc",
"feedback/feedback_util_chromeos.h",
"mash_service_registry.cc",
"mash_service_registry.h",
"media/chromeos_login_media_access_handler.cc",
"media/chromeos_login_media_access_handler.h",
"media/public_session_media_access_handler.cc",
......@@ -2814,9 +2816,14 @@ split_static_library("browser") {
]
deps += [
"//ash",
"//ash/public/cpp",
"//chrome/browser/chromeos",
"//components/font_service:lib",
"//components/font_service/public/interfaces",
"//mash/quick_launch/public/interfaces:constants",
"//services/ui/public/cpp/input_devices",
"//services/ui/public/cpp/input_devices:input_device_controller",
"//services/ui/public/interfaces",
"//ui/ozone",
]
public_deps += [
......@@ -4099,28 +4106,6 @@ split_static_library("browser") {
if (use_udev) {
deps += [ "//device/udev_linux" ]
}
if (enable_mus) {
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" ]
}
}
}
if (is_android) {
......
......@@ -271,6 +271,7 @@
#include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/chromeos/system/input_device_settings.h"
#include "chrome/browser/mash_service_registry.h"
#include "chrome/browser/metrics/leak_detector/leak_detector_remote_controller.h"
#include "chrome/browser/ui/browser_dialogs.h"
#include "chrome/browser/ui/browser_finder.h"
......@@ -380,7 +381,6 @@
#endif // BUILDFLAG(ENABLE_EXTENSIONS)
#if BUILDFLAG(ENABLE_MUS)
#include "chrome/browser/mash_service_registry.h"
#include "services/ui/public/interfaces/constants.mojom.h"
#endif
......@@ -1935,10 +1935,6 @@ void ChromeContentBrowserClient::AdjustUtilityServiceProcessCommandLine(
const service_manager::Identity& identity,
base::CommandLine* command_line) {
#if BUILDFLAG(ENABLE_MUS)
if (mash_service_registry::IsMashServiceName(identity.name())) {
command_line->AppendSwitchASCII(switches::kMashServiceName,
identity.name());
}
bool copy_switches = false;
if (identity.name() == ui::mojom::kServiceName) {
command_line->AppendSwitch(switches::kMessageLoopTypeUi);
......@@ -1949,6 +1945,10 @@ void ChromeContentBrowserClient::AdjustUtilityServiceProcessCommandLine(
command_line->AppendSwitch(switches::kMessageLoopTypeUi);
copy_switches = true;
}
if (mash_service_registry::IsMashServiceName(identity.name())) {
command_line->AppendSwitchASCII(switches::kMashServiceName,
identity.name());
}
#endif
// TODO(sky): move to a whitelist, but currently the set of flags is rather
// sprawling.
......@@ -1956,7 +1956,7 @@ void ChromeContentBrowserClient::AdjustUtilityServiceProcessCommandLine(
for (const auto& sw : base::CommandLine::ForCurrentProcess()->GetSwitches())
command_line->AppendSwitchNative(sw.first, sw.second);
}
#endif
#endif // BUILDFLAG(ENABLE_MUS)
}
std::string ChromeContentBrowserClient::GetApplicationLocale() {
......@@ -3282,7 +3282,7 @@ void ChromeContentBrowserClient::RegisterOutOfProcessServices(
(*services)[patch::mojom::kServiceName] =
l10n_util::GetStringUTF16(IDS_UTILITY_PROCESS_PATCH_NAME);
#if BUILDFLAG(ENABLE_MUS)
#if defined(OS_CHROMEOS)
if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kMash))
mash_service_registry::RegisterOutOfProcessServices(services);
#endif
......@@ -3290,7 +3290,7 @@ void ChromeContentBrowserClient::RegisterOutOfProcessServices(
bool ChromeContentBrowserClient::ShouldTerminateOnServiceQuit(
const service_manager::Identity& id) {
#if BUILDFLAG(ENABLE_MUS)
#if defined(OS_CHROMEOS)
return mash_service_registry::ShouldTerminateOnServiceQuit(id.name());
#endif
return false;
......
......@@ -4,20 +4,14 @@
#include "chrome/browser/mash_service_registry.h"
#include "ash/public/interfaces/constants.mojom.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "components/font_service/public/interfaces/constants.mojom.h"
#include "mash/quick_launch/public/interfaces/constants.mojom.h"
#include "mash/quick_launch/quick_launch.h"
#include "services/ui/public/interfaces/constants.mojom.h"
#if defined(OS_CHROMEOS)
#include "ash/public/interfaces/constants.mojom.h" // nogncheck
#endif // defined(OS_CHROMEOS)
#if defined(OS_LINUX) && !defined(OS_ANDROID)
#include "components/font_service/public/interfaces/constants.mojom.h"
#endif // defined(OS_LINUX) && !defined(OS_ANDROID)
namespace mash_service_registry {
namespace {
......@@ -29,14 +23,10 @@ struct Service {
constexpr Service kServices[] = {
{mash::quick_launch::mojom::kServiceName, "Quick Launch"},
{ui::mojom::kServiceName, "UI Service"},
#if defined(OS_CHROMEOS)
{ash::mojom::kServiceName, "Ash Window Manager and Shell"},
{"accessibility_autoclick", "Ash Accessibility Autoclick"},
{"touch_hud", "Ash Touch Hud"},
#endif // defined(OS_CHROMEOS)
#if defined(OS_LINUX) && !defined(OS_ANDROID)
{font_service::mojom::kServiceName, "Font Service"},
#endif // defined(OS_LINUX) && !defined(OS_ANDROID)
};
} // namespace
......@@ -61,13 +51,7 @@ bool ShouldTerminateOnServiceQuit(const std::string& name) {
// Some services going down are treated as catastrophic failures, usually
// because both the browser and the service cache data about each other's
// state that is not rebuilt when the service restarts.
if (name == ui::mojom::kServiceName)
return true;
#if defined(OS_CHROMEOS)
if (name == ash::mojom::kServiceName)
return true;
#endif
return false;
return name == ui::mojom::kServiceName || name == ash::mojom::kServiceName;
}
} // namespace mash_service_registry
......@@ -145,32 +145,22 @@ static_library("utility") {
}
}
if (enable_mus) {
if (is_chromeos) {
sources += [
"mash_service_factory.cc",
"mash_service_factory.h",
]
deps += [
"//mash/quick_launch:lib",
"//mash/quick_launch/public/interfaces",
"//services/ui:lib",
"//services/ui/public/interfaces",
]
if (is_linux) {
deps += [
"//components/font_service:lib",
"//components/font_service/public/interfaces",
]
}
}
if (is_chromeos) {
deps += [
"//ash",
"//ash/autoclick/mus:lib",
"//ash/touch_hud/mus:lib",
"//chrome/services/file_util:lib",
"//components/font_service:lib",
"//components/font_service/public/interfaces",
"//mash/quick_launch:lib",
"//mash/quick_launch/public/interfaces",
"//services/ui:lib",
"//services/ui/public/interfaces",
]
}
......
......@@ -292,8 +292,8 @@ void ChromeContentUtilityClient::RegisterServices(
#endif
#endif // BUILDFLAG(ENABLE_EXTENSIONS)
#if BUILDFLAG(ENABLE_MUS)
RegisterMashServices(services);
#if defined(OS_CHROMEOS)
RegisterOutOfProcessMashServices(services);
#endif
}
......
......@@ -6,25 +6,19 @@
#include <memory>
#include "ash/autoclick/mus/autoclick_application.h"
#include "ash/public/interfaces/constants.mojom.h"
#include "ash/touch_hud/mus/touch_hud_application.h"
#include "ash/window_manager_service.h"
#include "base/bind.h"
#include "build/build_config.h"
#include "components/font_service/font_service_app.h"
#include "components/font_service/public/interfaces/constants.mojom.h"
#include "mash/quick_launch/public/interfaces/constants.mojom.h"
#include "mash/quick_launch/quick_launch.h"
#include "services/ui/public/interfaces/constants.mojom.h"
#include "services/ui/service.h"
#if defined(OS_CHROMEOS)
#include "ash/autoclick/mus/autoclick_application.h" // nogncheck
#include "ash/public/interfaces/constants.mojom.h" // nogncheck
#include "ash/touch_hud/mus/touch_hud_application.h" // nogncheck
#include "ash/window_manager_service.h" // nogncheck
#endif // defined(OS_CHROMEOS)
#if defined(OS_LINUX) && !defined(OS_ANDROID)
#include "components/font_service/font_service_app.h"
#include "components/font_service/public/interfaces/constants.mojom.h"
#endif // defined(OS_LINUX) && !defined(OS_ANDROID)
namespace {
using ServiceFactoryFunction = std::unique_ptr<service_manager::Service>();
......@@ -34,15 +28,16 @@ void RegisterMashService(
const std::string& name,
ServiceFactoryFunction factory_function) {
service_manager::EmbeddedServiceInfo service_info;
service_info.factory = base::Bind(factory_function);
service_info.factory = base::BindRepeating(factory_function);
services->emplace(name, service_info);
}
// NOTE: For --mus the UI service is created at the //chrome/browser layer,
// not in //content. See ServiceManagerContext.
std::unique_ptr<service_manager::Service> CreateUiService() {
return std::make_unique<ui::Service>();
}
#if defined(OS_CHROMEOS)
std::unique_ptr<service_manager::Service> CreateAshService() {
const bool show_primary_host_on_connect = true;
return std::make_unique<ash::WindowManagerService>(
......@@ -60,30 +55,22 @@ std::unique_ptr<service_manager::Service> CreateQuickLaunch() {
std::unique_ptr<service_manager::Service> CreateTouchHud() {
return std::make_unique<ash::touch_hud::TouchHudApplication>();
}
#endif
#if defined(OS_LINUX) && !defined(OS_ANDROID)
std::unique_ptr<service_manager::Service> CreateFontService() {
return std::make_unique<font_service::FontServiceApp>();
}
#endif // defined(OS_LINUX) && !defined(OS_ANDROID)
} // namespace
void RegisterMashServices(
void RegisterOutOfProcessMashServices(
content::ContentUtilityClient::StaticServiceMap* services) {
RegisterMashService(services, ui::mojom::kServiceName, &CreateUiService);
#if defined(OS_CHROMEOS)
RegisterMashService(services, mash::quick_launch::mojom::kServiceName,
&CreateQuickLaunch);
RegisterMashService(services, ash::mojom::kServiceName, &CreateAshService);
RegisterMashService(services, "accessibility_autoclick",
&CreateAccessibilityAutoclick);
RegisterMashService(services, "touch_hud", &CreateTouchHud);
#endif
#if defined(OS_LINUX) && !defined(OS_ANDROID)
RegisterMashService(services, font_service::mojom::kServiceName,
&CreateFontService);
#endif // defined(OS_LINUX) && !defined(OS_ANDROID)
}
......@@ -7,8 +7,8 @@
#include "content/public/utility/content_utility_client.h"
// Registers the services provided by mash.
void RegisterMashServices(
// Registers the out-of-process services for --mash.
void RegisterOutOfProcessMashServices(
content::ContentUtilityClient::StaticServiceMap* services);
#endif // CHROME_UTILITY_MASH_SERVICE_FACTORY_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment