Commit ae4c25d5 authored by Scott Violet's avatar Scott Violet Committed by Commit Bot

chromeos: renames GpuSupport to GpuInterfaceProvider

And updates the functions to better reflect what it is suppose to do. There was
a race conditions with how the code was before. In particular, because
access to content has to be on the io-thread care must be taken during
destruction. Creation of the interfaces happens on the io thread, which means
destruction of the object supplied to AddInterface() has to happen on the
io-thread. I separated out the parts that happen on the io thread into a
refcounted thread safe that is destroyed on the io thread.

BUG=837686
TEST=covered by tests

Change-Id: Ia3dce4894a3cf4b7a08cd5a9c4d1fae674d7e7c5
Reviewed-on: https://chromium-review.googlesource.com/1105611Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Scott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#568469}
parent b257999e
...@@ -1436,8 +1436,8 @@ component("ash") { ...@@ -1436,8 +1436,8 @@ component("ash") {
component("ash_with_content") { component("ash_with_content") {
sources = [ sources = [
"content/ash_with_content_export.h", "content/ash_with_content_export.h",
"content/content_gpu_support.cc", "content/content_gpu_interface_provider.cc",
"content/content_gpu_support.h", "content/content_gpu_interface_provider.h",
"content/keyboard_overlay/keyboard_overlay_delegate.cc", "content/keyboard_overlay/keyboard_overlay_delegate.cc",
"content/keyboard_overlay/keyboard_overlay_delegate.h", "content/keyboard_overlay/keyboard_overlay_delegate.h",
"content/keyboard_overlay/keyboard_overlay_view.cc", "content/keyboard_overlay/keyboard_overlay_view.cc",
...@@ -1461,6 +1461,8 @@ component("ash_with_content") { ...@@ -1461,6 +1461,8 @@ component("ash_with_content") {
"//content/public/browser", "//content/public/browser",
"//gpu/config", "//gpu/config",
"//ipc", "//ipc",
"//mojo/public/cpp/bindings",
"//services/ui/public/interfaces",
"//skia", "//skia",
"//ui/aura", "//ui/aura",
"//ui/base", "//ui/base",
......
specific_include_rules = { specific_include_rules = {
"content_gpu_support.*": [ "content_gpu_interface_provider.*": [
"+components/discardable_memory/public/interfaces",
"+content/public/browser", "+content/public/browser",
], ],
"screen_orientation_delegate_chromeos.cc": [ "screen_orientation_delegate_chromeos.cc": [
......
// 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/content/content_gpu_interface_provider.h"
#include "base/containers/unique_ptr_adapters.h"
#include "base/memory/ref_counted.h"
#include "components/discardable_memory/public/interfaces/discardable_shared_memory_manager.mojom.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/gpu_client.h"
#include "content/public/browser/gpu_service_registry.h"
#include "services/ui/public/interfaces/gpu.mojom.h"
namespace ash {
// InterfaceBinderImpl handles the actual binding. The binding (and destruction
// of this object) has to happen on the io-thread.
class ContentGpuInterfaceProvider::InterfaceBinderImpl
: public base::RefCountedThreadSafe<
InterfaceBinderImpl,
content::BrowserThread::DeleteOnIOThread> {
public:
InterfaceBinderImpl() = default;
void BindGpuRequestOnGpuTaskRunner(ui::mojom::GpuRequest request) {
auto gpu_client = content::GpuClient::Create(
std::move(request),
base::BindOnce(&InterfaceBinderImpl::OnGpuClientConnectionError, this));
gpu_clients_.push_back(std::move(gpu_client));
}
void BindDiscardableSharedMemoryManagerOnGpuTaskRunner(
discardable_memory::mojom::DiscardableSharedMemoryManagerRequest
request) {
content::BindInterfaceInGpuProcess(std::move(request));
}
private:
friend struct content::BrowserThread::DeleteOnThread<
content::BrowserThread::IO>;
friend class base::DeleteHelper<InterfaceBinderImpl>;
~InterfaceBinderImpl() = default;
void OnGpuClientConnectionError(content::GpuClient* client) {
base::EraseIf(
gpu_clients_,
base::UniquePtrMatcher<content::GpuClient,
content::BrowserThread::DeleteOnIOThread>(
client));
}
std::vector<std::unique_ptr<content::GpuClient,
content::BrowserThread::DeleteOnIOThread>>
gpu_clients_;
DISALLOW_COPY_AND_ASSIGN(InterfaceBinderImpl);
};
ContentGpuInterfaceProvider::ContentGpuInterfaceProvider()
: interface_binder_impl_(base::MakeRefCounted<InterfaceBinderImpl>()) {}
ContentGpuInterfaceProvider::~ContentGpuInterfaceProvider() = default;
void ContentGpuInterfaceProvider::RegisterGpuInterfaces(
service_manager::BinderRegistry* registry) {
scoped_refptr<base::SingleThreadTaskRunner> gpu_task_runner =
content::BrowserThread::GetTaskRunnerForThread(
content::BrowserThread::IO);
registry->AddInterface(
base::BindRepeating(&InterfaceBinderImpl::
BindDiscardableSharedMemoryManagerOnGpuTaskRunner,
interface_binder_impl_),
gpu_task_runner);
registry->AddInterface(
base::BindRepeating(&InterfaceBinderImpl::BindGpuRequestOnGpuTaskRunner,
interface_binder_impl_),
gpu_task_runner);
}
} // 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_CONTENT_CONTENT_GPU_INTERFACE_PROVIDER_H_
#define ASH_CONTENT_CONTENT_GPU_INTERFACE_PROVIDER_H_
#include <memory>
#include <vector>
#include "ash/content/ash_with_content_export.h"
#include "base/macros.h"
#include "base/memory/scoped_refptr.h"
#include "services/ui/ws2/gpu_interface_provider.h"
namespace ash {
// An implementation of GpuInterfaceProvider that forwards to the Gpu
// implementation in content.
class ASH_WITH_CONTENT_EXPORT ContentGpuInterfaceProvider
: public ui::ws2::GpuInterfaceProvider {
public:
ContentGpuInterfaceProvider();
~ContentGpuInterfaceProvider() override;
// ui::ws2::GpuInterfaceProvider:
void RegisterGpuInterfaces(
service_manager::BinderRegistry* registry) override;
private:
class InterfaceBinderImpl;
scoped_refptr<InterfaceBinderImpl> interface_binder_impl_;
DISALLOW_COPY_AND_ASSIGN(ContentGpuInterfaceProvider);
};
} // namespace ash
#endif // ASH_CONTENT_CONTENT_GPU_INTERFACE_PROVIDER_H_
// 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/content/content_gpu_support.h"
#include "base/containers/unique_ptr_adapters.h"
#include "content/public/browser/gpu_client.h"
#include "content/public/browser/gpu_service_registry.h"
namespace ash {
ContentGpuSupport::ContentGpuSupport() = default;
ContentGpuSupport::~ContentGpuSupport() = default;
scoped_refptr<base::SingleThreadTaskRunner>
ContentGpuSupport::GetGpuTaskRunner() {
return content::BrowserThread::GetTaskRunnerForThread(
content::BrowserThread::IO);
}
void ContentGpuSupport::BindDiscardableSharedMemoryManagerOnGpuTaskRunner(
discardable_memory::mojom::DiscardableSharedMemoryManagerRequest request) {
content::BindInterfaceInGpuProcess(std::move(request));
}
void ContentGpuSupport::BindGpuRequestOnGpuTaskRunner(
ui::mojom::GpuRequest request) {
auto gpu_client = content::GpuClient::Create(
std::move(request),
base::BindOnce(&ContentGpuSupport::OnGpuClientConnectionError,
base::Unretained(this)));
gpu_clients_.push_back(std::move(gpu_client));
}
void ContentGpuSupport::OnGpuClientConnectionError(content::GpuClient* client) {
base::EraseIf(
gpu_clients_,
base::UniquePtrMatcher<content::GpuClient,
content::BrowserThread::DeleteOnIOThread>(client));
}
} // 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_CONTENT_CONTENT_GPU_SUPPORT_H_
#define ASH_CONTENT_CONTENT_GPU_SUPPORT_H_
#include <memory>
#include <vector>
#include "ash/content/ash_with_content_export.h"
#include "base/macros.h"
#include "content/public/browser/browser_thread.h"
#include "services/ui/ws2/gpu_support.h"
namespace content {
class GpuClient;
}
namespace ash {
// An implementation of GpuSupport that forwards to the Gpu implementation in
// content.
class ASH_WITH_CONTENT_EXPORT ContentGpuSupport : public ui::ws2::GpuSupport {
public:
ContentGpuSupport();
~ContentGpuSupport() override;
// ui::ws2::GpuSupport:
scoped_refptr<base::SingleThreadTaskRunner> GetGpuTaskRunner() override;
void BindDiscardableSharedMemoryManagerOnGpuTaskRunner(
discardable_memory::mojom::DiscardableSharedMemoryManagerRequest request)
override;
void BindGpuRequestOnGpuTaskRunner(ui::mojom::GpuRequest request) override;
private:
void OnGpuClientConnectionError(content::GpuClient* client);
std::vector<std::unique_ptr<content::GpuClient,
content::BrowserThread::DeleteOnIOThread>>
gpu_clients_;
DISALLOW_COPY_AND_ASSIGN(ContentGpuSupport);
};
} // namespace ash
#endif // ASH_CONTENT_CONTENT_GPU_SUPPORT_H_
...@@ -177,7 +177,7 @@ ...@@ -177,7 +177,7 @@
#include "services/preferences/public/mojom/preferences.mojom.h" #include "services/preferences/public/mojom/preferences.mojom.h"
#include "services/service_manager/public/cpp/connector.h" #include "services/service_manager/public/cpp/connector.h"
#include "services/ui/public/interfaces/constants.mojom.h" #include "services/ui/public/interfaces/constants.mojom.h"
#include "services/ui/ws2/gpu_support.h" #include "services/ui/ws2/gpu_interface_provider.h"
#include "ui/aura/client/aura_constants.h" #include "ui/aura/client/aura_constants.h"
#include "ui/aura/env.h" #include "ui/aura/env.h"
#include "ui/aura/layout_manager.h" #include "ui/aura/layout_manager.h"
...@@ -280,7 +280,7 @@ Shell* Shell::CreateInstance(ShellInitParams init_params) { ...@@ -280,7 +280,7 @@ Shell* Shell::CreateInstance(ShellInitParams init_params) {
instance_->Init(init_params.context_factory, instance_->Init(init_params.context_factory,
init_params.context_factory_private, init_params.context_factory_private,
std::move(init_params.initial_display_prefs), std::move(init_params.initial_display_prefs),
std::move(init_params.gpu_support)); std::move(init_params.gpu_interface_provider));
return instance_; return instance_;
} }
...@@ -955,10 +955,11 @@ Shell::~Shell() { ...@@ -955,10 +955,11 @@ Shell::~Shell() {
instance_ = nullptr; instance_ = nullptr;
} }
void Shell::Init(ui::ContextFactory* context_factory, void Shell::Init(
ui::ContextFactoryPrivate* context_factory_private, ui::ContextFactory* context_factory,
std::unique_ptr<base::Value> initial_display_prefs, ui::ContextFactoryPrivate* context_factory_private,
std::unique_ptr<ui::ws2::GpuSupport> gpu_support) { std::unique_ptr<base::Value> initial_display_prefs,
std::unique_ptr<ui::ws2::GpuInterfaceProvider> gpu_interface_provider) {
const Config config = shell_port_->GetAshConfig(); const Config config = shell_port_->GetAshConfig();
// This creates the MessageCenter object which is used by some other objects // This creates the MessageCenter object which is used by some other objects
...@@ -1298,7 +1299,7 @@ void Shell::Init(ui::ContextFactory* context_factory, ...@@ -1298,7 +1299,7 @@ void Shell::Init(ui::ContextFactory* context_factory,
if (config != Config::MASH) { if (config != Config::MASH) {
window_service_owner_ = window_service_owner_ =
std::make_unique<WindowServiceOwner>(std::move(gpu_support)); std::make_unique<WindowServiceOwner>(std::move(gpu_interface_provider));
ime_focus_handler_ = std::make_unique<ImeFocusHandler>( ime_focus_handler_ = std::make_unique<ImeFocusHandler>(
focus_controller(), window_tree_host_manager_->input_method()); focus_controller(), window_tree_host_manager_->input_method());
} }
......
...@@ -62,7 +62,7 @@ class ContextFactoryPrivate; ...@@ -62,7 +62,7 @@ class ContextFactoryPrivate;
class UserActivityDetector; class UserActivityDetector;
class UserActivityPowerManagerNotifier; class UserActivityPowerManagerNotifier;
namespace ws2 { namespace ws2 {
class GpuSupport; class GpuInterfaceProvider;
} }
} // namespace ui } // namespace ui
...@@ -675,10 +675,11 @@ class ASH_EXPORT Shell : public SessionObserver, ...@@ -675,10 +675,11 @@ class ASH_EXPORT Shell : public SessionObserver,
std::unique_ptr<ShellPort> shell_port); std::unique_ptr<ShellPort> shell_port);
~Shell() override; ~Shell() override;
void Init(ui::ContextFactory* context_factory, void Init(
ui::ContextFactoryPrivate* context_factory_private, ui::ContextFactory* context_factory,
std::unique_ptr<base::Value> initial_display_prefs, ui::ContextFactoryPrivate* context_factory_private,
std::unique_ptr<ui::ws2::GpuSupport> gpu_support); std::unique_ptr<base::Value> initial_display_prefs,
std::unique_ptr<ui::ws2::GpuInterfaceProvider> gpu_interface_provider);
// Initializes the display manager and related components. // Initializes the display manager and related components.
void InitializeDisplayManager(); void InitializeDisplayManager();
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#include "ash/components/quick_launch/public/mojom/constants.mojom.h" #include "ash/components/quick_launch/public/mojom/constants.mojom.h"
#include "ash/components/shortcut_viewer/public/mojom/shortcut_viewer.mojom.h" #include "ash/components/shortcut_viewer/public/mojom/shortcut_viewer.mojom.h"
#include "ash/components/tap_visualizer/public/mojom/constants.mojom.h" #include "ash/components/tap_visualizer/public/mojom/constants.mojom.h"
#include "ash/content/content_gpu_support.h" #include "ash/content/content_gpu_interface_provider.h"
#include "ash/content/shell_content_state.h" #include "ash/content/shell_content_state.h"
#include "ash/login_status.h" #include "ash/login_status.h"
#include "ash/public/cpp/ash_features.h" #include "ash/public/cpp/ash_features.h"
...@@ -97,7 +97,8 @@ void ShellBrowserMainParts::PreMainMessageLoopRun() { ...@@ -97,7 +97,8 @@ void ShellBrowserMainParts::PreMainMessageLoopRun() {
init_params.delegate = std::make_unique<ash::shell::ShellDelegateImpl>(); init_params.delegate = std::make_unique<ash::shell::ShellDelegateImpl>();
init_params.context_factory = content::GetContextFactory(); init_params.context_factory = content::GetContextFactory();
init_params.context_factory_private = content::GetContextFactoryPrivate(); init_params.context_factory_private = content::GetContextFactoryPrivate();
init_params.gpu_support = std::make_unique<ContentGpuSupport>(); init_params.gpu_interface_provider =
std::make_unique<ContentGpuInterfaceProvider>();
ash::Shell::CreateInstance(std::move(init_params)); ash::Shell::CreateInstance(std::move(init_params));
// Initialize session controller client and create fake user sessions. The // Initialize session controller client and create fake user sessions. The
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
#include "ash/shell_delegate.h" #include "ash/shell_delegate.h"
#include "ash/shell_port.h" #include "ash/shell_port.h"
#include "services/ui/ws2/gpu_support.h" #include "services/ui/ws2/gpu_interface_provider.h"
namespace ash { namespace ash {
......
...@@ -17,7 +17,7 @@ namespace ui { ...@@ -17,7 +17,7 @@ namespace ui {
class ContextFactory; class ContextFactory;
class ContextFactoryPrivate; class ContextFactoryPrivate;
namespace ws2 { namespace ws2 {
class GpuSupport; class GpuInterfaceProvider;
} }
} }
...@@ -39,9 +39,9 @@ struct ASH_EXPORT ShellInitParams { ...@@ -39,9 +39,9 @@ struct ASH_EXPORT ShellInitParams {
// ShellObserver::OnLocalStatePrefServiceInitialized is called. // ShellObserver::OnLocalStatePrefServiceInitialized is called.
std::unique_ptr<base::Value> initial_display_prefs; std::unique_ptr<base::Value> initial_display_prefs;
// Allows gpu-support to be injected while avoiding direct content // Allows gpu interfaces to be injected while avoiding direct content
// dependencies. // dependencies.
std::unique_ptr<ui::ws2::GpuSupport> gpu_support; std::unique_ptr<ui::ws2::GpuInterfaceProvider> gpu_interface_provider;
}; };
} // namespace ash } // namespace ash
......
...@@ -9,15 +9,15 @@ ...@@ -9,15 +9,15 @@
#include "ash/wm/non_client_frame_controller.h" #include "ash/wm/non_client_frame_controller.h"
#include "ash/ws/window_service_delegate_impl.h" #include "ash/ws/window_service_delegate_impl.h"
#include "services/service_manager/public/cpp/service_context.h" #include "services/service_manager/public/cpp/service_context.h"
#include "services/ui/ws2/gpu_support.h" #include "services/ui/ws2/gpu_interface_provider.h"
#include "services/ui/ws2/window_service.h" #include "services/ui/ws2/window_service.h"
#include "ui/wm/core/focus_controller.h" #include "ui/wm/core/focus_controller.h"
namespace ash { namespace ash {
WindowServiceOwner::WindowServiceOwner( WindowServiceOwner::WindowServiceOwner(
std::unique_ptr<ui::ws2::GpuSupport> gpu_support) std::unique_ptr<ui::ws2::GpuInterfaceProvider> gpu_interface_provider)
: gpu_support_(std::move(gpu_support)) {} : gpu_interface_provider_(std::move(gpu_interface_provider)) {}
WindowServiceOwner::~WindowServiceOwner() = default; WindowServiceOwner::~WindowServiceOwner() = default;
...@@ -31,7 +31,7 @@ void WindowServiceOwner::BindWindowService( ...@@ -31,7 +31,7 @@ void WindowServiceOwner::BindWindowService(
window_service_delegate_ = std::make_unique<WindowServiceDelegateImpl>(); window_service_delegate_ = std::make_unique<WindowServiceDelegateImpl>();
std::unique_ptr<ui::ws2::WindowService> window_service = std::unique_ptr<ui::ws2::WindowService> window_service =
std::make_unique<ui::ws2::WindowService>( std::make_unique<ui::ws2::WindowService>(
window_service_delegate_.get(), std::move(gpu_support_), window_service_delegate_.get(), std::move(gpu_interface_provider_),
Shell::Get()->focus_controller()); Shell::Get()->focus_controller());
window_service_ = window_service.get(); window_service_ = window_service.get();
window_service_->SetFrameDecorationValues( window_service_->SetFrameDecorationValues(
......
...@@ -18,7 +18,7 @@ class ServiceContext; ...@@ -18,7 +18,7 @@ class ServiceContext;
namespace ui { namespace ui {
namespace ws2 { namespace ws2 {
class GpuSupport; class GpuInterfaceProvider;
class WindowService; class WindowService;
} // namespace ws2 } // namespace ws2
} // namespace ui } // namespace ui
...@@ -32,7 +32,8 @@ class WindowServiceDelegateImpl; ...@@ -32,7 +32,8 @@ class WindowServiceDelegateImpl;
// BindWindowService() is called the WindowService is created. // BindWindowService() is called the WindowService is created.
class ASH_EXPORT WindowServiceOwner { class ASH_EXPORT WindowServiceOwner {
public: public:
explicit WindowServiceOwner(std::unique_ptr<ui::ws2::GpuSupport> gpu_support); explicit WindowServiceOwner(
std::unique_ptr<ui::ws2::GpuInterfaceProvider> gpu_interface_provider);
~WindowServiceOwner(); ~WindowServiceOwner();
// Called from the ServiceManager when a request is made for the // Called from the ServiceManager when a request is made for the
...@@ -47,7 +48,7 @@ class ASH_EXPORT WindowServiceOwner { ...@@ -47,7 +48,7 @@ class ASH_EXPORT WindowServiceOwner {
friend class AshTestHelper; friend class AshTestHelper;
// Non-null until |service_context_| is created. // Non-null until |service_context_| is created.
std::unique_ptr<ui::ws2::GpuSupport> gpu_support_; std::unique_ptr<ui::ws2::GpuInterfaceProvider> gpu_interface_provider_;
// The following state is created once BindWindowService() is called. // The following state is created once BindWindowService() is called.
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
#include <utility> #include <utility>
#include "ash/content/content_gpu_support.h" #include "ash/content/content_gpu_interface_provider.h"
#include "ash/display/display_prefs.h" #include "ash/display/display_prefs.h"
#include "ash/shell.h" #include "ash/shell.h"
#include "ash/shell_init_params.h" #include "ash/shell_init_params.h"
...@@ -26,7 +26,8 @@ void CreateClassicShell() { ...@@ -26,7 +26,8 @@ void CreateClassicShell() {
shell_init_params.context_factory = content::GetContextFactory(); shell_init_params.context_factory = content::GetContextFactory();
shell_init_params.context_factory_private = shell_init_params.context_factory_private =
content::GetContextFactoryPrivate(); content::GetContextFactoryPrivate();
shell_init_params.gpu_support = std::make_unique<ash::ContentGpuSupport>(); shell_init_params.gpu_interface_provider =
std::make_unique<ash::ContentGpuInterfaceProvider>();
// Pass the initial display prefs to ash::Shell as a Value dictionary. // Pass the initial display prefs to ash::Shell as a Value dictionary.
// This is done this way to avoid complexities with registering the display // This is done this way to avoid complexities with registering the display
// prefs in multiple places (i.e. in g_browser_process->local_state() and // prefs in multiple places (i.e. in g_browser_process->local_state() and
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#include <memory> #include <memory>
#include <utility> #include <utility>
#include "ash/content/content_gpu_support.h" #include "ash/content/content_gpu_interface_provider.h"
#include "ash/session/test_session_controller_client.h" #include "ash/session/test_session_controller_client.h"
#include "ash/shell.h" #include "ash/shell.h"
#include "ash/shell_init_params.h" #include "ash/shell_init_params.h"
...@@ -69,7 +69,8 @@ ViewEventTestPlatformPartChromeOS::ViewEventTestPlatformPartChromeOS( ...@@ -69,7 +69,8 @@ ViewEventTestPlatformPartChromeOS::ViewEventTestPlatformPartChromeOS(
init_params.delegate = std::make_unique<ash::TestShellDelegate>(); init_params.delegate = std::make_unique<ash::TestShellDelegate>();
init_params.context_factory = context_factory; init_params.context_factory = context_factory;
init_params.context_factory_private = context_factory_private; init_params.context_factory_private = context_factory_private;
init_params.gpu_support = std::make_unique<ash::ContentGpuSupport>(); init_params.gpu_interface_provider =
std::make_unique<ash::ContentGpuInterfaceProvider>();
base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
switches::kHostWindowBounds, "0+0-1280x800"); switches::kHostWindowBounds, "0+0-1280x800");
ash::Shell::CreateInstance(std::move(init_params)); ash::Shell::CreateInstance(std::move(init_params));
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
#include "services/service_manager/public/cpp/service_context.h" #include "services/service_manager/public/cpp/service_context.h"
#include "services/service_manager/public/cpp/service_runner.h" #include "services/service_manager/public/cpp/service_runner.h"
#include "services/ui/public/interfaces/window_tree_host_factory.mojom.h" #include "services/ui/public/interfaces/window_tree_host_factory.mojom.h"
#include "services/ui/ws2/gpu_support.h" #include "services/ui/ws2/gpu_interface_provider.h"
#include "services/ui/ws2/window_service.h" #include "services/ui/ws2/window_service.h"
#include "services/ui/ws2/window_service_delegate.h" #include "services/ui/ws2/window_service_delegate.h"
#include "services/ui/ws2/window_tree.h" #include "services/ui/ws2/window_tree.h"
......
...@@ -15,7 +15,7 @@ component("lib") { ...@@ -15,7 +15,7 @@ component("lib") {
":test_support", ":test_support",
] ]
public = [ public = [
"gpu_support.h", "gpu_interface_provider.h",
"ids.h", "ids.h",
"window_delegate_impl.h", "window_delegate_impl.h",
"window_properties.h", "window_properties.h",
......
// 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 SERVICES_UI_WS2_GPU_INTERFACE_PROVIDER_H_
#define SERVICES_UI_WS2_GPU_INTERFACE_PROVIDER_H_
#include "base/component_export.h"
#include "services/service_manager/public/cpp/binder_registry.h"
namespace ui {
namespace ws2 {
// GpuInterfaceProvider is responsible for providing the Gpu related interfaces.
// The implementation of these varies depending upon where the WindowService is
// hosted.
class COMPONENT_EXPORT(WINDOW_SERVICE) GpuInterfaceProvider {
public:
virtual ~GpuInterfaceProvider() {}
// Registers the gpu-related interfaces, specifically
// discardable_memory::mojom::DiscardableSharedMemoryManagerRequest and
// ui::mojom::GpuRequest.
virtual void RegisterGpuInterfaces(
service_manager::BinderRegistry* registry) = 0;
};
} // namespace ws2
} // namespace ui
#endif // SERVICES_UI_WS2_GPU_INTERFACE_PROVIDER_H_
// 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 SERVICES_UI_WS2_GPU_SUPPORT_H_
#define SERVICES_UI_WS2_GPU_SUPPORT_H_
#include "base/component_export.h"
#include "base/memory/scoped_refptr.h"
#include "components/discardable_memory/public/interfaces/discardable_shared_memory_manager.mojom.h"
#include "services/ui/public/interfaces/gpu.mojom.h"
namespace base {
class SingleThreadTaskRunner;
}
namespace ui {
namespace ws2 {
// GpuSupport provides the functions needed for gpu related functionality. It is
// expected this class is bound to functions in content that do this. Once Viz
// moves out of content, this class can be removed.
class COMPONENT_EXPORT(WINDOW_SERVICE) GpuSupport {
public:
virtual ~GpuSupport() {}
// Returns the task runner used to bind gpu related interfaces on. This is
// typically the io-thread.
virtual scoped_refptr<base::SingleThreadTaskRunner> GetGpuTaskRunner() = 0;
// The Bind functions are called when a client requests a gpu related
// interface.
virtual void BindDiscardableSharedMemoryManagerOnGpuTaskRunner(
discardable_memory::mojom::DiscardableSharedMemoryManagerRequest
request) = 0;
virtual void BindGpuRequestOnGpuTaskRunner(ui::mojom::GpuRequest request) = 0;
};
} // namespace ws2
} // namespace ui
#endif // SERVICES_UI_WS2_GPU_SUPPORT_H_
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/single_thread_task_runner.h" #include "base/single_thread_task_runner.h"
#include "services/ui/ws2/gpu_support.h" #include "services/ui/ws2/gpu_interface_provider.h"
#include "services/ui/ws2/screen_provider.h" #include "services/ui/ws2/screen_provider.h"
#include "services/ui/ws2/server_window.h" #include "services/ui/ws2/server_window.h"
#include "services/ui/ws2/window_service_delegate.h" #include "services/ui/ws2/window_service_delegate.h"
...@@ -18,11 +18,12 @@ ...@@ -18,11 +18,12 @@
namespace ui { namespace ui {
namespace ws2 { namespace ws2 {
WindowService::WindowService(WindowServiceDelegate* delegate, WindowService::WindowService(
std::unique_ptr<GpuSupport> gpu_support, WindowServiceDelegate* delegate,
aura::client::FocusClient* focus_client) std::unique_ptr<GpuInterfaceProvider> gpu_interface_provider,
aura::client::FocusClient* focus_client)
: delegate_(delegate), : delegate_(delegate),
gpu_support_(std::move(gpu_support)), gpu_interface_provider_(std::move(gpu_interface_provider)),
screen_provider_(std::make_unique<ScreenProvider>()), screen_provider_(std::make_unique<ScreenProvider>()),
focus_client_(focus_client), focus_client_(focus_client),
ime_registrar_(&ime_driver_) { ime_registrar_(&ime_driver_) {
...@@ -99,18 +100,9 @@ void WindowService::OnStart() { ...@@ -99,18 +100,9 @@ void WindowService::OnStart() {
registry_.AddInterface(base::BindRepeating( registry_.AddInterface(base::BindRepeating(
&WindowService::BindWindowTreeFactoryRequest, base::Unretained(this))); &WindowService::BindWindowTreeFactoryRequest, base::Unretained(this)));
// |gpu_support_| may be null in tests. // |gpu_interface_provider_| may be null in tests.
if (gpu_support_) { if (gpu_interface_provider_)
registry_.AddInterface( gpu_interface_provider_->RegisterGpuInterfaces(&registry_);
base::BindRepeating(
&GpuSupport::BindDiscardableSharedMemoryManagerOnGpuTaskRunner,
base::Unretained(gpu_support_.get())),
gpu_support_->GetGpuTaskRunner());
registry_.AddInterface(
base::BindRepeating(&GpuSupport::BindGpuRequestOnGpuTaskRunner,
base::Unretained(gpu_support_.get())),
gpu_support_->GetGpuTaskRunner());
}
} }
void WindowService::OnBindInterface( void WindowService::OnBindInterface(
......
...@@ -43,7 +43,7 @@ class WindowTreeClient; ...@@ -43,7 +43,7 @@ class WindowTreeClient;
namespace ws2 { namespace ws2 {
class GpuSupport; class GpuInterfaceProvider;
class ScreenProvider; class ScreenProvider;
class ServerWindow; class ServerWindow;
class WindowServiceDelegate; class WindowServiceDelegate;
...@@ -57,7 +57,7 @@ class COMPONENT_EXPORT(WINDOW_SERVICE) WindowService ...@@ -57,7 +57,7 @@ class COMPONENT_EXPORT(WINDOW_SERVICE) WindowService
: public service_manager::Service { : public service_manager::Service {
public: public:
WindowService(WindowServiceDelegate* delegate, WindowService(WindowServiceDelegate* delegate,
std::unique_ptr<GpuSupport> gpu_support, std::unique_ptr<GpuInterfaceProvider> gpu_support,
aura::client::FocusClient* focus_client); aura::client::FocusClient* focus_client);
~WindowService() override; ~WindowService() override;
...@@ -108,8 +108,8 @@ class COMPONENT_EXPORT(WINDOW_SERVICE) WindowService ...@@ -108,8 +108,8 @@ class COMPONENT_EXPORT(WINDOW_SERVICE) WindowService
WindowServiceDelegate* delegate_; WindowServiceDelegate* delegate_;
// GpuSupport may be null in tests. // GpuInterfaceProvider may be null in tests.
std::unique_ptr<GpuSupport> gpu_support_; std::unique_ptr<GpuInterfaceProvider> gpu_interface_provider_;
std::unique_ptr<ScreenProvider> screen_provider_; std::unique_ptr<ScreenProvider> screen_provider_;
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#include "services/ui/ws2/window_service_test_setup.h" #include "services/ui/ws2/window_service_test_setup.h"
#include "services/ui/ws2/embedding.h" #include "services/ui/ws2/embedding.h"
#include "services/ui/ws2/gpu_support.h" #include "services/ui/ws2/gpu_interface_provider.h"
#include "services/ui/ws2/window_service.h" #include "services/ui/ws2/window_service.h"
#include "services/ui/ws2/window_tree.h" #include "services/ui/ws2/window_tree.h"
#include "services/ui/ws2/window_tree_binding.h" #include "services/ui/ws2/window_tree_binding.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