Commit 0d6b1f56 authored by Scott Violet's avatar Scott Violet Committed by Commit Bot

chromeos: have ash always create the UI Service

Currently ash and ui are bundled together by way of process groups. Process
groups make it hard to have an explicit construction ordering. For OopAsh we
need Ash to control creation of the UI Service. This patch removes
progress-groups and instead uses ServiceFactory.

Ash has two distinct ways to provide the 'Ash' service, which necessitates
the change in two places. WindowManagerService will go away soon, and we
will only have one way.

BUG=837686
TEST=covered by tests

Change-Id: Id871fe56331f99fcfb6225f4ebf59378a533600a
Reviewed-on: https://chromium-review.googlesource.com/1098233Reviewed-by: default avatarTom Sepez <tsepez@chromium.org>
Reviewed-by: default avatarJames Cook <jamescook@chromium.org>
Reviewed-by: default avatarKen Rockot <rockot@chromium.org>
Commit-Queue: Scott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#567339}
parent 7ad40f28
...@@ -1358,6 +1358,9 @@ component("ash") { ...@@ -1358,6 +1358,9 @@ component("ash") {
"//services/data_decoder/public/cpp", "//services/data_decoder/public/cpp",
"//services/preferences/public/cpp", "//services/preferences/public/cpp",
"//services/service_manager/public/cpp", "//services/service_manager/public/cpp",
# TODO(sky): this should not be necessary once --mash goes away.
"//services/ui:lib",
"//services/ui/public/interfaces/input_devices", "//services/ui/public/interfaces/input_devices",
# TODO(msw): Remove this; only ash_with_content should depend on webkit. # TODO(msw): Remove this; only ash_with_content should depend on webkit.
...@@ -2343,6 +2346,7 @@ service("ash_service") { ...@@ -2343,6 +2346,7 @@ service("ash_service") {
service_manifest("manifest") { service_manifest("manifest") {
name = "ash" name = "ash"
source = "manifest.json" source = "manifest.json"
packaged_services = [ "//services/ui:manifest" ]
} }
# TODO: Load locale-specific strings. # TODO: Load locale-specific strings.
......
...@@ -140,6 +140,7 @@ specific_include_rules = { ...@@ -140,6 +140,7 @@ specific_include_rules = {
"+ash/host/ash_window_tree_host.h" "+ash/host/ash_window_tree_host.h"
], ],
"window_manager_service.cc": [ "window_manager_service.cc": [
"+chromeos/cryptohome" "+chromeos/cryptohome",
"+services/ui/service.h"
], ],
} }
...@@ -5,8 +5,13 @@ ...@@ -5,8 +5,13 @@
#include "ash/ash_service.h" #include "ash/ash_service.h"
#include "ash/mojo_interface_factory.h" #include "ash/mojo_interface_factory.h"
#include "ash/shell.h"
#include "ash/ws/window_service_owner.h"
#include "base/bind.h"
#include "base/process/process_handle.h"
#include "base/threading/thread_task_runner_handle.h" #include "base/threading/thread_task_runner_handle.h"
#include "services/service_manager/embedder/embedded_service_info.h" #include "services/service_manager/embedder/embedded_service_info.h"
#include "services/ui/public/interfaces/constants.mojom.h"
namespace ash { namespace ash {
namespace { namespace {
...@@ -32,6 +37,8 @@ service_manager::EmbeddedServiceInfo AshService::CreateEmbeddedServiceInfo() { ...@@ -32,6 +37,8 @@ service_manager::EmbeddedServiceInfo AshService::CreateEmbeddedServiceInfo() {
void AshService::OnStart() { void AshService::OnStart() {
mojo_interface_factory::RegisterInterfaces( mojo_interface_factory::RegisterInterfaces(
&registry_, base::ThreadTaskRunnerHandle::Get()); &registry_, base::ThreadTaskRunnerHandle::Get());
registry_.AddInterface(base::BindRepeating(&AshService::BindServiceFactory,
base::Unretained(this)));
} }
void AshService::OnBindInterface( void AshService::OnBindInterface(
...@@ -41,4 +48,18 @@ void AshService::OnBindInterface( ...@@ -41,4 +48,18 @@ void AshService::OnBindInterface(
registry_.BindInterface(interface_name, std::move(handle)); registry_.BindInterface(interface_name, std::move(handle));
} }
void AshService::CreateService(
service_manager::mojom::ServiceRequest service,
const std::string& name,
service_manager::mojom::PIDReceiverPtr pid_receiver) {
DCHECK_EQ(name, ui::mojom::kServiceName);
Shell::Get()->window_service_owner()->BindWindowService(std::move(service));
pid_receiver->SetPID(base::GetCurrentProcId());
}
void AshService::BindServiceFactory(
service_manager::mojom::ServiceFactoryRequest request) {
service_factory_bindings_.AddBinding(this, std::move(request));
}
} // namespace ash } // namespace ash
...@@ -7,8 +7,10 @@ ...@@ -7,8 +7,10 @@
#include "ash/ash_export.h" #include "ash/ash_export.h"
#include "base/macros.h" #include "base/macros.h"
#include "mojo/public/cpp/bindings/binding_set.h"
#include "services/service_manager/public/cpp/binder_registry.h" #include "services/service_manager/public/cpp/binder_registry.h"
#include "services/service_manager/public/cpp/service.h" #include "services/service_manager/public/cpp/service.h"
#include "services/service_manager/public/mojom/service_factory.mojom.h"
namespace service_manager { namespace service_manager {
struct EmbeddedServiceInfo; struct EmbeddedServiceInfo;
...@@ -16,9 +18,13 @@ struct EmbeddedServiceInfo; ...@@ -16,9 +18,13 @@ struct EmbeddedServiceInfo;
namespace ash { namespace ash {
// Used to export Ash's mojo services. Specifically the interfaces defined in // Used to export Ash's mojo services, specifically the interfaces defined in
// Ash's manifest.json. // Ash's manifest.json. Also responsible for creating the
class ASH_EXPORT AshService : public service_manager::Service { // UI-Service/WindowService.
//
// NOTE: this is not used for --mash.
class ASH_EXPORT AshService : public service_manager::Service,
public service_manager::mojom::ServiceFactory {
public: public:
AshService(); AshService();
~AshService() override; ~AshService() override;
...@@ -32,8 +38,19 @@ class ASH_EXPORT AshService : public service_manager::Service { ...@@ -32,8 +38,19 @@ class ASH_EXPORT AshService : public service_manager::Service {
const std::string& interface_name, const std::string& interface_name,
mojo::ScopedMessagePipeHandle handle) override; mojo::ScopedMessagePipeHandle handle) override;
// service_manager::mojom::ServiceFactory:
void CreateService(
service_manager::mojom::ServiceRequest service,
const std::string& name,
service_manager::mojom::PIDReceiverPtr pid_receiver) override;
private: private:
void BindServiceFactory(
service_manager::mojom::ServiceFactoryRequest request);
service_manager::BinderRegistry registry_; service_manager::BinderRegistry registry_;
mojo::BindingSet<service_manager::mojom::ServiceFactory>
service_factory_bindings_;
DISALLOW_COPY_AND_ASSIGN(AshService); DISALLOW_COPY_AND_ASSIGN(AshService);
}; };
......
...@@ -54,7 +54,10 @@ ...@@ -54,7 +54,10 @@
"display": [ "display": [
"ash.mojom.AshDisplayController" "ash.mojom.AshDisplayController"
], ],
"mus:window_manager": [ "ui.mojom.AcceleratorRegistrar" ] "mus:window_manager": [ "ui.mojom.AcceleratorRegistrar" ],
"service_manager:service_factory": [
"service_manager.mojom.ServiceFactory"
]
}, },
"requires": { "requires": {
"*": [ "accessibility", "app" ], "*": [ "accessibility", "app" ],
......
...@@ -19,18 +19,23 @@ grit("resources") { ...@@ -19,18 +19,23 @@ grit("resources") {
] ]
deps = [ deps = [
":ash_content_browser_manifest_overlay",
":ash_content_packaged_services_manifest_overlay", ":ash_content_packaged_services_manifest_overlay",
] ]
} }
service_manifest("ash_content_browser_manifest_overlay") {
source = "//ash/shell/ash_content_browser_manifest_overlay.json"
}
service_manifest("ash_content_packaged_services_manifest_overlay") { service_manifest("ash_content_packaged_services_manifest_overlay") {
source = "//ash/shell/ash_content_packaged_services_manifest_overlay.json" source = "//ash/shell/ash_content_packaged_services_manifest_overlay.json"
packaged_services = [ packaged_services = [
"//ash:manifest",
"//ash/components/quick_launch:manifest", "//ash/components/quick_launch:manifest",
"//ash/components/shortcut_viewer:manifest", "//ash/components/shortcut_viewer:manifest",
"//ash/components/tap_visualizer:manifest", "//ash/components/tap_visualizer:manifest",
"//components/services/font:manifest", "//components/services/font:manifest",
"//services/ui/ime/test_ime_driver:manifest", "//services/ui/ime/test_ime_driver:manifest",
"//services/ui:manifest",
] ]
} }
...@@ -2,3 +2,6 @@ per-file *app_list*=xiyuan@chromium.org ...@@ -2,3 +2,6 @@ per-file *app_list*=xiyuan@chromium.org
per-file ash_content_packaged_services_manifest_overlay.json=set noparent per-file ash_content_packaged_services_manifest_overlay.json=set noparent
per-file ash_content_packaged_services_manifest_overlay.json=file://ipc/SECURITY_OWNERS per-file ash_content_packaged_services_manifest_overlay.json=file://ipc/SECURITY_OWNERS
per-file ash_content_browser_manifest_overlay.json=set noparent
per-file ash_content_browser_manifest_overlay.json=file://ipc/SECURITY_OWNERS
{
"name": "content_browser",
"display_name": "Ash Content Browser",
"interface_provider_specs": {
"service_manager:connector": {
"requires": {
"shortcut_viewer_app": [ "shortcut_viewer" ]
}
}
}
}
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
</outputs> </outputs>
<release seq="1"> <release seq="1">
<includes> <includes>
<include name="IDR_ASH_SHELL_CONTENT_BROWSER_MANIFEST_OVERLAY" file="${root_gen_dir}\ash\shell\ash_content_browser_manifest_overlay.json" type="BINDATA" use_base_dir="false"/>
<include name="IDR_ASH_SHELL_CONTENT_PACKAGED_SERVICES_MANIFEST_OVERLAY" file="${root_gen_dir}\ash\shell\ash_content_packaged_services_manifest_overlay.json" type="BINDATA" use_base_dir="false"/> <include name="IDR_ASH_SHELL_CONTENT_PACKAGED_SERVICES_MANIFEST_OVERLAY" file="${root_gen_dir}\ash\shell\ash_content_packaged_services_manifest_overlay.json" type="BINDATA" use_base_dir="false"/>
<include name="IDR_ASH_SHELL_FONT_SERVICE_MANIFEST" file="../../components/services/font/manifest.json" type="BINDATA" use_base_dir="false" /> <include name="IDR_ASH_SHELL_FONT_SERVICE_MANIFEST" file="../../components/services/font/manifest.json" type="BINDATA" use_base_dir="false" />
<include name="IDR_ASH_SHELL_QUICK_LAUNCH_MANIFEST" file="../../ash/components/quick_launch/manifest.json" type="BINDATA" use_base_dir="false" /> <include name="IDR_ASH_SHELL_QUICK_LAUNCH_MANIFEST" file="../../ash/components/quick_launch/manifest.json" type="BINDATA" use_base_dir="false" />
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "base/threading/thread.h" #include "base/threading/thread.h"
#include "base/threading/thread_restrictions.h" #include "base/threading/thread_restrictions.h"
#include "base/time/time.h"
#include "chromeos/audio/cras_audio_handler.h" #include "chromeos/audio/cras_audio_handler.h"
#include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/power_policy_controller.h" #include "chromeos/dbus/power_policy_controller.h"
...@@ -126,9 +127,11 @@ void ShellBrowserMainParts::PreMainMessageLoopRun() { ...@@ -126,9 +127,11 @@ void ShellBrowserMainParts::PreMainMessageLoopRun() {
->GetConnector() ->GetConnector()
->StartService(tap_visualizer::mojom::kServiceName); ->StartService(tap_visualizer::mojom::kServiceName);
} }
shortcut_viewer::mojom::ShortcutViewerPtr shortcut_viewer;
content::ServiceManagerConnection::GetForProcess() content::ServiceManagerConnection::GetForProcess()
->GetConnector() ->GetConnector()
->StartService(shortcut_viewer::mojom::kServiceName); ->BindInterface(shortcut_viewer::mojom::kServiceName, &shortcut_viewer);
shortcut_viewer->Toggle(base::TimeTicks::Now());
ash::Shell::Get()->InitWaylandServer(nullptr); ash::Shell::Get()->InitWaylandServer(nullptr);
} }
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
#include "ash/shell.h" #include "ash/shell.h"
#include "ash/shell/content/client/shell_browser_main_parts.h" #include "ash/shell/content/client/shell_browser_main_parts.h"
#include "ash/shell/grit/ash_shell_resources.h" #include "ash/shell/grit/ash_shell_resources.h"
#include "ash/ws/window_service_owner.h"
#include "base/base_switches.h" #include "base/base_switches.h"
#include "base/bind.h" #include "base/bind.h"
#include "base/command_line.h" #include "base/command_line.h"
...@@ -59,14 +58,23 @@ void ShellContentBrowserClient::GetQuotaSettings( ...@@ -59,14 +58,23 @@ void ShellContentBrowserClient::GetQuotaSettings(
std::unique_ptr<base::Value> std::unique_ptr<base::Value>
ShellContentBrowserClient::GetServiceManifestOverlay(base::StringPiece name) { ShellContentBrowserClient::GetServiceManifestOverlay(base::StringPiece name) {
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); if (name == content::mojom::kBrowserServiceName) {
if (name != content::mojom::kPackagedServicesServiceName) // This is necessary for outgoing interface requests (such as the keyboard
return nullptr; // shortcut viewer).
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
base::StringPiece manifest_contents = rb.GetRawDataResourceForScale( base::StringPiece manifest_contents = rb.GetRawDataResourceForScale(
IDR_ASH_SHELL_CONTENT_PACKAGED_SERVICES_MANIFEST_OVERLAY, IDR_ASH_SHELL_CONTENT_BROWSER_MANIFEST_OVERLAY,
ui::ScaleFactor::SCALE_FACTOR_NONE); ui::ScaleFactor::SCALE_FACTOR_NONE);
return base::JSONReader::Read(manifest_contents); return base::JSONReader::Read(manifest_contents);
}
if (name == content::mojom::kPackagedServicesServiceName) {
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
base::StringPiece manifest_contents = rb.GetRawDataResourceForScale(
IDR_ASH_SHELL_CONTENT_PACKAGED_SERVICES_MANIFEST_OVERLAY,
ui::ScaleFactor::SCALE_FACTOR_NONE);
return base::JSONReader::Read(manifest_contents);
}
return nullptr;
} }
std::vector<content::ContentBrowserClient::ServiceManifestInfo> std::vector<content::ContentBrowserClient::ServiceManifestInfo>
...@@ -102,11 +110,6 @@ void ShellContentBrowserClient::RegisterInProcessServices( ...@@ -102,11 +110,6 @@ void ShellContentBrowserClient::RegisterInProcessServices(
content::ServiceManagerConnection* connection) { content::ServiceManagerConnection* connection) {
services->insert(std::make_pair(mojom::kServiceName, services->insert(std::make_pair(mojom::kServiceName,
AshService::CreateEmbeddedServiceInfo())); AshService::CreateEmbeddedServiceInfo()));
connection->AddServiceRequestHandler(
ui::mojom::kServiceName,
base::BindRepeating(&BindWindowServiceOnIoThread,
base::ThreadTaskRunnerHandle::Get()));
} }
} // namespace shell } // namespace shell
......
...@@ -13,6 +13,8 @@ ...@@ -13,6 +13,8 @@
#include "ash/system/power/power_status.h" #include "ash/system/power/power_status.h"
#include "ash/window_manager.h" #include "ash/window_manager.h"
#include "base/bind.h" #include "base/bind.h"
#include "base/process/process_handle.h"
#include "base/threading/thread.h"
#include "base/threading/thread_task_runner_handle.h" #include "base/threading/thread_task_runner_handle.h"
#include "chromeos/audio/cras_audio_handler.h" #include "chromeos/audio/cras_audio_handler.h"
#include "chromeos/cryptohome/system_salt_getter.h" #include "chromeos/cryptohome/system_salt_getter.h"
...@@ -26,6 +28,9 @@ ...@@ -26,6 +28,9 @@
#include "services/service_manager/public/cpp/connector.h" #include "services/service_manager/public/cpp/connector.h"
#include "services/service_manager/public/cpp/service_context.h" #include "services/service_manager/public/cpp/service_context.h"
#include "services/ui/common/accelerator_util.h" #include "services/ui/common/accelerator_util.h"
#include "services/ui/common/image_cursors_set.h"
#include "services/ui/public/interfaces/constants.mojom.h"
#include "services/ui/service.h"
#include "ui/aura/env.h" #include "ui/aura/env.h"
#include "ui/aura/mus/window_tree_client.h" #include "ui/aura/mus/window_tree_client.h"
#include "ui/events/event.h" #include "ui/events/event.h"
...@@ -34,20 +39,29 @@ ...@@ -34,20 +39,29 @@
namespace ash { namespace ash {
WindowManagerService::WindowManagerService(bool show_primary_host_on_connect) WindowManagerService::WindowManagerService(bool show_primary_host_on_connect)
: show_primary_host_on_connect_(show_primary_host_on_connect) {} : show_primary_host_on_connect_(show_primary_host_on_connect),
image_cursors_set_(std::make_unique<ui::ImageCursorsSet>()) {}
WindowManagerService::~WindowManagerService() { WindowManagerService::~WindowManagerService() {
// Verify that we created a WindowManager before attempting to tear everything // Verify that we created a WindowManager before attempting to tear everything
// down. In some fast running tests OnStart may never have been called. // down. In some fast running tests OnStart() may never have been called.
if (!window_manager_.get()) if (window_manager_) {
return; // Destroy the WindowManager while still valid. This way we ensure
// OnWillDestroyRootWindowController() is called (if it hasn't been
// Destroy the WindowManager while still valid. This way we ensure // already).
// OnWillDestroyRootWindowController() is called (if it hasn't been already). window_manager_.reset();
window_manager_.reset();
statistics_provider_.reset();
statistics_provider_.reset(); ShutdownComponents();
ShutdownComponents(); }
if (ui_thread_) {
ui_thread_->task_runner()->PostTask(
FROM_HERE,
base::BindOnce(
&WindowManagerService::DestroyUiServiceOnBackgroundThread,
base::Unretained(this)));
}
ui_thread_.reset();
} }
service_manager::Connector* WindowManagerService::GetConnector() { service_manager::Connector* WindowManagerService::GetConnector() {
...@@ -116,10 +130,55 @@ void WindowManagerService::ShutdownComponents() { ...@@ -116,10 +130,55 @@ void WindowManagerService::ShutdownComponents() {
chromeos::DBusThreadManager::Shutdown(); chromeos::DBusThreadManager::Shutdown();
} }
void WindowManagerService::BindServiceFactory(
service_manager::mojom::ServiceFactoryRequest request) {
service_factory_bindings_.AddBinding(this, std::move(request));
}
void WindowManagerService::CreateUiServiceOnBackgroundThread(
scoped_refptr<base::SingleThreadTaskRunner> resource_runner,
service_manager::mojom::ServiceRequest service_request) {
ui::Service::InitParams params;
params.running_standalone = false;
params.resource_runner = resource_runner;
params.image_cursors_set_weak_ptr = image_cursors_set_->GetWeakPtr();
params.should_host_viz = true;
std::unique_ptr<ui::Service> service = std::make_unique<ui::Service>(params);
ui_service_context_ = std::make_unique<service_manager::ServiceContext>(
std::move(service), std::move(service_request));
}
void WindowManagerService::DestroyUiServiceOnBackgroundThread() {
ui_service_context_.reset();
}
void WindowManagerService::CreateService(
service_manager::mojom::ServiceRequest service_request,
const std::string& name,
service_manager::mojom::PIDReceiverPtr pid_receiver) {
DCHECK_EQ(name, ui::mojom::kServiceName);
ui_thread_ = std::make_unique<base::Thread>("UI Service");
// The image cursors must be set by the time this is called.
base::Thread::Options options;
options.message_loop_type = base::MessageLoop::TYPE_UI;
options.priority = base::ThreadPriority::DISPLAY;
ui_thread_->StartWithOptions(options);
ui_thread_->task_runner()->PostTask(
FROM_HERE,
base::BindOnce(&WindowManagerService::CreateUiServiceOnBackgroundThread,
base::Unretained(this),
base::ThreadTaskRunnerHandle::Get(),
std::move(service_request)));
pid_receiver->SetPID(base::GetCurrentProcId());
}
void WindowManagerService::OnStart() { void WindowManagerService::OnStart() {
mojo_interface_factory::RegisterInterfaces( mojo_interface_factory::RegisterInterfaces(
&registry_, base::ThreadTaskRunnerHandle::Get()); &registry_, base::ThreadTaskRunnerHandle::Get());
registry_.AddInterface(base::BindRepeating(
&WindowManagerService::BindServiceFactory, base::Unretained(this)));
const bool register_path_provider = running_standalone_; const bool register_path_provider = running_standalone_;
aura_init_ = views::AuraInit::Create( aura_init_ = views::AuraInit::Create(
context()->connector(), context()->identity(), context()->connector(), context()->identity(),
......
...@@ -14,14 +14,20 @@ ...@@ -14,14 +14,20 @@
#include "ash/ash_export.h" #include "ash/ash_export.h"
#include "base/macros.h" #include "base/macros.h"
#include "mojo/public/cpp/bindings/binding.h" #include "mojo/public/cpp/bindings/binding.h"
#include "mojo/public/cpp/bindings/binding_set.h"
#include "services/service_manager/public/cpp/binder_registry.h" #include "services/service_manager/public/cpp/binder_registry.h"
#include "services/service_manager/public/cpp/service.h" #include "services/service_manager/public/cpp/service.h"
#include "services/service_manager/public/mojom/service_factory.mojom.h"
#include "services/ui/common/types.h" #include "services/ui/common/types.h"
namespace aura { namespace aura {
class WindowTreeClient; class WindowTreeClient;
} }
namespace base {
class Thread;
}
namespace chromeos { namespace chromeos {
namespace system { namespace system {
class ScopedFakeStatisticsProvider; class ScopedFakeStatisticsProvider;
...@@ -36,13 +42,20 @@ namespace views { ...@@ -36,13 +42,20 @@ namespace views {
class AuraInit; class AuraInit;
} }
namespace ui {
class ImageCursorsSet;
}
namespace ash { namespace ash {
class AshTestHelper; class AshTestHelper;
class NetworkConnectDelegateMus; class NetworkConnectDelegateMus;
class WindowManager; class WindowManager;
// Hosts the window manager and the ash system user interface for mash. // Hosts the window manager and the ash system user interface for mash. This is
class ASH_EXPORT WindowManagerService : public service_manager::Service { // also responsible for creating the UI Service. This is only used for --mash.
class ASH_EXPORT WindowManagerService
: public service_manager::Service,
public service_manager::mojom::ServiceFactory {
public: public:
// See WindowManager's constructor for details of // See WindowManager's constructor for details of
// |show_primary_host_on_connect|. // |show_primary_host_on_connect|.
...@@ -67,6 +80,20 @@ class ASH_EXPORT WindowManagerService : public service_manager::Service { ...@@ -67,6 +80,20 @@ class ASH_EXPORT WindowManagerService : public service_manager::Service {
void InitializeComponents(bool init_network_handler); void InitializeComponents(bool init_network_handler);
void ShutdownComponents(); void ShutdownComponents();
void BindServiceFactory(
service_manager::mojom::ServiceFactoryRequest request);
void CreateUiServiceOnBackgroundThread(
scoped_refptr<base::SingleThreadTaskRunner> resource_runner,
service_manager::mojom::ServiceRequest service_request);
void DestroyUiServiceOnBackgroundThread();
// service_manager::mojom::ServiceFactory:
void CreateService(
service_manager::mojom::ServiceRequest service_request,
const std::string& name,
service_manager::mojom::PIDReceiverPtr pid_receiver) override;
// service_manager::Service: // service_manager::Service:
void OnStart() override; void OnStart() override;
void OnBindInterface(const service_manager::BindSourceInfo& source_info, void OnBindInterface(const service_manager::BindSourceInfo& source_info,
...@@ -84,6 +111,9 @@ class ASH_EXPORT WindowManagerService : public service_manager::Service { ...@@ -84,6 +111,9 @@ class ASH_EXPORT WindowManagerService : public service_manager::Service {
std::unique_ptr<chromeos::system::ScopedFakeStatisticsProvider> std::unique_ptr<chromeos::system::ScopedFakeStatisticsProvider>
statistics_provider_; statistics_provider_;
mojo::BindingSet<service_manager::mojom::ServiceFactory>
service_factory_bindings_;
service_manager::BinderRegistry registry_; service_manager::BinderRegistry registry_;
// Whether this class initialized NetworkHandler and needs to clean it up. // Whether this class initialized NetworkHandler and needs to clean it up.
...@@ -92,6 +122,15 @@ class ASH_EXPORT WindowManagerService : public service_manager::Service { ...@@ -92,6 +122,15 @@ class ASH_EXPORT WindowManagerService : public service_manager::Service {
// Whether this class initialized DBusThreadManager and needs to clean it up. // Whether this class initialized DBusThreadManager and needs to clean it up.
bool dbus_thread_manager_initialized_ = false; bool dbus_thread_manager_initialized_ = false;
// Thread the UI Service runs on.
std::unique_ptr<base::Thread> ui_thread_;
// The ServiceContext created for the UI service. This is created (and
// shutdown) on |ui_thread_|.
std::unique_ptr<service_manager::ServiceContext> ui_service_context_;
std::unique_ptr<ui::ImageCursorsSet> image_cursors_set_;
DISALLOW_COPY_AND_ASSIGN(WindowManagerService); DISALLOW_COPY_AND_ASSIGN(WindowManagerService);
}; };
......
...@@ -14,14 +14,6 @@ ...@@ -14,14 +14,6 @@
#include "ui/wm/core/focus_controller.h" #include "ui/wm/core/focus_controller.h"
namespace ash { namespace ash {
namespace {
void BindWindowServiceOnMainThread(
service_manager::mojom::ServiceRequest request) {
Shell::Get()->window_service_owner()->BindWindowService(std::move(request));
}
} // namespace
WindowServiceOwner::WindowServiceOwner( WindowServiceOwner::WindowServiceOwner(
std::unique_ptr<ui::ws2::GpuSupport> gpu_support) std::unique_ptr<ui::ws2::GpuSupport> gpu_support)
...@@ -50,12 +42,4 @@ void WindowServiceOwner::BindWindowService( ...@@ -50,12 +42,4 @@ void WindowServiceOwner::BindWindowService(
std::move(window_service), std::move(request)); std::move(window_service), std::move(request));
} }
void BindWindowServiceOnIoThread(
scoped_refptr<base::SingleThreadTaskRunner> main_runner,
service_manager::mojom::ServiceRequest request) {
main_runner->PostTask(
FROM_HERE,
base::BindOnce(&BindWindowServiceOnMainThread, std::move(request)));
}
} // namespace ash } // namespace ash
...@@ -12,10 +12,6 @@ ...@@ -12,10 +12,6 @@
#include "base/memory/scoped_refptr.h" #include "base/memory/scoped_refptr.h"
#include "services/service_manager/public/mojom/service.mojom.h" #include "services/service_manager/public/mojom/service.mojom.h"
namespace base {
class SingleThreadTaskRunner;
}
namespace service_manager { namespace service_manager {
class ServiceContext; class ServiceContext;
} }
...@@ -66,13 +62,6 @@ class ASH_EXPORT WindowServiceOwner { ...@@ -66,13 +62,6 @@ class ASH_EXPORT WindowServiceOwner {
DISALLOW_COPY_AND_ASSIGN(WindowServiceOwner); DISALLOW_COPY_AND_ASSIGN(WindowServiceOwner);
}; };
// This function should be bound to a ServiceManagerConnection. The
// ServiceManager executes this on a background thread, so this posts a task
// to |main_runner| that calls BindWindowService().
ASH_EXPORT void BindWindowServiceOnIoThread(
scoped_refptr<base::SingleThreadTaskRunner> main_runner,
service_manager::mojom::ServiceRequest request);
} // namespace ash } // namespace ash
#endif // ASH_WS_WINDOW_SERVICE_OWNER_H_ #endif // ASH_WS_WINDOW_SERVICE_OWNER_H_
...@@ -214,8 +214,6 @@ specific_include_rules = { ...@@ -214,8 +214,6 @@ specific_include_rules = {
# Once Ash runs out of process no longer needed. # Once Ash runs out of process no longer needed.
"+ash/shell.h", "+ash/shell.h",
"+ash/strings/grit/ash_strings.h", "+ash/strings/grit/ash_strings.h",
"+ash/ws/window_service_owner.h",
"+services/ui/ws2/window_service.h",
# Needed for classic mode. # Needed for classic mode.
"+ash/ash_service.h", "+ash/ash_service.h",
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
#include "ash/public/interfaces/window_properties.mojom.h" #include "ash/public/interfaces/window_properties.mojom.h"
#include "ash/shell.h" #include "ash/shell.h"
#include "ash/strings/grit/ash_strings.h" #include "ash/strings/grit/ash_strings.h"
#include "ash/ws/window_service_owner.h"
#include "base/stl_util.h" #include "base/stl_util.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/threading/thread_task_runner_handle.h" #include "base/threading/thread_task_runner_handle.h"
...@@ -32,8 +31,7 @@ namespace { ...@@ -32,8 +31,7 @@ namespace {
struct Service { struct Service {
const char* name; const char* name;
int display_name_id; // Resource ID for the display name. int display_name_id; // Resource ID for the display name.
const char* process_group = nullptr; // If null, uses a separate process.
}; };
// Services shared between mash and non-mash configs. // Services shared between mash and non-mash configs.
...@@ -48,8 +46,8 @@ constexpr Service kCommonServices[] = { ...@@ -48,8 +46,8 @@ constexpr Service kCommonServices[] = {
// Services unique to mash. Note that the non-mash case also has an Ash service, // Services unique to mash. Note that the non-mash case also has an Ash service,
// it's just registered differently (see RegisterInProcessServices()). // it's just registered differently (see RegisterInProcessServices()).
constexpr Service kMashServices[] = { constexpr Service kMashServices[] = {
{ash::mojom::kServiceName, IDS_ASH_ASH_SERVICE_NAME, kAshAndUiProcessGroup}, {ash::mojom::kServiceName, IDS_ASH_ASH_SERVICE_NAME},
{ui::mojom::kServiceName, IDS_ASH_UI_SERVICE_NAME, kAshAndUiProcessGroup}, {ui::mojom::kServiceName, IDS_ASH_UI_SERVICE_NAME},
}; };
void RegisterOutOfProcessServicesImpl( void RegisterOutOfProcessServicesImpl(
...@@ -60,14 +58,8 @@ void RegisterOutOfProcessServicesImpl( ...@@ -60,14 +58,8 @@ void RegisterOutOfProcessServicesImpl(
const Service& service = services[i]; const Service& service = services[i];
base::string16 display_name = base::string16 display_name =
l10n_util::GetStringUTF16(service.display_name_id); l10n_util::GetStringUTF16(service.display_name_id);
if (service.process_group) { (*services_map)[service.name] =
(*services_map)[service.name] = ContentBrowserClient::OutOfProcessServiceInfo(display_name);
ContentBrowserClient::OutOfProcessServiceInfo(display_name,
service.process_group);
} else {
(*services_map)[service.name] =
ContentBrowserClient::OutOfProcessServiceInfo(display_name);
}
} }
} }
...@@ -104,11 +96,6 @@ void RegisterInProcessServices( ...@@ -104,11 +96,6 @@ void RegisterInProcessServices(
(*services)[ash::mojom::kServiceName] = (*services)[ash::mojom::kServiceName] =
ash::AshService::CreateEmbeddedServiceInfo(); ash::AshService::CreateEmbeddedServiceInfo();
connection->AddServiceRequestHandler(
ui::mojom::kServiceName,
base::BindRepeating(&ash::BindWindowServiceOnIoThread,
base::ThreadTaskRunnerHandle::Get()));
} }
bool IsAshRelatedServiceName(const std::string& name) { bool IsAshRelatedServiceName(const std::string& name) {
...@@ -123,24 +110,6 @@ bool IsAshRelatedServiceName(const std::string& name) { ...@@ -123,24 +110,6 @@ bool IsAshRelatedServiceName(const std::string& name) {
return false; return false;
} }
std::string GetAshRelatedServiceLabel(const std::string& service_name) {
for (const Service& service : kMashServices) {
if (service_name == service.name) {
// Use the process group name when available because that makes it more
// obvious that multiple services are running in the same process.
return service.process_group ? service.process_group : service.name;
}
}
for (const Service& service : kCommonServices) {
if (service_name == service.name) {
// Use the process group name when available because that makes it more
// obvious that multiple services are running in the same process.
return service.process_group ? service.process_group : service.name;
}
}
return std::string();
}
bool ShouldTerminateOnServiceQuit(const std::string& name) { bool ShouldTerminateOnServiceQuit(const std::string& name) {
// Some services going down are treated as catastrophic failures, usually // Some services going down are treated as catastrophic failures, usually
// because both the browser and the service cache data about each other's // because both the browser and the service cache data about each other's
......
...@@ -11,9 +11,6 @@ ...@@ -11,9 +11,6 @@
namespace ash_service_registry { namespace ash_service_registry {
// Process group used for the ash service and the ui service. Visible for test.
constexpr char kAshAndUiProcessGroup[] = "ash_and_ui";
// Registers the set of Ash related services that run out of process. // Registers the set of Ash related services that run out of process.
void RegisterOutOfProcessServices( void RegisterOutOfProcessServices(
content::ContentBrowserClient::OutOfProcessServiceMap* services); content::ContentBrowserClient::OutOfProcessServiceMap* services);
...@@ -26,11 +23,6 @@ void RegisterInProcessServices( ...@@ -26,11 +23,6 @@ void RegisterInProcessServices(
// Returns true if |name| identifies an Ash related service. // Returns true if |name| identifies an Ash related service.
bool IsAshRelatedServiceName(const std::string& name); bool IsAshRelatedServiceName(const std::string& name);
// If |service_name| identifies an Ash related service, returns an arbitrary
// label that identifies the service or group of related services. Otherwise
// returns the empty string.
std::string GetAshRelatedServiceLabel(const std::string& service_name);
// Returns true if the browser should exit when service |name| quits. // Returns true if the browser should exit when service |name| quits.
bool ShouldTerminateOnServiceQuit(const std::string& name); bool ShouldTerminateOnServiceQuit(const std::string& name);
......
// Copyright 2017 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 "chrome/browser/ash_service_registry.h"
#include "base/bind.h"
#include "base/run_loop.h"
#include "chrome/browser/chromeos/ash_config.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/test/browser_test_utils.h"
namespace {
void VerifyProcessGroupOnIOThread() {
EXPECT_TRUE(content::HasValidProcessForProcessGroup(
ash_service_registry::kAshAndUiProcessGroup));
}
} // namespace
using AshServiceRegistryTest = InProcessBrowserTest;
IN_PROC_BROWSER_TEST_F(AshServiceRegistryTest, AshAndUiInSameProcess) {
// Test only applies to mash (out-of-process ash).
if (chromeos::GetAshConfig() != ash::Config::MASH)
return;
// Process group information is owned by the IO thread.
base::RunLoop run_loop;
content::BrowserThread::PostTaskAndReply(
content::BrowserThread::IO, FROM_HERE,
base::BindOnce(&VerifyProcessGroupOnIOThread), run_loop.QuitClosure());
run_loop.Run();
}
// Copyright 2017 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 "chrome/browser/ash_service_registry.h"
#include "ash/public/interfaces/constants.mojom.h"
#include "base/stl_util.h"
#include "base/test/scoped_feature_list.h"
#include "content/public/browser/content_browser_client.h"
#include "services/ui/public/interfaces/constants.mojom.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/ui_base_features.h"
TEST(AshServiceRegistryTest, AshAndUiInSameProcess) {
base::test::ScopedFeatureList scoped_feature_list;
scoped_feature_list.InitAndEnableFeature(features::kMash);
content::ContentBrowserClient::OutOfProcessServiceMap services;
ash_service_registry::RegisterOutOfProcessServices(&services);
// The ash service and ui service should be in the same process group.
ASSERT_TRUE(base::ContainsKey(services, ash::mojom::kServiceName));
ASSERT_TRUE(base::ContainsKey(services, ui::mojom::kServiceName));
std::string ash_process_group =
*services[ash::mojom::kServiceName].process_group;
std::string ui_process_group =
*services[ui::mojom::kServiceName].process_group;
EXPECT_FALSE(ash_process_group.empty());
EXPECT_FALSE(ui_process_group.empty());
EXPECT_EQ(ash_process_group, ui_process_group);
}
...@@ -2086,9 +2086,8 @@ void ChromeContentBrowserClient::AdjustUtilityServiceProcessCommandLine( ...@@ -2086,9 +2086,8 @@ void ChromeContentBrowserClient::AdjustUtilityServiceProcessCommandLine(
copy_switches = true; copy_switches = true;
} }
if (ash_service_registry::IsAshRelatedServiceName(identity.name())) { if (ash_service_registry::IsAshRelatedServiceName(identity.name())) {
command_line->AppendSwitchASCII( command_line->AppendSwitchASCII(switches::kMashServiceName,
switches::kMashServiceName, identity.name());
ash_service_registry::GetAshRelatedServiceLabel(identity.name()));
} }
#endif #endif
// TODO(sky): move to a whitelist, but currently the set of flags is rather // TODO(sky): move to a whitelist, but currently the set of flags is rather
......
...@@ -1519,7 +1519,6 @@ test("browser_tests") { ...@@ -1519,7 +1519,6 @@ test("browser_tests") {
if (is_chromeos) { if (is_chromeos) {
assert(enable_app_list) assert(enable_app_list)
sources += [ sources += [
"../browser/ash_service_registry_browsertest.cc",
"../browser/chromeos/accessibility/accessibility_manager_browsertest.cc", "../browser/chromeos/accessibility/accessibility_manager_browsertest.cc",
"../browser/chromeos/accessibility/magnification_manager_browsertest.cc", "../browser/chromeos/accessibility/magnification_manager_browsertest.cc",
"../browser/chromeos/accessibility/speech_monitor.cc", "../browser/chromeos/accessibility/speech_monitor.cc",
...@@ -3268,7 +3267,6 @@ test("unit_tests") { ...@@ -3268,7 +3267,6 @@ test("unit_tests") {
"../browser/ui/window_sizer/window_sizer_unittest.cc", "../browser/ui/window_sizer/window_sizer_unittest.cc",
] ]
sources += [ sources += [
"../browser/ash_service_registry_unittest.cc",
"../browser/chromeos/crostini/crostini_registry_service_unittest.cc", "../browser/chromeos/crostini/crostini_registry_service_unittest.cc",
"../browser/chromeos/policy/policy_cert_verifier_unittest.cc", "../browser/chromeos/policy/policy_cert_verifier_unittest.cc",
"../browser/component_updater/cros_component_installer_chromeos_unittest.cc", "../browser/component_updater/cros_component_installer_chromeos_unittest.cc",
......
...@@ -21,9 +21,6 @@ ...@@ -21,9 +21,6 @@
#include "build/build_config.h" #include "build/build_config.h"
#include "components/services/font/font_service_app.h" #include "components/services/font/font_service_app.h"
#include "components/services/font/public/interfaces/constants.mojom.h" #include "components/services/font/public/interfaces/constants.mojom.h"
#include "services/ui/common/image_cursors_set.h"
#include "services/ui/public/interfaces/constants.mojom.h"
#include "services/ui/service.h"
namespace { namespace {
...@@ -50,34 +47,6 @@ void RegisterMashService( ...@@ -50,34 +47,6 @@ void RegisterMashService(
services->emplace(name, service_info); services->emplace(name, service_info);
} }
// Runs on the UI service main thread.
// 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(
const scoped_refptr<base::SingleThreadTaskRunner>& resource_runner,
base::WeakPtr<ui::ImageCursorsSet> image_cursors_set_weak_ptr) {
ui::Service::InitParams params;
params.running_standalone = false;
params.resource_runner = resource_runner;
params.image_cursors_set_weak_ptr = image_cursors_set_weak_ptr;
params.should_host_viz = true;
return std::make_unique<ui::Service>(params);
}
// Runs on the utility process main thread.
void RegisterUiService(
content::ContentUtilityClient::StaticServiceMap* services,
ui::ImageCursorsSet* cursors) {
service_manager::EmbeddedServiceInfo service_info;
service_info.use_own_thread = true;
service_info.message_loop_type = base::MessageLoop::TYPE_UI;
service_info.thread_priority = base::ThreadPriority::DISPLAY;
service_info.factory =
base::BindRepeating(&CreateUiService, base::ThreadTaskRunnerHandle::Get(),
cursors->GetWeakPtr());
services->emplace(ui::mojom::kServiceName, service_info);
}
// Wrapper function so we only have one copy of histogram macro generated code. // Wrapper function so we only have one copy of histogram macro generated code.
void RecordMashServiceLaunch(MashService service) { void RecordMashServiceLaunch(MashService service) {
UMA_HISTOGRAM_ENUMERATION("Launch.MashService", service); UMA_HISTOGRAM_ENUMERATION("Launch.MashService", service);
...@@ -118,14 +87,12 @@ std::unique_ptr<service_manager::Service> CreateFontService() { ...@@ -118,14 +87,12 @@ std::unique_ptr<service_manager::Service> CreateFontService() {
} // namespace } // namespace
MashServiceFactory::MashServiceFactory() MashServiceFactory::MashServiceFactory() = default;
: cursors_(std::make_unique<ui::ImageCursorsSet>()) {}
MashServiceFactory::~MashServiceFactory() = default; MashServiceFactory::~MashServiceFactory() = default;
void MashServiceFactory::RegisterOutOfProcessServices( void MashServiceFactory::RegisterOutOfProcessServices(
content::ContentUtilityClient::StaticServiceMap* services) { content::ContentUtilityClient::StaticServiceMap* services) {
RegisterUiService(services, cursors_.get());
RegisterMashService(services, quick_launch::mojom::kServiceName, RegisterMashService(services, quick_launch::mojom::kServiceName,
&CreateQuickLaunchApp); &CreateQuickLaunchApp);
RegisterMashService(services, ash::mojom::kServiceName, &CreateAshService); RegisterMashService(services, ash::mojom::kServiceName, &CreateAshService);
......
...@@ -5,14 +5,8 @@ ...@@ -5,14 +5,8 @@
#ifndef CHROME_UTILITY_MASH_SERVICE_FACTORY_H_ #ifndef CHROME_UTILITY_MASH_SERVICE_FACTORY_H_
#define CHROME_UTILITY_MASH_SERVICE_FACTORY_H_ #define CHROME_UTILITY_MASH_SERVICE_FACTORY_H_
#include <memory>
#include "content/public/utility/content_utility_client.h" #include "content/public/utility/content_utility_client.h"
namespace ui {
class ImageCursorsSet;
}
// Lives on the utility process main thread. // Lives on the utility process main thread.
class MashServiceFactory { class MashServiceFactory {
public: public:
...@@ -24,9 +18,6 @@ class MashServiceFactory { ...@@ -24,9 +18,6 @@ class MashServiceFactory {
content::ContentUtilityClient::StaticServiceMap* services); content::ContentUtilityClient::StaticServiceMap* services);
private: private:
// Must live on the utility main thread.
std::unique_ptr<ui::ImageCursorsSet> cursors_;
DISALLOW_COPY_AND_ASSIGN(MashServiceFactory); DISALLOW_COPY_AND_ASSIGN(MashServiceFactory);
}; };
......
...@@ -197,10 +197,6 @@ service_manifest("packaged_services_manifest") { ...@@ -197,10 +197,6 @@ service_manifest("packaged_services_manifest") {
"//services/video_capture:manifest", "//services/video_capture:manifest",
"//services/viz:manifest", "//services/viz:manifest",
] ]
if (enable_mus) {
packaged_services += [ "//services/ui:manifest" ]
}
} }
service_manifest("browser_manifest") { service_manifest("browser_manifest") {
......
...@@ -43,7 +43,6 @@ catalog("catalog") { ...@@ -43,7 +43,6 @@ catalog("catalog") {
"//mash/catalog_viewer:manifest", "//mash/catalog_viewer:manifest",
"//mash/session:manifest", "//mash/session:manifest",
"//mash/task_viewer:manifest", "//mash/task_viewer:manifest",
"//services/ui:manifest",
"//services/ui/demo:manifest", "//services/ui/demo:manifest",
"//services/ui/ime/test_ime_driver:manifest", "//services/ui/ime/test_ime_driver:manifest",
"//services/viz:manifest", "//services/viz:manifest",
......
...@@ -292,9 +292,11 @@ catalog("views_mus_tests_catalog") { ...@@ -292,9 +292,11 @@ catalog("views_mus_tests_catalog") {
":interactive_ui_tests_manifest", ":interactive_ui_tests_manifest",
] ]
standalone_services = [ "//services/ui/test_wm:manifest" ] standalone_services = [
"//services/ui:manifest",
catalog_deps = [ "//mash:catalog" ] "//services/ui/test_wm:manifest",
"//services/ui/ime/test_ime_driver:manifest",
]
} }
copy("views_mus_tests_catalog_copy") { copy("views_mus_tests_catalog_copy") {
......
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