Commit 65b73f95 authored by Scott Violet's avatar Scott Violet Committed by Commit Bot

chromeos: gets OopAsh working

This makes AshService create the necessary things when ash runs out of the
browser process.

BUG=837686
TEST=covered by tests

Change-Id: Ia7203fbde3737c8009315c19de0d3b981605eb5a
Reviewed-on: https://chromium-review.googlesource.com/1109465
Commit-Queue: Scott Violet <sky@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#569353}
parent a8583d14
......@@ -1281,6 +1281,8 @@ component("ash") {
"wm/workspace/workspace_window_resizer.h",
"wm/workspace_controller.cc",
"wm/workspace_controller.h",
"ws/ash_gpu_interface_provider.cc",
"ws/ash_gpu_interface_provider.h",
"ws/window_service_delegate_impl.cc",
"ws/window_service_delegate_impl.h",
"ws/window_service_owner.cc",
......@@ -1305,6 +1307,7 @@ component("ash") {
"//services/ui/public/cpp/input_devices",
"//services/ui/public/interfaces",
"//services/ui/public/interfaces/display",
"//services/ui/ws2:host",
"//services/ui/ws2:lib",
"//skia",
"//ui/aura",
......@@ -1343,6 +1346,7 @@ component("ash") {
"//chromeos/services/multidevice_setup/public/mojom",
"//components/account_id",
"//components/device_event_log",
"//components/discardable_memory/service",
"//components/exo",
"//components/exo/wayland",
"//components/onc",
......@@ -1366,9 +1370,11 @@ component("ash") {
"//services/data_decoder/public/cpp",
"//services/preferences/public/cpp",
"//services/service_manager/public/cpp",
"//services/ui/gpu_host",
# TODO(sky): this should not be necessary once --mash goes away.
"//services/ui:lib",
"//services/ui/public/cpp/input_devices:input_device_controller",
"//services/ui/public/interfaces/input_devices",
# TODO(msw): Remove this; only ash_with_content should depend on webkit.
......
......@@ -4,6 +4,8 @@ include_rules = [
"+cc/output",
"+chromeos/cryptohome",
"+components/account_id",
"+components/discardable_memory/public",
"+components/discardable_memory/service/discardable_shared_memory_manager.h",
"+components/exo",
"+components/pref_registry",
"+components/prefs",
......@@ -28,6 +30,8 @@ include_rules = [
"+services/service_manager/embedder",
"+services/service_manager/public",
"+services/ui/common",
"+services/ui/gpu_host/gpu_host.h",
"+services/ui/gpu_host/gpu_host_delegate.h",
"+services/ui/public",
"+services/ui/ws2",
"+services/viz/public",
......@@ -115,6 +119,9 @@ specific_include_rules = {
"app_launch_unittest.cc": [
"+ash/components/quick_launch/public",
],
"ash_service\.*": [
"+chromeos/cryptohome",
],
"message_center_controller\.*": [
"+components/arc/common/notifications.mojom.h"
],
......
......@@ -5,13 +5,45 @@
#include "ash/ash_service.h"
#include "ash/mojo_interface_factory.h"
#include "ash/network_connect_delegate_mus.h"
#include "ash/shell.h"
#include "ash/shell_delegate_mash.h"
#include "ash/shell_init_params.h"
#include "ash/shell_port_classic.h"
#include "ash/ws/ash_gpu_interface_provider.h"
#include "ash/ws/window_service_owner.h"
#include "base/bind.h"
#include "base/process/process_handle.h"
#include "base/feature_list.h"
#include "base/threading/thread.h"
#include "base/threading/thread_task_runner_handle.h"
#include "chromeos/audio/cras_audio_handler.h"
#include "chromeos/cryptohome/system_salt_getter.h"
#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/power_policy_controller.h"
#include "chromeos/network/network_connect.h"
#include "chromeos/network/network_handler.h"
#include "chromeos/system/fake_statistics_provider.h"
#include "components/discardable_memory/service/discardable_shared_memory_manager.h"
#include "components/viz/common/frame_sinks/begin_frame_source.h"
#include "components/viz/common/switches.h"
#include "components/viz/host/host_frame_sink_manager.h"
#include "device/bluetooth/bluetooth_adapter_factory.h"
#include "device/bluetooth/dbus/bluez_dbus_manager.h"
#include "services/service_manager/embedder/embedded_service_info.h"
#include "services/service_manager/public/cpp/connector.h"
#include "services/service_manager/public/cpp/service_context.h"
#include "services/ui/gpu_host/gpu_host.h"
#include "services/ui/public/cpp/gpu/gpu.h"
#include "services/ui/public/cpp/input_devices/input_device_controller.h"
#include "services/ui/public/interfaces/constants.mojom.h"
#include "services/ui/ws2/host_context_factory.h"
#include "services/ui/ws2/window_service.h"
#include "ui/aura/env.h"
#include "ui/aura/window_tree_host.h"
#include "ui/base/ui_base_features.h"
#include "ui/views/layout/layout_provider.h"
#include "ui/views/views_delegate.h"
#include "ui/wm/core/wm_state.h"
namespace ash {
namespace {
......@@ -20,11 +52,49 @@ std::unique_ptr<service_manager::Service> CreateAshService() {
return std::make_unique<AshService>();
}
class AshViewsDelegate : public views::ViewsDelegate {
public:
AshViewsDelegate() = default;
~AshViewsDelegate() override = default;
private:
// views::ViewsDelegate:
void OnBeforeWidgetInit(
views::Widget::InitParams* params,
views::internal::NativeWidgetDelegate* delegate) override {}
// TODO: this may need to create ChromeLayoutProvider.
// https://crbug.com/853989 .
views::LayoutProvider layout_provider_;
DISALLOW_COPY_AND_ASSIGN(AshViewsDelegate);
};
} // namespace
AshService::AshService() = default;
AshService::~AshService() = default;
AshService::~AshService() {
if (!base::FeatureList::IsEnabled(features::kOopAsh))
return;
Shell::DeleteInstance();
statistics_provider_.reset();
// NOTE: PowerStatus is shutdown by Shell.
chromeos::SystemSaltGetter::Shutdown();
chromeos::CrasAudioHandler::Shutdown();
chromeos::NetworkConnect::Shutdown();
network_connect_delegate_.reset();
// We may not have started the NetworkHandler.
if (network_handler_initialized_)
chromeos::NetworkHandler::Shutdown();
device::BluetoothAdapterFactory::Shutdown();
bluez::BluezDBusManager::Shutdown();
chromeos::PowerPolicyController::Shutdown();
if (dbus_thread_manager_initialized_)
chromeos::DBusThreadManager::Shutdown();
}
// static
service_manager::EmbeddedServiceInfo AshService::CreateEmbeddedServiceInfo() {
......@@ -34,11 +104,87 @@ service_manager::EmbeddedServiceInfo AshService::CreateEmbeddedServiceInfo() {
return info;
}
void AshService::InitForOop() {
wm_state_ = std::make_unique<::wm::WMState>();
discardable_shared_memory_manager_ =
std::make_unique<discardable_memory::DiscardableSharedMemoryManager>();
gpu_host_ = std::make_unique<ui::gpu_host::DefaultGpuHost>(
this, context()->connector(), discardable_shared_memory_manager_.get());
host_frame_sink_manager_ = std::make_unique<viz::HostFrameSinkManager>();
host_frame_sink_manager_->WillAssignTemporaryReferencesExternally();
CreateFrameSinkManager();
io_thread_ = std::make_unique<base::Thread>("IOThread");
base::Thread::Options thread_options(base::MessageLoop::TYPE_IO, 0);
thread_options.priority = base::ThreadPriority::NORMAL;
CHECK(io_thread_->StartWithOptions(thread_options));
gpu_ = ui::Gpu::Create(context()->connector(), ui::mojom::kServiceName,
io_thread_->task_runner());
context_factory_ = std::make_unique<ui::ws2::HostContextFactory>(
gpu_.get(), host_frame_sink_manager_.get());
env_ = aura::Env::CreateInstanceToHostViz(context()->connector());
views_delegate_ = std::make_unique<AshViewsDelegate>();
// Must occur after mojo::ApplicationRunner has initialized AtExitManager, but
// before WindowManager::Init(). Tests might initialize their own instance.
if (!chromeos::DBusThreadManager::IsInitialized()) {
chromeos::DBusThreadManager::Initialize(
chromeos::DBusThreadManager::kShared);
dbus_thread_manager_initialized_ = true;
}
chromeos::PowerPolicyController::Initialize(
chromeos::DBusThreadManager::Get()->GetPowerManagerClient());
// See ChromeBrowserMainPartsChromeos for ordering details.
bluez::BluezDBusManager::Initialize(
chromeos::DBusThreadManager::Get()->GetSystemBus(),
chromeos::DBusThreadManager::Get()->IsUsingFakes());
if (!chromeos::NetworkHandler::IsInitialized()) {
chromeos::NetworkHandler::Initialize();
network_handler_initialized_ = true;
}
network_connect_delegate_ = std::make_unique<NetworkConnectDelegateMus>();
chromeos::NetworkConnect::Initialize(network_connect_delegate_.get());
// TODO(jamescook): Initialize real audio handler.
chromeos::CrasAudioHandler::InitializeForTesting();
chromeos::SystemSaltGetter::Initialize();
// TODO(jamescook): Refactor StatisticsProvider so we can get just the data
// we need in ash. Right now StatisticsProviderImpl launches the crossystem
// binary to get system data, which we don't want to do twice on startup.
statistics_provider_.reset(
new chromeos::system::ScopedFakeStatisticsProvider());
statistics_provider_->SetMachineStatistic("initial_locale", "en-US");
statistics_provider_->SetMachineStatistic("keyboard_layout", "");
ShellInitParams shell_init_params;
shell_init_params.shell_port = std::make_unique<ash::ShellPortClassic>();
shell_init_params.delegate =
std::make_unique<ShellDelegateMash>(context()->connector());
shell_init_params.context_factory = context_factory_.get();
shell_init_params.context_factory_private =
context_factory_->GetContextFactoryPrivate();
shell_init_params.connector = context()->connector();
shell_init_params.gpu_interface_provider =
std::make_unique<AshGpuInterfaceProvider>(
gpu_host_.get(), discardable_shared_memory_manager_.get());
Shell::CreateInstance(std::move(shell_init_params));
Shell::GetPrimaryRootWindow()->GetHost()->Show();
}
void AshService::OnStart() {
mojo_interface_factory::RegisterInterfaces(
&registry_, base::ThreadTaskRunnerHandle::Get());
registry_.AddInterface(base::BindRepeating(&AshService::BindServiceFactory,
base::Unretained(this)));
if (base::FeatureList::IsEnabled(features::kOopAsh))
InitForOop();
}
void AshService::OnBindInterface(
......@@ -54,6 +200,12 @@ void AshService::CreateService(
service_manager::mojom::PIDReceiverPtr pid_receiver) {
DCHECK_EQ(name, ui::mojom::kServiceName);
Shell::Get()->window_service_owner()->BindWindowService(std::move(service));
if (base::FeatureList::IsEnabled(features::kOopAsh)) {
ui::ws2::WindowService* window_service =
Shell::Get()->window_service_owner()->window_service();
input_device_controller_ = std::make_unique<ui::InputDeviceController>();
input_device_controller_->AddInterface(window_service->registry());
}
pid_receiver->SetPID(base::GetCurrentProcId());
}
......@@ -62,4 +214,31 @@ void AshService::BindServiceFactory(
service_factory_bindings_.AddBinding(this, std::move(request));
}
void AshService::CreateFrameSinkManager() {
viz::mojom::FrameSinkManagerPtr frame_sink_manager;
viz::mojom::FrameSinkManagerRequest frame_sink_manager_request =
mojo::MakeRequest(&frame_sink_manager);
viz::mojom::FrameSinkManagerClientPtr frame_sink_manager_client;
viz::mojom::FrameSinkManagerClientRequest frame_sink_manager_client_request =
mojo::MakeRequest(&frame_sink_manager_client);
viz::mojom::FrameSinkManagerParamsPtr params =
viz::mojom::FrameSinkManagerParams::New();
params->restart_id = viz::BeginFrameSource::kNotRestartableId + 1;
base::Optional<uint32_t> activation_deadline_in_frames =
switches::GetDeadlineToSynchronizeSurfaces();
params->use_activation_deadline = activation_deadline_in_frames.has_value();
params->activation_deadline_in_frames =
activation_deadline_in_frames.value_or(0u);
params->frame_sink_manager = std::move(frame_sink_manager_request);
params->frame_sink_manager_client = frame_sink_manager_client.PassInterface();
gpu_host_->CreateFrameSinkManager(std::move(params));
host_frame_sink_manager_->BindAndSetManager(
std::move(frame_sink_manager_client_request), nullptr /* task_runner */,
std::move(frame_sink_manager));
}
void AshService::OnGpuServiceInitialized() {}
} // namespace ash
......@@ -11,20 +11,63 @@
#include "services/service_manager/public/cpp/binder_registry.h"
#include "services/service_manager/public/cpp/service.h"
#include "services/service_manager/public/mojom/service_factory.mojom.h"
#include "services/ui/gpu_host/gpu_host_delegate.h"
#include "services/ui/public/interfaces/gpu.mojom.h"
namespace aura {
class Env;
} // namespace aura
namespace base {
class Thread;
}
namespace chromeos {
namespace system {
class ScopedFakeStatisticsProvider;
}
} // namespace chromeos
namespace discardable_memory {
class DiscardableSharedMemoryManager;
}
namespace service_manager {
struct EmbeddedServiceInfo;
}
namespace ui {
class Gpu;
class InputDeviceController;
namespace gpu_host {
class GpuHost;
}
namespace ws2 {
class HostContextFactory;
}
} // namespace ui
namespace views {
class ViewsDelegate;
}
namespace viz {
class HostFrameSinkManager;
}
namespace wm {
class WMState;
}
namespace ash {
class NetworkConnectDelegateMus;
// Used to export Ash's mojo services, specifically the interfaces defined in
// Ash's manifest.json. Also responsible for creating the
// UI-Service/WindowService.
//
// NOTE: this is not used for --mash.
// UI-Service/WindowService when ash runs out of process.
class ASH_EXPORT AshService : public service_manager::Service,
public service_manager::mojom::ServiceFactory {
public service_manager::mojom::ServiceFactory,
public ui::gpu_host::GpuHostDelegate {
public:
AshService();
~AshService() override;
......@@ -45,13 +88,52 @@ class ASH_EXPORT AshService : public service_manager::Service,
service_manager::mojom::PIDReceiverPtr pid_receiver) override;
private:
// Does initialization necessary when ash runs out of process. This is called
// once the service starts (from OnStart()).
void InitForOop();
void BindServiceFactory(
service_manager::mojom::ServiceFactoryRequest request);
void CreateFrameSinkManager();
// ui::ws::GpuHostDelegate:
void OnGpuServiceInitialized() override;
service_manager::BinderRegistry registry_;
mojo::BindingSet<service_manager::mojom::ServiceFactory>
service_factory_bindings_;
std::unique_ptr<::wm::WMState> wm_state_;
std::unique_ptr<discardable_memory::DiscardableSharedMemoryManager>
discardable_shared_memory_manager_;
std::unique_ptr<ui::gpu_host::GpuHost> gpu_host_;
std::unique_ptr<viz::HostFrameSinkManager> host_frame_sink_manager_;
// IO thread for GPU and discardable shared memory IPC.
std::unique_ptr<base::Thread> io_thread_;
std::unique_ptr<ui::Gpu> gpu_;
std::unique_ptr<ui::ws2::HostContextFactory> context_factory_;
std::unique_ptr<aura::Env> env_;
std::unique_ptr<views::ViewsDelegate> views_delegate_;
std::unique_ptr<NetworkConnectDelegateMus> network_connect_delegate_;
std::unique_ptr<chromeos::system::ScopedFakeStatisticsProvider>
statistics_provider_;
std::unique_ptr<ui::InputDeviceController> input_device_controller_;
// Whether this class initialized NetworkHandler and needs to clean it up.
bool network_handler_initialized_ = false;
// Whether this class initialized DBusThreadManager and needs to clean it up.
bool dbus_thread_manager_initialized_ = false;
DISALLOW_COPY_AND_ASSIGN(AshService);
};
......
......@@ -19,6 +19,7 @@
#include "ash/wm/window_state.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/window.h"
#include "ui/base/ui_base_features.h"
#include "ui/views/controls/image_view.h"
#include "ui/views/widget/widget.h"
......@@ -123,7 +124,7 @@ HeaderView::HeaderView(views::Widget* target_widget,
target_widget, this, caption_button_container_);
} else {
DCHECK_EQ(mojom::WindowStyle::BROWSER, window_style);
DCHECK_EQ(Config::MASH, Shell::GetAshConfig());
DCHECK(!::features::IsAshInBrowserProcess());
appearance_provider_ = std::make_unique<WindowPropertyAppearanceProvider>(
target_widget_->GetNativeWindow());
// TODO(estade): pass correct value for |incognito|.
......
......@@ -1052,9 +1052,12 @@ void Shell::Init(
if (config == Config::CLASSIC) {
// This will initialize aura::Env which requires |display_manager_| to
// be initialized first.
aura::Env::GetInstance()->set_context_factory(context_factory);
aura::Env::GetInstance()->set_context_factory_private(
context_factory_private);
if (context_factory)
aura::Env::GetInstance()->set_context_factory(context_factory);
if (context_factory_private) {
aura::Env::GetInstance()->set_context_factory_private(
context_factory_private);
}
}
// Night Light depends on the display manager, the display color manager, and
......@@ -1169,7 +1172,7 @@ void Shell::Init(
std::move(user_activity_monitor), user_activity_detector_.get());
}
if (config == Config::MASH)
if (!::features::IsAshInBrowserProcess())
client_image_registry_ = std::make_unique<ClientImageRegistry>();
// In mash drag and drop is handled by mus.
......
......@@ -20,6 +20,7 @@
#include "mash/public/mojom/launchable.mojom.h"
#include "services/service_manager/public/cpp/connector.h"
#include "ui/accessibility/ax_node_data.h"
#include "ui/base/ui_base_features.h"
#include "ui/gfx/color_palette.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/paint_vector_icon.h"
......@@ -40,7 +41,7 @@ FlagWarningTray::FlagWarningTray(Shelf* shelf) : shelf_(shelf) {
// Flag warning tray is not currently used in non-MASH environments, because
// mus will roll out via experiment/Finch trial and showing the tray would
// reveal the experiment state to users.
DCHECK_EQ(Shell::GetAshConfig(), Config::MASH);
DCHECK(!::features::IsAshInBrowserProcess());
container_ = new TrayContainer(shelf);
AddChildView(container_);
......
......@@ -23,6 +23,7 @@
#include "ash/system/virtual_keyboard/virtual_keyboard_tray.h"
#include "base/command_line.h"
#include "base/i18n/time_formatting.h"
#include "ui/base/ui_base_features.h"
#include "ui/display/display.h"
#include "ui/native_theme/native_theme_dark_aura.h"
......@@ -83,7 +84,7 @@ void StatusAreaWidget::Initialize() {
logout_button_tray_ = std::make_unique<LogoutButtonTray>(shelf_);
status_area_widget_delegate_->AddChildView(logout_button_tray_.get());
if (Shell::GetAshConfig() == ash::Config::MASH) {
if (!::features::IsAshInBrowserProcess()) {
// Flag warning tray is not currently used in non-MASH environments, because
// mus will roll out via experiment/Finch trial and showing the tray would
// reveal the experiment state to users.
......
// Copyright 2018 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 "ash/ws/ash_gpu_interface_provider.h"
#include "base/bind.h"
#include "components/discardable_memory/service/discardable_shared_memory_manager.h"
#include "services/service_manager/public/cpp/bind_source_info.h"
#include "services/service_manager/public/cpp/binder_registry.h"
#include "services/ui/gpu_host/gpu_host.h"
namespace ash {
AshGpuInterfaceProvider::AshGpuInterfaceProvider(
ui::gpu_host::GpuHost* gpu_host,
discardable_memory::DiscardableSharedMemoryManager*
discardable_shared_memory_manager)
: gpu_host_(gpu_host),
discardable_shared_memory_manager_(discardable_shared_memory_manager) {
DCHECK(gpu_host_);
DCHECK(discardable_shared_memory_manager_);
}
AshGpuInterfaceProvider::~AshGpuInterfaceProvider() = default;
void AshGpuInterfaceProvider::RegisterGpuInterfaces(
service_manager::BinderRegistry* registry) {
registry->AddInterface(base::BindRepeating(
&AshGpuInterfaceProvider::BindGpuRequest, base::Unretained(this)));
registry->AddInterface(base::BindRepeating(
&AshGpuInterfaceProvider::BindDiscardableSharedMemoryManagerRequest,
base::Unretained(this)));
}
void AshGpuInterfaceProvider::BindDiscardableSharedMemoryManagerRequest(
discardable_memory::mojom::DiscardableSharedMemoryManagerRequest request) {
discardable_shared_memory_manager_->Bind(std::move(request),
service_manager::BindSourceInfo());
}
void AshGpuInterfaceProvider::BindGpuRequest(ui::mojom::GpuRequest request) {
gpu_host_->Add(std::move(request));
}
} // namespace ash
// Copyright 2018 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 ASH_WS_ASH_GPU_INTERFACE_PROVIDER_H_
#define ASH_WS_ASH_GPU_INTERFACE_PROVIDER_H_
#include "components/discardable_memory/public/interfaces/discardable_shared_memory_manager.mojom.h"
#include "services/ui/public/interfaces/gpu.mojom.h"
#include "services/ui/ws2/gpu_interface_provider.h"
namespace discardable_memory {
class DiscardableSharedMemoryManager;
}
namespace ui {
namespace gpu_host {
class GpuHost;
}
} // namespace ui
namespace ash {
// Implementation of GpuInterfaceProvider used when Ash runs out of process.
class AshGpuInterfaceProvider : public ui::ws2::GpuInterfaceProvider {
public:
AshGpuInterfaceProvider(ui::gpu_host::GpuHost* gpu_host,
discardable_memory::DiscardableSharedMemoryManager*
discardable_shared_memory_manager);
~AshGpuInterfaceProvider() override;
// ui::ws2::GpuInterfaceProvider:
void RegisterGpuInterfaces(
service_manager::BinderRegistry* registry) override;
private:
void BindDiscardableSharedMemoryManagerRequest(
discardable_memory::mojom::DiscardableSharedMemoryManagerRequest request);
void BindGpuRequest(ui::mojom::GpuRequest request);
ui::gpu_host::GpuHost* gpu_host_;
discardable_memory::DiscardableSharedMemoryManager*
discardable_shared_memory_manager_;
DISALLOW_COPY_AND_ASSIGN(AshGpuInterfaceProvider);
};
} // namespace ash
#endif // ASH_WS_ASH_GPU_INTERFACE_PROVIDER_H_
......@@ -66,9 +66,11 @@ if (is_chromeos) {
"//services/ui/public/interfaces/input_devices",
]
# This target is really an implementation detail of the ui service, but
# until Chrome is switched over to mus it needs to be visible to Chrome too.
# This target is really an implementation detail of the ui service, which
# is hosted in ash. Until Ash is switched out of process chrome needs to
# depend upon it too.
visibility = [
"//ash:ash",
"//chrome/browser",
"//services/ui:lib",
]
......
......@@ -102,6 +102,8 @@ void WindowService::OnStart() {
&WindowService::BindInputDeviceServerRequest, base::Unretained(this)));
registry_.AddInterface(base::BindRepeating(
&WindowService::BindWindowTreeFactoryRequest, base::Unretained(this)));
registry_.AddInterface(base::BindRepeating(
&WindowService::BindUserActivityMonitorRequest, base::Unretained(this)));
// |gpu_interface_provider_| may be null in tests.
if (gpu_interface_provider_)
......@@ -141,6 +143,12 @@ void WindowService::BindInputDeviceServerRequest(
input_device_server_.AddBinding(std::move(request));
}
void WindowService::BindUserActivityMonitorRequest(
ui::mojom::UserActivityMonitorRequest request) {
// TODO: https://crbug.com/854700.
NOTIMPLEMENTED_LOG_ONCE();
}
void WindowService::BindWindowTreeFactoryRequest(
ui::mojom::WindowTreeFactoryRequest request) {
window_tree_factory_->AddBinding(std::move(request));
......
......@@ -17,6 +17,7 @@
#include "services/ui/input_devices/input_device_server.h"
#include "services/ui/public/interfaces/ime/ime.mojom.h"
#include "services/ui/public/interfaces/screen_provider.mojom.h"
#include "services/ui/public/interfaces/user_activity_monitor.mojom.h"
#include "services/ui/public/interfaces/window_tree.mojom.h"
#include "services/ui/ws2/ids.h"
#include "ui/aura/mus/property_converter.h"
......@@ -84,6 +85,8 @@ class COMPONENT_EXPORT(WINDOW_SERVICE) WindowService
const std::set<WindowTree*>& window_trees() const { return window_trees_; }
service_manager::BinderRegistry* registry() { return &registry_; }
// Called when a WindowServiceClient is about to be destroyed.
void OnWillDestroyWindowTree(WindowTree* tree);
......@@ -103,6 +106,8 @@ class COMPONENT_EXPORT(WINDOW_SERVICE) WindowService
void BindImeRegistrarRequest(mojom::IMERegistrarRequest request);
void BindImeDriverRequest(mojom::IMEDriverRequest request);
void BindInputDeviceServerRequest(mojom::InputDeviceServerRequest request);
void BindUserActivityMonitorRequest(
mojom::UserActivityMonitorRequest request);
void BindWindowTreeFactoryRequest(
ui::mojom::WindowTreeFactoryRequest request);
......
......@@ -65,10 +65,21 @@ Env::~Env() {
std::unique_ptr<Env> Env::CreateInstance(Mode mode) {
DCHECK(!lazy_tls_ptr.Pointer()->Get());
std::unique_ptr<Env> env(new Env(mode));
env->Init();
env->Init(nullptr);
return env;
}
#if defined(USE_OZONE)
// static
std::unique_ptr<Env> Env::CreateInstanceToHostViz(
service_manager::Connector* connector) {
DCHECK(!lazy_tls_ptr.Pointer()->Get());
std::unique_ptr<Env> env(new Env(Mode::LOCAL));
env->Init(connector);
return env;
}
#endif
// static
Env* Env::GetInstance() {
Env* env = lazy_tls_ptr.Pointer()->Get();
......@@ -195,7 +206,7 @@ Env::Env(Mode mode)
lazy_tls_ptr.Pointer()->Set(this);
}
void Env::Init() {
void Env::Init(service_manager::Connector* connector) {
if (mode_ == Mode::MUS) {
EnableMusOSExchangeDataProvider();
EnableMusOverrideInputInjector();
......@@ -214,6 +225,14 @@ void Env::Init() {
command_line->HasSwitch("in-process-gpu");
params.using_mojo = command_line->HasSwitch(switches::kEnableDrmMojo);
if (connector) {
// Supplying a connector implies this process is hosting Viz.
params.connector = connector;
// Hosting viz is currently single-process only.
params.single_process = true;
params.using_mojo = true;
}
ui::OzonePlatform::InitializeForUI(params);
#endif
if (!ui::PlatformEventSource::GetInstance())
......
......@@ -11,6 +11,7 @@
#include "base/macros.h"
#include "base/observer_list.h"
#include "base/supports_user_data.h"
#include "build/build_config.h"
#include "mojo/public/cpp/system/buffer.h"
#include "ui/aura/aura_export.h"
#include "ui/base/dragdrop/os_exchange_data_provider_factory.h"
......@@ -28,6 +29,10 @@ template <typename MojoInterface>
class InterfacePtr;
}
namespace service_manager {
class Connector;
}
namespace ui {
class ContextFactory;
class ContextFactoryPrivate;
......@@ -73,6 +78,14 @@ class AURA_EXPORT Env : public ui::EventTarget,
// NOTE: if you pass in Mode::MUS it is expected that you call
// SetWindowTreeClient() before any windows are created.
static std::unique_ptr<Env> CreateInstance(Mode mode = Mode::LOCAL);
#if defined(USE_OZONE)
// used to create a new Env that hosts the viz process. |connector| is the
// connector used to establish outbound connections.
static std::unique_ptr<Env> CreateInstanceToHostViz(
service_manager::Connector* connector);
#endif
static Env* GetInstance();
static Env* GetInstanceDontCreate();
......@@ -167,7 +180,7 @@ class AURA_EXPORT Env : public ui::EventTarget,
explicit Env(Mode mode);
void Init();
void Init(service_manager::Connector* connector);
// After calling this method, all OSExchangeDataProvider instances will be
// Mus instances. We can't do this work in Init(), because our mode may
......
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