Move ash/mash/viz stuff to ServiceBinding
Migrates a bunch of stuff related to either ash, mash, or viz, over to ServiceBinding instead of the deprecated ServiceContext/EmbeddedServiceInfo etc APIs. Bug: 891780 Change-Id: Ia5313525013cd75c845b04f7ff6550a2880553f6 Reviewed-on: https://chromium-review.googlesource.com/c/1355981 Commit-Queue: Ken Rockot <rockot@google.com> Reviewed-by: Scott Violet <sky@chromium.org> Cr-Commit-Position: refs/heads/master@{#612589}
This commit is contained in:
ash
components
shortcut_viewer
tap_visualizer
shell
content
client
ws
chrome/utility
content
shell
browser
utility
utility
mash
catalog_viewer
example
views_examples
window_type_launcher
session
task_viewer
services
video_capture
viz
ws
ui/views/mus
@@ -10,14 +10,14 @@
|
|||||||
#include "base/time/time.h"
|
#include "base/time/time.h"
|
||||||
#include "base/trace_event/trace_event.h"
|
#include "base/trace_event/trace_event.h"
|
||||||
#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 "ui/events/devices/input_device_manager.h"
|
#include "ui/events/devices/input_device_manager.h"
|
||||||
#include "ui/views/mus/aura_init.h"
|
#include "ui/views/mus/aura_init.h"
|
||||||
|
|
||||||
namespace keyboard_shortcut_viewer {
|
namespace keyboard_shortcut_viewer {
|
||||||
|
|
||||||
ShortcutViewerApplication::ShortcutViewerApplication()
|
ShortcutViewerApplication::ShortcutViewerApplication(
|
||||||
: shortcut_viewer_binding_(this) {
|
service_manager::mojom::ServiceRequest request)
|
||||||
|
: service_binding_(this, std::move(request)) {
|
||||||
registry_.AddInterface<shortcut_viewer::mojom::ShortcutViewer>(
|
registry_.AddInterface<shortcut_viewer::mojom::ShortcutViewer>(
|
||||||
base::BindRepeating(&ShortcutViewerApplication::AddBinding,
|
base::BindRepeating(&ShortcutViewerApplication::AddBinding,
|
||||||
base::Unretained(this)));
|
base::Unretained(this)));
|
||||||
@@ -32,13 +32,13 @@ void ShortcutViewerApplication::RegisterForTraceEvents() {
|
|||||||
|
|
||||||
void ShortcutViewerApplication::OnStart() {
|
void ShortcutViewerApplication::OnStart() {
|
||||||
views::AuraInit::InitParams params;
|
views::AuraInit::InitParams params;
|
||||||
params.connector = context()->connector();
|
params.connector = service_binding_.GetConnector();
|
||||||
params.identity = context()->identity();
|
params.identity = service_binding_.identity();
|
||||||
params.register_path_provider = false;
|
params.register_path_provider = false;
|
||||||
params.use_accessibility_host = true;
|
params.use_accessibility_host = true;
|
||||||
aura_init_ = views::AuraInit::Create(params);
|
aura_init_ = views::AuraInit::Create(params);
|
||||||
if (!aura_init_) {
|
if (!aura_init_) {
|
||||||
context()->QuitNow();
|
Terminate();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,8 +46,9 @@ void ShortcutViewerApplication::OnStart() {
|
|||||||
ash::ash_client::Init();
|
ash::ash_client::Init();
|
||||||
|
|
||||||
// Quit the application when the window is closed.
|
// Quit the application when the window is closed.
|
||||||
last_window_closed_observer_ = std::make_unique<LastWindowClosedObserver>(
|
last_window_closed_observer_ =
|
||||||
context()->CreateQuitClosure());
|
std::make_unique<LastWindowClosedObserver>(base::BindRepeating(
|
||||||
|
&ShortcutViewerApplication::Terminate, base::Unretained(this)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShortcutViewerApplication::OnBindInterface(
|
void ShortcutViewerApplication::OnBindInterface(
|
||||||
|
@@ -13,6 +13,8 @@
|
|||||||
#include "mojo/public/cpp/bindings/binding.h"
|
#include "mojo/public/cpp/bindings/binding.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/cpp/service_binding.h"
|
||||||
|
#include "services/service_manager/public/mojom/service.mojom.h"
|
||||||
#include "ui/events/devices/input_device_event_observer.h"
|
#include "ui/events/devices/input_device_event_observer.h"
|
||||||
|
|
||||||
namespace views {
|
namespace views {
|
||||||
@@ -29,7 +31,8 @@ class ShortcutViewerApplication
|
|||||||
public ui::InputDeviceEventObserver,
|
public ui::InputDeviceEventObserver,
|
||||||
public shortcut_viewer::mojom::ShortcutViewer {
|
public shortcut_viewer::mojom::ShortcutViewer {
|
||||||
public:
|
public:
|
||||||
ShortcutViewerApplication();
|
explicit ShortcutViewerApplication(
|
||||||
|
service_manager::mojom::ServiceRequest request);
|
||||||
~ShortcutViewerApplication() override;
|
~ShortcutViewerApplication() override;
|
||||||
|
|
||||||
// Records a single trace event for shortcut viewer. chrome://tracing doesn't
|
// Records a single trace event for shortcut viewer. chrome://tracing doesn't
|
||||||
@@ -52,13 +55,15 @@ class ShortcutViewerApplication
|
|||||||
|
|
||||||
void AddBinding(shortcut_viewer::mojom::ShortcutViewerRequest request);
|
void AddBinding(shortcut_viewer::mojom::ShortcutViewerRequest request);
|
||||||
|
|
||||||
|
service_manager::ServiceBinding service_binding_;
|
||||||
|
|
||||||
std::unique_ptr<views::AuraInit> aura_init_;
|
std::unique_ptr<views::AuraInit> aura_init_;
|
||||||
std::unique_ptr<LastWindowClosedObserver> last_window_closed_observer_;
|
std::unique_ptr<LastWindowClosedObserver> last_window_closed_observer_;
|
||||||
|
|
||||||
service_manager::BinderRegistry registry_;
|
service_manager::BinderRegistry registry_;
|
||||||
|
|
||||||
mojo::Binding<shortcut_viewer::mojom::ShortcutViewer>
|
mojo::Binding<shortcut_viewer::mojom::ShortcutViewer>
|
||||||
shortcut_viewer_binding_;
|
shortcut_viewer_binding_{this};
|
||||||
|
|
||||||
// Timestamp of the user gesture (e.g. Ctrl-Shift-/ keystroke) that triggered
|
// Timestamp of the user gesture (e.g. Ctrl-Shift-/ keystroke) that triggered
|
||||||
// showing the window. Used for metrics.
|
// showing the window. Used for metrics.
|
||||||
|
@@ -10,7 +10,6 @@
|
|||||||
#include "ash/public/cpp/shell_window_ids.h"
|
#include "ash/public/cpp/shell_window_ids.h"
|
||||||
#include "base/macros.h"
|
#include "base/macros.h"
|
||||||
#include "base/strings/utf_string_conversions.h"
|
#include "base/strings/utf_string_conversions.h"
|
||||||
#include "services/service_manager/public/cpp/service_context.h"
|
|
||||||
#include "services/ws/public/cpp/property_type_converters.h"
|
#include "services/ws/public/cpp/property_type_converters.h"
|
||||||
#include "services/ws/public/mojom/window_manager.mojom.h"
|
#include "services/ws/public/mojom/window_manager.mojom.h"
|
||||||
#include "services/ws/public/mojom/window_tree_constants.mojom.h"
|
#include "services/ws/public/mojom/window_tree_constants.mojom.h"
|
||||||
@@ -24,7 +23,9 @@
|
|||||||
|
|
||||||
namespace tap_visualizer {
|
namespace tap_visualizer {
|
||||||
|
|
||||||
TapVisualizerApp::TapVisualizerApp() = default;
|
TapVisualizerApp::TapVisualizerApp(
|
||||||
|
service_manager::mojom::ServiceRequest request)
|
||||||
|
: service_binding_(this, std::move(request)) {}
|
||||||
|
|
||||||
TapVisualizerApp::~TapVisualizerApp() {
|
TapVisualizerApp::~TapVisualizerApp() {
|
||||||
display::Screen::GetScreen()->RemoveObserver(this);
|
display::Screen::GetScreen()->RemoveObserver(this);
|
||||||
@@ -46,12 +47,12 @@ void TapVisualizerApp::Start() {
|
|||||||
|
|
||||||
void TapVisualizerApp::OnStart() {
|
void TapVisualizerApp::OnStart() {
|
||||||
views::AuraInit::InitParams params;
|
views::AuraInit::InitParams params;
|
||||||
params.connector = context()->connector();
|
params.connector = service_binding_.GetConnector();
|
||||||
params.identity = context()->identity();
|
params.identity = service_binding_.identity();
|
||||||
params.register_path_provider = false;
|
params.register_path_provider = false;
|
||||||
aura_init_ = views::AuraInit::Create(params);
|
aura_init_ = views::AuraInit::Create(params);
|
||||||
if (!aura_init_) {
|
if (!aura_init_) {
|
||||||
context()->QuitNow();
|
Terminate();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Start();
|
Start();
|
||||||
|
@@ -12,6 +12,8 @@
|
|||||||
|
|
||||||
#include "base/macros.h"
|
#include "base/macros.h"
|
||||||
#include "services/service_manager/public/cpp/service.h"
|
#include "services/service_manager/public/cpp/service.h"
|
||||||
|
#include "services/service_manager/public/cpp/service_binding.h"
|
||||||
|
#include "services/service_manager/public/mojom/service.mojom.h"
|
||||||
#include "ui/display/display_observer.h"
|
#include "ui/display/display_observer.h"
|
||||||
#include "ui/events/event_observer.h"
|
#include "ui/events/event_observer.h"
|
||||||
|
|
||||||
@@ -29,7 +31,8 @@ class TapVisualizerApp : public service_manager::Service,
|
|||||||
public ui::EventObserver,
|
public ui::EventObserver,
|
||||||
public display::DisplayObserver {
|
public display::DisplayObserver {
|
||||||
public:
|
public:
|
||||||
TapVisualizerApp();
|
explicit TapVisualizerApp(service_manager::mojom::ServiceRequest request);
|
||||||
|
|
||||||
~TapVisualizerApp() override;
|
~TapVisualizerApp() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -51,6 +54,8 @@ class TapVisualizerApp : public service_manager::Service,
|
|||||||
// Creates the touch HUD widget for a display.
|
// Creates the touch HUD widget for a display.
|
||||||
void CreateWidgetForDisplay(int64_t display_id);
|
void CreateWidgetForDisplay(int64_t display_id);
|
||||||
|
|
||||||
|
service_manager::ServiceBinding service_binding_;
|
||||||
|
|
||||||
// Maps display::Display::id() to the renderer for that display.
|
// Maps display::Display::id() to the renderer for that display.
|
||||||
std::map<int64_t, std::unique_ptr<TapRenderer>> display_id_to_renderer_;
|
std::map<int64_t, std::unique_ptr<TapRenderer>> display_id_to_renderer_;
|
||||||
|
|
||||||
|
@@ -81,7 +81,7 @@ class TapVisualizerAppTest : public aura::test::AuraTestBase {
|
|||||||
|
|
||||||
TEST_F(TapVisualizerAppTest, Basics) {
|
TEST_F(TapVisualizerAppTest, Basics) {
|
||||||
// Simulate the service starting.
|
// Simulate the service starting.
|
||||||
TapVisualizerApp app;
|
TapVisualizerApp app(nullptr);
|
||||||
TapVisualizerAppTestApi test_api(&app);
|
TapVisualizerAppTestApi test_api(&app);
|
||||||
test_api.Start();
|
test_api.Start();
|
||||||
|
|
||||||
@@ -111,7 +111,7 @@ TEST_F(TapVisualizerAppTest, MultiDisplay) {
|
|||||||
display::DisplayList::Type::NOT_PRIMARY);
|
display::DisplayList::Type::NOT_PRIMARY);
|
||||||
|
|
||||||
// Simulate the service starting.
|
// Simulate the service starting.
|
||||||
TapVisualizerApp app;
|
TapVisualizerApp app(nullptr);
|
||||||
TapVisualizerAppTestApi test_api(&app);
|
TapVisualizerAppTestApi test_api(&app);
|
||||||
test_api.Start();
|
test_api.Start();
|
||||||
|
|
||||||
|
@@ -33,15 +33,17 @@ std::unique_ptr<service_manager::Service> CreateQuickLaunch(
|
|||||||
std::move(request));
|
std::move(request));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<service_manager::Service> CreateShortcutViewer() {
|
std::unique_ptr<service_manager::Service> CreateShortcutViewer(
|
||||||
|
service_manager::mojom::ServiceRequest request) {
|
||||||
logging::SetLogPrefix("shortcut");
|
logging::SetLogPrefix("shortcut");
|
||||||
return std::make_unique<
|
return std::make_unique<keyboard_shortcut_viewer::ShortcutViewerApplication>(
|
||||||
keyboard_shortcut_viewer::ShortcutViewerApplication>();
|
std::move(request));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<service_manager::Service> CreateTapVisualizer() {
|
std::unique_ptr<service_manager::Service> CreateTapVisualizer(
|
||||||
|
service_manager::mojom::ServiceRequest request) {
|
||||||
logging::SetLogPrefix("tap");
|
logging::SetLogPrefix("tap");
|
||||||
return std::make_unique<tap_visualizer::TapVisualizerApp>();
|
return std::make_unique<tap_visualizer::TapVisualizerApp>(std::move(request));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<service_manager::Service> CreateTestImeDriver(
|
std::unique_ptr<service_manager::Service> CreateTestImeDriver(
|
||||||
@@ -55,19 +57,6 @@ class ShellContentUtilityClient : public content::ContentUtilityClient {
|
|||||||
~ShellContentUtilityClient() override = default;
|
~ShellContentUtilityClient() override = default;
|
||||||
|
|
||||||
// ContentUtilityClient:
|
// ContentUtilityClient:
|
||||||
void RegisterServices(StaticServiceMap* services) override {
|
|
||||||
{
|
|
||||||
service_manager::EmbeddedServiceInfo info;
|
|
||||||
info.factory = base::BindRepeating(&CreateShortcutViewer);
|
|
||||||
(*services)[shortcut_viewer::mojom::kServiceName] = info;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
service_manager::EmbeddedServiceInfo info;
|
|
||||||
info.factory = base::BindRepeating(&CreateTapVisualizer);
|
|
||||||
(*services)[tap_visualizer::mojom::kServiceName] = info;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unique_ptr<service_manager::Service> HandleServiceRequest(
|
std::unique_ptr<service_manager::Service> HandleServiceRequest(
|
||||||
const std::string& service_name,
|
const std::string& service_name,
|
||||||
service_manager::mojom::ServiceRequest request) override {
|
service_manager::mojom::ServiceRequest request) override {
|
||||||
@@ -75,6 +64,10 @@ class ShellContentUtilityClient : public content::ContentUtilityClient {
|
|||||||
return CreateQuickLaunch(std::move(request));
|
return CreateQuickLaunch(std::move(request));
|
||||||
if (service_name == test_ime_driver::mojom::kServiceName)
|
if (service_name == test_ime_driver::mojom::kServiceName)
|
||||||
return CreateTestImeDriver(std::move(request));
|
return CreateTestImeDriver(std::move(request));
|
||||||
|
if (service_name == shortcut_viewer::mojom::kServiceName)
|
||||||
|
return CreateShortcutViewer(std::move(request));
|
||||||
|
if (service_name == tap_visualizer::mojom::kServiceName)
|
||||||
|
return CreateTapVisualizer(std::move(request));
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@@ -13,9 +13,7 @@
|
|||||||
#include "base/lazy_instance.h"
|
#include "base/lazy_instance.h"
|
||||||
#include "base/unguessable_token.h"
|
#include "base/unguessable_token.h"
|
||||||
#include "services/content/public/cpp/buildflags.h"
|
#include "services/content/public/cpp/buildflags.h"
|
||||||
#include "services/service_manager/public/cpp/service_context.h"
|
|
||||||
#include "services/ws/public/cpp/host/gpu_interface_provider.h"
|
#include "services/ws/public/cpp/host/gpu_interface_provider.h"
|
||||||
#include "services/ws/window_service.h"
|
|
||||||
#include "ui/base/ui_base_features.h"
|
#include "ui/base/ui_base_features.h"
|
||||||
#include "ui/display/display.h"
|
#include "ui/display/display.h"
|
||||||
#include "ui/display/screen.h"
|
#include "ui/display/screen.h"
|
||||||
@@ -65,23 +63,21 @@ class ServerRemoteContentViewManager
|
|||||||
WindowServiceOwner::WindowServiceOwner(
|
WindowServiceOwner::WindowServiceOwner(
|
||||||
std::unique_ptr<ws::GpuInterfaceProvider> gpu_interface_provider)
|
std::unique_ptr<ws::GpuInterfaceProvider> gpu_interface_provider)
|
||||||
: window_service_delegate_(std::make_unique<WindowServiceDelegateImpl>()),
|
: window_service_delegate_(std::make_unique<WindowServiceDelegateImpl>()),
|
||||||
owned_window_service_(
|
window_service_(window_service_delegate_.get(),
|
||||||
std::make_unique<ws::WindowService>(window_service_delegate_.get(),
|
std::move(gpu_interface_provider),
|
||||||
std::move(gpu_interface_provider),
|
Shell::Get()->focus_controller(),
|
||||||
Shell::Get()->focus_controller(),
|
!::features::IsMultiProcessMash(),
|
||||||
!::features::IsMultiProcessMash(),
|
Shell::Get()->aura_env()) {
|
||||||
Shell::Get()->aura_env())),
|
window_service_.SetFrameDecorationValues(
|
||||||
window_service_(owned_window_service_.get()) {
|
|
||||||
window_service_->SetFrameDecorationValues(
|
|
||||||
NonClientFrameController::GetPreferredClientAreaInsets(),
|
NonClientFrameController::GetPreferredClientAreaInsets(),
|
||||||
NonClientFrameController::GetMaxTitleBarButtonWidth());
|
NonClientFrameController::GetMaxTitleBarButtonWidth());
|
||||||
window_service_->SetDisplayForNewWindows(
|
window_service_.SetDisplayForNewWindows(
|
||||||
display::Screen::GetScreen()->GetDisplayForNewWindows().id());
|
display::Screen::GetScreen()->GetDisplayForNewWindows().id());
|
||||||
RegisterWindowProperties(window_service_->property_converter());
|
RegisterWindowProperties(window_service_.property_converter());
|
||||||
|
|
||||||
#if BUILDFLAG(ENABLE_REMOTE_NAVIGABLE_CONTENTS_VIEW)
|
#if BUILDFLAG(ENABLE_REMOTE_NAVIGABLE_CONTENTS_VIEW)
|
||||||
content::NavigableContentsView::SetRemoteViewManager(
|
content::NavigableContentsView::SetRemoteViewManager(
|
||||||
std::make_unique<ServerRemoteContentViewManager>(window_service_));
|
std::make_unique<ServerRemoteContentViewManager>(&window_service_));
|
||||||
#endif // BUILDFLAG(ENABLE_REMOTE_NAVIGABLE_CONTENTS_VIEW)
|
#endif // BUILDFLAG(ENABLE_REMOTE_NAVIGABLE_CONTENTS_VIEW)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,13 +85,7 @@ WindowServiceOwner::~WindowServiceOwner() = default;
|
|||||||
|
|
||||||
void WindowServiceOwner::BindWindowService(
|
void WindowServiceOwner::BindWindowService(
|
||||||
service_manager::mojom::ServiceRequest request) {
|
service_manager::mojom::ServiceRequest request) {
|
||||||
// This should only be called once. If called more than once it means the
|
window_service_.BindServiceRequest(std::move(request));
|
||||||
// WindowService lost its connection to the service_manager, which triggered
|
|
||||||
// a new WindowService to be created. That should never happen.
|
|
||||||
DCHECK(!service_context_);
|
|
||||||
|
|
||||||
service_context_ = std::make_unique<service_manager::ServiceContext>(
|
|
||||||
std::move(owned_window_service_), std::move(request));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace ash
|
} // namespace ash
|
||||||
|
@@ -11,14 +11,10 @@
|
|||||||
#include "ash/shell_init_params.h"
|
#include "ash/shell_init_params.h"
|
||||||
#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"
|
||||||
|
#include "services/ws/window_service.h"
|
||||||
namespace service_manager {
|
|
||||||
class ServiceContext;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace ws {
|
namespace ws {
|
||||||
class GpuInterfaceProvider;
|
class GpuInterfaceProvider;
|
||||||
class WindowService;
|
|
||||||
} // namespace ws
|
} // namespace ws
|
||||||
|
|
||||||
namespace ash {
|
namespace ash {
|
||||||
@@ -38,22 +34,13 @@ class ASH_EXPORT WindowServiceOwner {
|
|||||||
// WindowService.
|
// WindowService.
|
||||||
void BindWindowService(service_manager::mojom::ServiceRequest request);
|
void BindWindowService(service_manager::mojom::ServiceRequest request);
|
||||||
|
|
||||||
ws::WindowService* window_service() { return window_service_; }
|
ws::WindowService* window_service() { return &window_service_; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class AshTestHelper;
|
friend class AshTestHelper;
|
||||||
|
|
||||||
std::unique_ptr<WindowServiceDelegateImpl> window_service_delegate_;
|
std::unique_ptr<WindowServiceDelegateImpl> window_service_delegate_;
|
||||||
|
ws::WindowService window_service_;
|
||||||
// Handles the ServiceRequest. Owns |window_service_|.
|
|
||||||
std::unique_ptr<service_manager::ServiceContext> service_context_;
|
|
||||||
|
|
||||||
// The WindowService. The constructor creates the WindowService and assigns
|
|
||||||
// it to |owned_window_service_| and |window_service_|. When
|
|
||||||
// BindWindowService() is called |owned_window_service_| is passed to
|
|
||||||
// |service_context_|.
|
|
||||||
std::unique_ptr<ws::WindowService> owned_window_service_;
|
|
||||||
ws::WindowService* window_service_;
|
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(WindowServiceOwner);
|
DISALLOW_COPY_AND_ASSIGN(WindowServiceOwner);
|
||||||
};
|
};
|
||||||
|
2
chrome/utility/OWNERS
Normal file
2
chrome/utility/OWNERS
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
# For service-related code
|
||||||
|
per-file chrome_content_utility_client.*=rockot@google.com
|
@@ -290,11 +290,6 @@ void ChromeContentUtilityClient::RegisterServices(
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(OS_CHROMEOS)
|
|
||||||
// TODO(jamescook): Figure out why we have to do this when not using mash.
|
|
||||||
mash_service_factory_->RegisterOutOfProcessServices(services);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if BUILDFLAG(ENABLE_SIMPLE_BROWSER_SERVICE_OUT_OF_PROCESS)
|
#if BUILDFLAG(ENABLE_SIMPLE_BROWSER_SERVICE_OUT_OF_PROCESS)
|
||||||
{
|
{
|
||||||
service_manager::EmbeddedServiceInfo service_info;
|
service_manager::EmbeddedServiceInfo service_info;
|
||||||
|
@@ -35,17 +35,6 @@ enum class MashService {
|
|||||||
kMaxValue = kFontDeprecated,
|
kMaxValue = kFontDeprecated,
|
||||||
};
|
};
|
||||||
|
|
||||||
using ServiceFactoryFunction = std::unique_ptr<service_manager::Service>();
|
|
||||||
|
|
||||||
void RegisterMashService(
|
|
||||||
content::ContentUtilityClient::StaticServiceMap* services,
|
|
||||||
const std::string& name,
|
|
||||||
ServiceFactoryFunction factory_function) {
|
|
||||||
service_manager::EmbeddedServiceInfo service_info;
|
|
||||||
service_info.factory = base::BindRepeating(factory_function);
|
|
||||||
services->emplace(name, 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);
|
||||||
@@ -66,17 +55,19 @@ std::unique_ptr<service_manager::Service> CreateQuickLaunchService(
|
|||||||
std::move(request));
|
std::move(request));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<service_manager::Service> CreateShortcutViewerApp() {
|
std::unique_ptr<service_manager::Service> CreateShortcutViewerApp(
|
||||||
|
service_manager::mojom::ServiceRequest request) {
|
||||||
RecordMashServiceLaunch(MashService::kShortcutViewer);
|
RecordMashServiceLaunch(MashService::kShortcutViewer);
|
||||||
logging::SetLogPrefix("shortcut");
|
logging::SetLogPrefix("shortcut");
|
||||||
return std::make_unique<
|
return std::make_unique<keyboard_shortcut_viewer::ShortcutViewerApplication>(
|
||||||
keyboard_shortcut_viewer::ShortcutViewerApplication>();
|
std::move(request));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<service_manager::Service> CreateTapVisualizerApp() {
|
std::unique_ptr<service_manager::Service> CreateTapVisualizerApp(
|
||||||
|
service_manager::mojom::ServiceRequest request) {
|
||||||
RecordMashServiceLaunch(MashService::kTapVisualizer);
|
RecordMashServiceLaunch(MashService::kTapVisualizer);
|
||||||
logging::SetLogPrefix("tap");
|
logging::SetLogPrefix("tap");
|
||||||
return std::make_unique<tap_visualizer::TapVisualizerApp>();
|
return std::make_unique<tap_visualizer::TapVisualizerApp>(std::move(request));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
@@ -85,16 +76,6 @@ MashServiceFactory::MashServiceFactory() = default;
|
|||||||
|
|
||||||
MashServiceFactory::~MashServiceFactory() = default;
|
MashServiceFactory::~MashServiceFactory() = default;
|
||||||
|
|
||||||
void MashServiceFactory::RegisterOutOfProcessServices(
|
|
||||||
content::ContentUtilityClient::StaticServiceMap* services) {
|
|
||||||
RegisterMashService(services, shortcut_viewer::mojom::kServiceName,
|
|
||||||
&CreateShortcutViewerApp);
|
|
||||||
RegisterMashService(services, tap_visualizer::mojom::kServiceName,
|
|
||||||
&CreateTapVisualizerApp);
|
|
||||||
|
|
||||||
keyboard_shortcut_viewer::ShortcutViewerApplication::RegisterForTraceEvents();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unique_ptr<service_manager::Service>
|
std::unique_ptr<service_manager::Service>
|
||||||
MashServiceFactory::HandleServiceRequest(
|
MashServiceFactory::HandleServiceRequest(
|
||||||
const std::string& service_name,
|
const std::string& service_name,
|
||||||
@@ -103,6 +84,13 @@ MashServiceFactory::HandleServiceRequest(
|
|||||||
return CreateAshService(std::move(request));
|
return CreateAshService(std::move(request));
|
||||||
if (service_name == quick_launch::mojom::kServiceName)
|
if (service_name == quick_launch::mojom::kServiceName)
|
||||||
return CreateQuickLaunchService(std::move(request));
|
return CreateQuickLaunchService(std::move(request));
|
||||||
|
if (service_name == shortcut_viewer::mojom::kServiceName) {
|
||||||
|
keyboard_shortcut_viewer::ShortcutViewerApplication ::
|
||||||
|
RegisterForTraceEvents();
|
||||||
|
return CreateShortcutViewerApp(std::move(request));
|
||||||
|
}
|
||||||
|
if (service_name == tap_visualizer::mojom::kServiceName)
|
||||||
|
return CreateTapVisualizerApp(std::move(request));
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@@ -18,10 +18,6 @@ class MashServiceFactory {
|
|||||||
MashServiceFactory();
|
MashServiceFactory();
|
||||||
~MashServiceFactory();
|
~MashServiceFactory();
|
||||||
|
|
||||||
// Registers out-of-process services for mash.
|
|
||||||
void RegisterOutOfProcessServices(
|
|
||||||
content::ContentUtilityClient::StaticServiceMap* services);
|
|
||||||
|
|
||||||
// Handles an incoming service request for this utility process. Returns
|
// Handles an incoming service request for this utility process. Returns
|
||||||
// null if the named service is unknown or cannot be created.
|
// null if the named service is unknown or cannot be created.
|
||||||
std::unique_ptr<service_manager::Service> HandleServiceRequest(
|
std::unique_ptr<service_manager::Service> HandleServiceRequest(
|
||||||
|
@@ -194,24 +194,6 @@ void ShellContentBrowserClient::BindInterfaceRequestFromFrame(
|
|||||||
render_frame_host);
|
render_frame_host);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShellContentBrowserClient::RegisterInProcessServices(
|
|
||||||
StaticServiceMap* services,
|
|
||||||
content::ServiceManagerConnection* connection) {
|
|
||||||
#if defined(OS_CHROMEOS)
|
|
||||||
if (features::IsSingleProcessMash()) {
|
|
||||||
service_manager::EmbeddedServiceInfo info;
|
|
||||||
info.factory =
|
|
||||||
base::BindRepeating([]() -> std::unique_ptr<service_manager::Service> {
|
|
||||||
return ws::test::CreateInProcessWindowService(
|
|
||||||
GetContextFactory(), GetContextFactoryPrivate(),
|
|
||||||
CreateGpuInterfaceProvider());
|
|
||||||
});
|
|
||||||
info.task_runner = base::ThreadTaskRunnerHandle::Get();
|
|
||||||
services->insert(std::make_pair(test_ws::mojom::kServiceName, info));
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void ShellContentBrowserClient::RegisterOutOfProcessServices(
|
void ShellContentBrowserClient::RegisterOutOfProcessServices(
|
||||||
OutOfProcessServiceMap* services) {
|
OutOfProcessServiceMap* services) {
|
||||||
(*services)[kTestServiceUrl] =
|
(*services)[kTestServiceUrl] =
|
||||||
@@ -235,6 +217,16 @@ void ShellContentBrowserClient::HandleServiceRequest(
|
|||||||
media::CreateMediaServiceForTesting(std::move(request)));
|
media::CreateMediaServiceForTesting(std::move(request)));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(OS_CHROMEOS)
|
||||||
|
if (features::IsSingleProcessMash() &&
|
||||||
|
service_name == test_ws::mojom::kServiceName) {
|
||||||
|
service_manager::Service::RunAsyncUntilTermination(
|
||||||
|
ws::test::CreateInProcessWindowService(
|
||||||
|
GetContextFactory(), GetContextFactoryPrivate(),
|
||||||
|
CreateGpuInterfaceProvider(), std::move(request)));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ShellContentBrowserClient::ShouldTerminateOnServiceQuit(
|
bool ShellContentBrowserClient::ShouldTerminateOnServiceQuit(
|
||||||
|
@@ -38,8 +38,6 @@ class ShellContentBrowserClient : public ContentBrowserClient {
|
|||||||
content::RenderFrameHost* render_frame_host,
|
content::RenderFrameHost* render_frame_host,
|
||||||
const std::string& interface_name,
|
const std::string& interface_name,
|
||||||
mojo::ScopedMessagePipeHandle interface_pipe) override;
|
mojo::ScopedMessagePipeHandle interface_pipe) override;
|
||||||
void RegisterInProcessServices(StaticServiceMap* services,
|
|
||||||
ServiceManagerConnection* connection) override;
|
|
||||||
void RegisterOutOfProcessServices(OutOfProcessServiceMap* services) override;
|
void RegisterOutOfProcessServices(OutOfProcessServiceMap* services) override;
|
||||||
void HandleServiceRequest(
|
void HandleServiceRequest(
|
||||||
const std::string& service_name,
|
const std::string& service_name,
|
||||||
|
@@ -130,15 +130,20 @@ void ShellContentUtilityClient::RegisterServices(StaticServiceMap* services) {
|
|||||||
info.factory = base::BindRepeating(&echo::CreateEchoService);
|
info.factory = base::BindRepeating(&echo::CreateEchoService);
|
||||||
services->insert(std::make_pair(echo::mojom::kServiceName, info));
|
services->insert(std::make_pair(echo::mojom::kServiceName, info));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::unique_ptr<service_manager::Service>
|
||||||
|
ShellContentUtilityClient::HandleServiceRequest(
|
||||||
|
const std::string& service_name,
|
||||||
|
service_manager::mojom::ServiceRequest request) {
|
||||||
#if defined(OS_CHROMEOS)
|
#if defined(OS_CHROMEOS)
|
||||||
if (features::IsMultiProcessMash()) {
|
if (features::IsMultiProcessMash() &&
|
||||||
service_manager::EmbeddedServiceInfo info;
|
service_name == test_ws::mojom::kServiceName) {
|
||||||
info.factory =
|
return ws::test::CreateOutOfProcessWindowService(std::move(request));
|
||||||
base::BindRepeating(&ws::test::CreateOutOfProcessWindowService);
|
|
||||||
services->insert(std::make_pair(test_ws::mojom::kServiceName, info));
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShellContentUtilityClient::RegisterNetworkBinders(
|
void ShellContentUtilityClient::RegisterNetworkBinders(
|
||||||
|
@@ -20,6 +20,9 @@ class ShellContentUtilityClient : public ContentUtilityClient {
|
|||||||
// ContentUtilityClient:
|
// ContentUtilityClient:
|
||||||
void UtilityThreadStarted() override;
|
void UtilityThreadStarted() override;
|
||||||
void RegisterServices(StaticServiceMap* services) override;
|
void RegisterServices(StaticServiceMap* services) override;
|
||||||
|
std::unique_ptr<service_manager::Service> HandleServiceRequest(
|
||||||
|
const std::string& service_name,
|
||||||
|
service_manager::mojom::ServiceRequest request) override;
|
||||||
void RegisterNetworkBinders(
|
void RegisterNetworkBinders(
|
||||||
service_manager::BinderRegistry* registry) override;
|
service_manager::BinderRegistry* registry) override;
|
||||||
void RegisterAudioBinders(service_manager::BinderRegistry* registry) override;
|
void RegisterAudioBinders(service_manager::BinderRegistry* registry) override;
|
||||||
|
@@ -1,3 +1,6 @@
|
|||||||
# Mac Sandbox profiles.
|
# Mac Sandbox profiles.
|
||||||
per-file *.sb=set noparent
|
per-file *.sb=set noparent
|
||||||
per-file *.sb=rsesek@chromium.org
|
per-file *.sb=rsesek@chromium.org
|
||||||
|
|
||||||
|
# For service-related code
|
||||||
|
per-file utility_service_factory.*=rockot@google.com
|
||||||
|
@@ -109,10 +109,6 @@ class ContentCdmServiceClient final : public media::CdmService::Client {
|
|||||||
|
|
||||||
#endif // BUILDFLAG(ENABLE_LIBRARY_CDMS)
|
#endif // BUILDFLAG(ENABLE_LIBRARY_CDMS)
|
||||||
|
|
||||||
std::unique_ptr<service_manager::Service> CreateVizService() {
|
|
||||||
return std::make_unique<viz::Service>();
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
UtilityServiceFactory::UtilityServiceFactory()
|
UtilityServiceFactory::UtilityServiceFactory()
|
||||||
@@ -153,10 +149,6 @@ void UtilityServiceFactory::RegisterServices(ServiceMap* services) {
|
|||||||
}
|
}
|
||||||
#endif // BUILDFLAG(ENABLE_CROS_LIBASSISTANT)
|
#endif // BUILDFLAG(ENABLE_CROS_LIBASSISTANT)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
service_manager::EmbeddedServiceInfo viz_info;
|
|
||||||
viz_info.factory = base::Bind(&CreateVizService);
|
|
||||||
services->insert(std::make_pair(viz::mojom::kVizServiceName, viz_info));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UtilityServiceFactory::HandleServiceRequest(
|
bool UtilityServiceFactory::HandleServiceRequest(
|
||||||
@@ -183,6 +175,8 @@ bool UtilityServiceFactory::HandleServiceRequest(
|
|||||||
} else if (name == video_capture::mojom::kServiceName) {
|
} else if (name == video_capture::mojom::kServiceName) {
|
||||||
running_service_ =
|
running_service_ =
|
||||||
std::make_unique<video_capture::ServiceImpl>(std::move(request));
|
std::make_unique<video_capture::ServiceImpl>(std::move(request));
|
||||||
|
} else if (name == viz::mojom::kVizServiceName) {
|
||||||
|
running_service_ = std::make_unique<viz::Service>(std::move(request));
|
||||||
}
|
}
|
||||||
#if BUILDFLAG(ENABLE_LIBRARY_CDMS)
|
#if BUILDFLAG(ENABLE_LIBRARY_CDMS)
|
||||||
else if (name == media::mojom::kCdmServiceName) {
|
else if (name == media::mojom::kCdmServiceName) {
|
||||||
|
@@ -3,9 +3,9 @@
|
|||||||
# found in the LICENSE file.
|
# found in the LICENSE file.
|
||||||
|
|
||||||
import("//build/config/ui.gni")
|
import("//build/config/ui.gni")
|
||||||
|
import("//mojo/public/tools/bindings/mojom.gni")
|
||||||
import("//services/service_manager/public/cpp/service.gni")
|
import("//services/service_manager/public/cpp/service.gni")
|
||||||
import("//services/service_manager/public/service_manifest.gni")
|
import("//services/service_manager/public/service_manifest.gni")
|
||||||
import("//mojo/public/tools/bindings/mojom.gni")
|
|
||||||
|
|
||||||
source_set("lib") {
|
source_set("lib") {
|
||||||
sources = [
|
sources = [
|
||||||
@@ -27,6 +27,7 @@ source_set("lib") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
service("catalog_viewer") {
|
service("catalog_viewer") {
|
||||||
|
use_cpp_main = true
|
||||||
sources = [
|
sources = [
|
||||||
"main.cc",
|
"main.cc",
|
||||||
]
|
]
|
||||||
|
@@ -207,7 +207,8 @@ class CatalogViewerContents : public views::WidgetDelegateView,
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
CatalogViewer::CatalogViewer() {
|
CatalogViewer::CatalogViewer(service_manager::mojom::ServiceRequest request)
|
||||||
|
: service_binding_(this, std::move(request)) {
|
||||||
registry_.AddInterface<mojom::Launchable>(
|
registry_.AddInterface<mojom::Launchable>(
|
||||||
base::Bind(&CatalogViewer::Create, base::Unretained(this)));
|
base::Bind(&CatalogViewer::Create, base::Unretained(this)));
|
||||||
}
|
}
|
||||||
@@ -218,16 +219,16 @@ void CatalogViewer::RemoveWindow(views::Widget* window) {
|
|||||||
DCHECK(it != windows_.end());
|
DCHECK(it != windows_.end());
|
||||||
windows_.erase(it);
|
windows_.erase(it);
|
||||||
if (windows_.empty())
|
if (windows_.empty())
|
||||||
context()->QuitNow();
|
Terminate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CatalogViewer::OnStart() {
|
void CatalogViewer::OnStart() {
|
||||||
views::AuraInit::InitParams params;
|
views::AuraInit::InitParams params;
|
||||||
params.connector = context()->connector();
|
params.connector = service_binding_.GetConnector();
|
||||||
params.identity = context()->identity();
|
params.identity = service_binding_.identity();
|
||||||
aura_init_ = views::AuraInit::Create(params);
|
aura_init_ = views::AuraInit::Create(params);
|
||||||
if (!aura_init_)
|
if (!aura_init_)
|
||||||
context()->QuitNow();
|
Terminate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CatalogViewer::OnBindInterface(
|
void CatalogViewer::OnBindInterface(
|
||||||
@@ -245,7 +246,8 @@ void CatalogViewer::Launch(uint32_t what, mojom::LaunchMode how) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
catalog::mojom::CatalogPtr catalog;
|
catalog::mojom::CatalogPtr catalog;
|
||||||
context()->connector()->BindInterface(catalog::mojom::kServiceName, &catalog);
|
service_binding_.GetConnector()->BindInterface(catalog::mojom::kServiceName,
|
||||||
|
&catalog);
|
||||||
|
|
||||||
views::Widget* window = views::Widget::CreateWindowWithContextAndBounds(
|
views::Widget* window = views::Widget::CreateWindowWithContextAndBounds(
|
||||||
new CatalogViewerContents(this, std::move(catalog)), nullptr,
|
new CatalogViewerContents(this, std::move(catalog)), nullptr,
|
||||||
|
@@ -14,6 +14,8 @@
|
|||||||
#include "mojo/public/cpp/bindings/binding_set.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/cpp/service_binding.h"
|
||||||
|
#include "services/service_manager/public/mojom/service.mojom.h"
|
||||||
|
|
||||||
namespace views {
|
namespace views {
|
||||||
class AuraInit;
|
class AuraInit;
|
||||||
@@ -26,7 +28,7 @@ namespace catalog_viewer {
|
|||||||
class CatalogViewer : public service_manager::Service,
|
class CatalogViewer : public service_manager::Service,
|
||||||
public mojom::Launchable {
|
public mojom::Launchable {
|
||||||
public:
|
public:
|
||||||
CatalogViewer();
|
explicit CatalogViewer(service_manager::mojom::ServiceRequest request);
|
||||||
~CatalogViewer() override;
|
~CatalogViewer() override;
|
||||||
|
|
||||||
void RemoveWindow(views::Widget* window);
|
void RemoveWindow(views::Widget* window);
|
||||||
@@ -43,6 +45,7 @@ class CatalogViewer : public service_manager::Service,
|
|||||||
|
|
||||||
void Create(mojom::LaunchableRequest request);
|
void Create(mojom::LaunchableRequest request);
|
||||||
|
|
||||||
|
service_manager::ServiceBinding service_binding_;
|
||||||
mojo::BindingSet<mojom::Launchable> bindings_;
|
mojo::BindingSet<mojom::Launchable> bindings_;
|
||||||
std::vector<views::Widget*> windows_;
|
std::vector<views::Widget*> windows_;
|
||||||
|
|
||||||
|
@@ -2,12 +2,11 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
#include "base/message_loop/message_loop.h"
|
||||||
#include "mash/catalog_viewer/catalog_viewer.h"
|
#include "mash/catalog_viewer/catalog_viewer.h"
|
||||||
#include "services/service_manager/public/c/main.h"
|
#include "services/service_manager/public/cpp/standalone_service/service_main.h"
|
||||||
#include "services/service_manager/public/cpp/service_runner.h"
|
|
||||||
|
|
||||||
MojoResult ServiceMain(MojoHandle service_request_handle) {
|
void ServiceMain(service_manager::mojom::ServiceRequest request) {
|
||||||
service_manager::ServiceRunner runner(
|
base::MessageLoop message_loop;
|
||||||
new mash::catalog_viewer::CatalogViewer);
|
mash::catalog_viewer::CatalogViewer(std::move(request)).RunUntilTermination();
|
||||||
return runner.Run(service_request_handle);
|
|
||||||
}
|
}
|
||||||
|
@@ -3,14 +3,14 @@
|
|||||||
# found in the LICENSE file.
|
# found in the LICENSE file.
|
||||||
|
|
||||||
import("//build/config/ui.gni")
|
import("//build/config/ui.gni")
|
||||||
|
import("//mojo/public/tools/bindings/mojom.gni")
|
||||||
import("//services/service_manager/public/cpp/service.gni")
|
import("//services/service_manager/public/cpp/service.gni")
|
||||||
import("//services/service_manager/public/service_manifest.gni")
|
import("//services/service_manager/public/service_manifest.gni")
|
||||||
import("//mojo/public/tools/bindings/mojom.gni")
|
|
||||||
import("//tools/grit/repack.gni")
|
import("//tools/grit/repack.gni")
|
||||||
|
|
||||||
service("views_examples") {
|
service("views_examples") {
|
||||||
testonly = true
|
testonly = true
|
||||||
|
use_cpp_main = true
|
||||||
sources = [
|
sources = [
|
||||||
"views_examples.cc",
|
"views_examples.cc",
|
||||||
]
|
]
|
||||||
|
@@ -7,14 +7,15 @@
|
|||||||
|
|
||||||
#include "base/macros.h"
|
#include "base/macros.h"
|
||||||
#include "base/memory/ptr_util.h"
|
#include "base/memory/ptr_util.h"
|
||||||
|
#include "base/message_loop/message_loop.h"
|
||||||
#include "mash/public/mojom/launchable.mojom.h"
|
#include "mash/public/mojom/launchable.mojom.h"
|
||||||
#include "mojo/public/cpp/bindings/binding_set.h"
|
#include "mojo/public/cpp/bindings/binding_set.h"
|
||||||
#include "services/service_manager/public/c/main.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/connector.h"
|
#include "services/service_manager/public/cpp/connector.h"
|
||||||
#include "services/service_manager/public/cpp/service.h"
|
#include "services/service_manager/public/cpp/service.h"
|
||||||
#include "services/service_manager/public/cpp/service_context.h"
|
#include "services/service_manager/public/cpp/service_binding.h"
|
||||||
#include "services/service_manager/public/cpp/service_runner.h"
|
#include "services/service_manager/public/cpp/standalone_service/service_main.h"
|
||||||
|
#include "services/service_manager/public/mojom/service.mojom.h"
|
||||||
#include "ui/views/examples/example_base.h"
|
#include "ui/views/examples/example_base.h"
|
||||||
#include "ui/views/examples/examples_window.h"
|
#include "ui/views/examples/examples_window.h"
|
||||||
#include "ui/views/mus/aura_init.h"
|
#include "ui/views/mus/aura_init.h"
|
||||||
@@ -22,7 +23,8 @@
|
|||||||
class ViewsExamples : public service_manager::Service,
|
class ViewsExamples : public service_manager::Service,
|
||||||
public mash::mojom::Launchable {
|
public mash::mojom::Launchable {
|
||||||
public:
|
public:
|
||||||
ViewsExamples() {
|
explicit ViewsExamples(service_manager::mojom::ServiceRequest request)
|
||||||
|
: service_binding_(this, std::move(request)) {
|
||||||
registry_.AddInterface<mash::mojom::Launchable>(
|
registry_.AddInterface<mash::mojom::Launchable>(
|
||||||
base::Bind(&ViewsExamples::Create, base::Unretained(this)));
|
base::Bind(&ViewsExamples::Create, base::Unretained(this)));
|
||||||
}
|
}
|
||||||
@@ -32,11 +34,11 @@ class ViewsExamples : public service_manager::Service,
|
|||||||
// service_manager::Service:
|
// service_manager::Service:
|
||||||
void OnStart() override {
|
void OnStart() override {
|
||||||
views::AuraInit::InitParams params;
|
views::AuraInit::InitParams params;
|
||||||
params.connector = context()->connector();
|
params.connector = service_binding_.GetConnector();
|
||||||
params.identity = context()->identity();
|
params.identity = service_binding_.identity();
|
||||||
aura_init_ = views::AuraInit::Create(params);
|
aura_init_ = views::AuraInit::Create(params);
|
||||||
if (!aura_init_)
|
if (!aura_init_)
|
||||||
context()->QuitNow();
|
Terminate();
|
||||||
}
|
}
|
||||||
void OnBindInterface(const service_manager::BindSourceInfo& source_info,
|
void OnBindInterface(const service_manager::BindSourceInfo& source_info,
|
||||||
const std::string& interface_name,
|
const std::string& interface_name,
|
||||||
@@ -47,14 +49,14 @@ class ViewsExamples : public service_manager::Service,
|
|||||||
// mash::mojom::Launchable:
|
// mash::mojom::Launchable:
|
||||||
void Launch(uint32_t what, mash::mojom::LaunchMode how) override {
|
void Launch(uint32_t what, mash::mojom::LaunchMode how) override {
|
||||||
views::examples::ShowExamplesWindow(
|
views::examples::ShowExamplesWindow(
|
||||||
base::BindOnce(&service_manager::ServiceContext::QuitNow,
|
base::BindOnce(&ViewsExamples::Terminate, base::Unretained(this)));
|
||||||
base::Unretained(context())));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Create(mash::mojom::LaunchableRequest request) {
|
void Create(mash::mojom::LaunchableRequest request) {
|
||||||
bindings_.AddBinding(this, std::move(request));
|
bindings_.AddBinding(this, std::move(request));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
service_manager::ServiceBinding service_binding_;
|
||||||
mojo::BindingSet<mash::mojom::Launchable> bindings_;
|
mojo::BindingSet<mash::mojom::Launchable> bindings_;
|
||||||
|
|
||||||
service_manager::BinderRegistry registry_;
|
service_manager::BinderRegistry registry_;
|
||||||
@@ -64,7 +66,7 @@ class ViewsExamples : public service_manager::Service,
|
|||||||
DISALLOW_COPY_AND_ASSIGN(ViewsExamples);
|
DISALLOW_COPY_AND_ASSIGN(ViewsExamples);
|
||||||
};
|
};
|
||||||
|
|
||||||
MojoResult ServiceMain(MojoHandle service_request_handle) {
|
void ServiceMain(service_manager::mojom::ServiceRequest request) {
|
||||||
return service_manager::ServiceRunner(new ViewsExamples)
|
base::MessageLoop message_loop;
|
||||||
.Run(service_request_handle);
|
ViewsExamples(std::move(request)).RunUntilTermination();
|
||||||
}
|
}
|
||||||
|
@@ -3,14 +3,14 @@
|
|||||||
# found in the LICENSE file.
|
# found in the LICENSE file.
|
||||||
|
|
||||||
import("//build/config/ui.gni")
|
import("//build/config/ui.gni")
|
||||||
|
import("//mojo/public/tools/bindings/mojom.gni")
|
||||||
import("//services/service_manager/public/cpp/service.gni")
|
import("//services/service_manager/public/cpp/service.gni")
|
||||||
import("//services/service_manager/public/service_manifest.gni")
|
import("//services/service_manager/public/service_manifest.gni")
|
||||||
import("//mojo/public/tools/bindings/mojom.gni")
|
|
||||||
import("//tools/grit/repack.gni")
|
import("//tools/grit/repack.gni")
|
||||||
|
|
||||||
service("window_type_launcher") {
|
service("window_type_launcher") {
|
||||||
testonly = true
|
testonly = true
|
||||||
|
use_cpp_main = true
|
||||||
sources = [
|
sources = [
|
||||||
"window_type_launcher.cc",
|
"window_type_launcher.cc",
|
||||||
"window_type_launcher.h",
|
"window_type_launcher.h",
|
||||||
|
@@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#include "base/macros.h"
|
#include "base/macros.h"
|
||||||
#include "base/memory/ptr_util.h"
|
#include "base/memory/ptr_util.h"
|
||||||
|
#include "base/message_loop/message_loop.h"
|
||||||
#include "base/run_loop.h"
|
#include "base/run_loop.h"
|
||||||
#include "base/strings/string_number_conversions.h"
|
#include "base/strings/string_number_conversions.h"
|
||||||
#include "base/strings/utf_string_conversions.h"
|
#include "base/strings/utf_string_conversions.h"
|
||||||
@@ -15,8 +16,7 @@
|
|||||||
#include "services/service_manager/public/c/main.h"
|
#include "services/service_manager/public/c/main.h"
|
||||||
#include "services/service_manager/public/cpp/connector.h"
|
#include "services/service_manager/public/cpp/connector.h"
|
||||||
#include "services/service_manager/public/cpp/service.h"
|
#include "services/service_manager/public/cpp/service.h"
|
||||||
#include "services/service_manager/public/cpp/service_context.h"
|
#include "services/service_manager/public/cpp/standalone_service/service_main.h"
|
||||||
#include "services/service_manager/public/cpp/service_runner.h"
|
|
||||||
#include "services/ws/public/cpp/property_type_converters.h"
|
#include "services/ws/public/cpp/property_type_converters.h"
|
||||||
#include "services/ws/public/mojom/window_manager.mojom.h"
|
#include "services/ws/public/mojom/window_manager.mojom.h"
|
||||||
#include "ui/aura/window.h"
|
#include "ui/aura/window.h"
|
||||||
@@ -438,7 +438,9 @@ class WindowTypeLauncherView : public views::WidgetDelegateView,
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
WindowTypeLauncher::WindowTypeLauncher() {
|
WindowTypeLauncher::WindowTypeLauncher(
|
||||||
|
service_manager::mojom::ServiceRequest request)
|
||||||
|
: service_binding_(this, std::move(request)) {
|
||||||
registry_.AddInterface<mash::mojom::Launchable>(
|
registry_.AddInterface<mash::mojom::Launchable>(
|
||||||
base::Bind(&WindowTypeLauncher::Create, base::Unretained(this)));
|
base::Bind(&WindowTypeLauncher::Create, base::Unretained(this)));
|
||||||
}
|
}
|
||||||
@@ -449,16 +451,16 @@ void WindowTypeLauncher::RemoveWindow(views::Widget* window) {
|
|||||||
DCHECK(it != windows_.end());
|
DCHECK(it != windows_.end());
|
||||||
windows_.erase(it);
|
windows_.erase(it);
|
||||||
if (windows_.empty())
|
if (windows_.empty())
|
||||||
context()->QuitNow();
|
Terminate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowTypeLauncher::OnStart() {
|
void WindowTypeLauncher::OnStart() {
|
||||||
views::AuraInit::InitParams params;
|
views::AuraInit::InitParams params;
|
||||||
params.connector = context()->connector();
|
params.connector = service_binding_.GetConnector();
|
||||||
params.identity = context()->identity();
|
params.identity = service_binding_.identity();
|
||||||
aura_init_ = views::AuraInit::Create(params);
|
aura_init_ = views::AuraInit::Create(params);
|
||||||
if (!aura_init_)
|
if (!aura_init_)
|
||||||
context()->QuitNow();
|
Terminate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowTypeLauncher::OnBindInterface(
|
void WindowTypeLauncher::OnBindInterface(
|
||||||
@@ -477,7 +479,8 @@ void WindowTypeLauncher::Launch(uint32_t what, mash::mojom::LaunchMode how) {
|
|||||||
}
|
}
|
||||||
views::Widget* window = new views::Widget;
|
views::Widget* window = new views::Widget;
|
||||||
views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
|
views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
|
||||||
params.delegate = new WindowTypeLauncherView(this, context()->connector());
|
params.delegate =
|
||||||
|
new WindowTypeLauncherView(this, service_binding_.GetConnector());
|
||||||
window->Init(params);
|
window->Init(params);
|
||||||
window->Show();
|
window->Show();
|
||||||
windows_.push_back(window);
|
windows_.push_back(window);
|
||||||
@@ -487,7 +490,7 @@ void WindowTypeLauncher::Create(mash::mojom::LaunchableRequest request) {
|
|||||||
bindings_.AddBinding(this, std::move(request));
|
bindings_.AddBinding(this, std::move(request));
|
||||||
}
|
}
|
||||||
|
|
||||||
MojoResult ServiceMain(MojoHandle service_request_handle) {
|
void ServiceMain(service_manager::mojom::ServiceRequest request) {
|
||||||
return service_manager::ServiceRunner(new WindowTypeLauncher)
|
base::MessageLoop message_loop;
|
||||||
.Run(service_request_handle);
|
WindowTypeLauncher(std::move(request)).RunUntilTermination();
|
||||||
}
|
}
|
||||||
|
@@ -12,6 +12,8 @@
|
|||||||
#include "mojo/public/cpp/bindings/binding_set.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/cpp/service_binding.h"
|
||||||
|
#include "services/service_manager/public/mojom/service.mojom.h"
|
||||||
|
|
||||||
namespace views {
|
namespace views {
|
||||||
class AuraInit;
|
class AuraInit;
|
||||||
@@ -21,7 +23,7 @@ class Widget;
|
|||||||
class WindowTypeLauncher : public service_manager::Service,
|
class WindowTypeLauncher : public service_manager::Service,
|
||||||
public mash::mojom::Launchable {
|
public mash::mojom::Launchable {
|
||||||
public:
|
public:
|
||||||
WindowTypeLauncher();
|
explicit WindowTypeLauncher(service_manager::mojom::ServiceRequest request);
|
||||||
~WindowTypeLauncher() override;
|
~WindowTypeLauncher() override;
|
||||||
|
|
||||||
void RemoveWindow(views::Widget* window);
|
void RemoveWindow(views::Widget* window);
|
||||||
@@ -38,6 +40,7 @@ class WindowTypeLauncher : public service_manager::Service,
|
|||||||
|
|
||||||
void Create(mash::mojom::LaunchableRequest request);
|
void Create(mash::mojom::LaunchableRequest request);
|
||||||
|
|
||||||
|
service_manager::ServiceBinding service_binding_;
|
||||||
mojo::BindingSet<mash::mojom::Launchable> bindings_;
|
mojo::BindingSet<mash::mojom::Launchable> bindings_;
|
||||||
std::vector<views::Widget*> windows_;
|
std::vector<views::Widget*> windows_;
|
||||||
|
|
||||||
|
@@ -3,9 +3,9 @@
|
|||||||
# found in the LICENSE file.
|
# found in the LICENSE file.
|
||||||
|
|
||||||
import("//build/config/ui.gni")
|
import("//build/config/ui.gni")
|
||||||
|
import("//mojo/public/tools/bindings/mojom.gni")
|
||||||
import("//services/service_manager/public/cpp/service.gni")
|
import("//services/service_manager/public/cpp/service.gni")
|
||||||
import("//services/service_manager/public/service_manifest.gni")
|
import("//services/service_manager/public/service_manifest.gni")
|
||||||
import("//mojo/public/tools/bindings/mojom.gni")
|
|
||||||
import("//tools/grit/repack.gni")
|
import("//tools/grit/repack.gni")
|
||||||
|
|
||||||
source_set("lib") {
|
source_set("lib") {
|
||||||
@@ -33,7 +33,7 @@ source_set("lib") {
|
|||||||
|
|
||||||
service("session") {
|
service("session") {
|
||||||
output_name = "mash_session"
|
output_name = "mash_session"
|
||||||
|
use_cpp_main = true
|
||||||
sources = [
|
sources = [
|
||||||
"main.cc",
|
"main.cc",
|
||||||
]
|
]
|
||||||
|
@@ -2,11 +2,11 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
#include "base/message_loop/message_loop.h"
|
||||||
#include "mash/session/session.h"
|
#include "mash/session/session.h"
|
||||||
#include "services/service_manager/public/c/main.h"
|
#include "services/service_manager/public/cpp/standalone_service/service_main.h"
|
||||||
#include "services/service_manager/public/cpp/service_runner.h"
|
|
||||||
|
|
||||||
MojoResult ServiceMain(MojoHandle service_request_handle) {
|
void ServiceMain(service_manager::mojom::ServiceRequest request) {
|
||||||
service_manager::ServiceRunner runner(new mash::session::Session);
|
base::MessageLoop message_loop;
|
||||||
return runner.Run(service_request_handle);
|
mash::session::Session(std::move(request)).RunUntilTermination();
|
||||||
}
|
}
|
||||||
|
@@ -8,7 +8,6 @@
|
|||||||
#include "base/command_line.h"
|
#include "base/command_line.h"
|
||||||
#include "mash/common/config.h"
|
#include "mash/common/config.h"
|
||||||
#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"
|
|
||||||
|
|
||||||
#if defined(OS_CHROMEOS)
|
#if defined(OS_CHROMEOS)
|
||||||
#include "ash/components/quick_launch/public/mojom/constants.mojom.h" // nogncheck
|
#include "ash/components/quick_launch/public/mojom/constants.mojom.h" // nogncheck
|
||||||
@@ -17,7 +16,9 @@
|
|||||||
namespace mash {
|
namespace mash {
|
||||||
namespace session {
|
namespace session {
|
||||||
|
|
||||||
Session::Session() = default;
|
Session::Session(service_manager::mojom::ServiceRequest request)
|
||||||
|
: service_binding_(this, std::move(request)) {}
|
||||||
|
|
||||||
Session::~Session() = default;
|
Session::~Session() = default;
|
||||||
|
|
||||||
void Session::OnStart() {
|
void Session::OnStart() {
|
||||||
@@ -29,8 +30,9 @@ void Session::OnStart() {
|
|||||||
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
|
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
|
||||||
quick_launch::mojom::kServiceName)) {
|
quick_launch::mojom::kServiceName)) {
|
||||||
// TODO(https://crbug.com/904148): This should not use |WarmService()|.
|
// TODO(https://crbug.com/904148): This should not use |WarmService()|.
|
||||||
context()->connector()->WarmService(service_manager::ServiceFilter::ByName(
|
service_binding_.GetConnector()->WarmService(
|
||||||
quick_launch::mojom::kServiceName));
|
service_manager::ServiceFilter::ByName(
|
||||||
|
quick_launch::mojom::kServiceName));
|
||||||
}
|
}
|
||||||
#endif // defined(OS_CHROMEOS)
|
#endif // defined(OS_CHROMEOS)
|
||||||
}
|
}
|
||||||
@@ -38,8 +40,9 @@ void Session::OnStart() {
|
|||||||
void Session::StartWindowManager() {
|
void Session::StartWindowManager() {
|
||||||
// TODO(beng): monitor this service for death & bring down the whole system
|
// TODO(beng): monitor this service for death & bring down the whole system
|
||||||
// if necessary.
|
// if necessary.
|
||||||
context()->connector()->WarmService(service_manager::ServiceFilter::ByName(
|
service_binding_.GetConnector()->WarmService(
|
||||||
common::GetWindowManagerServiceName()));
|
service_manager::ServiceFilter::ByName(
|
||||||
|
common::GetWindowManagerServiceName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace session
|
} // namespace session
|
||||||
|
@@ -7,13 +7,15 @@
|
|||||||
|
|
||||||
#include "base/macros.h"
|
#include "base/macros.h"
|
||||||
#include "services/service_manager/public/cpp/service.h"
|
#include "services/service_manager/public/cpp/service.h"
|
||||||
|
#include "services/service_manager/public/cpp/service_binding.h"
|
||||||
|
#include "services/service_manager/public/mojom/service.mojom.h"
|
||||||
|
|
||||||
namespace mash {
|
namespace mash {
|
||||||
namespace session {
|
namespace session {
|
||||||
|
|
||||||
class Session : public service_manager::Service {
|
class Session : public service_manager::Service {
|
||||||
public:
|
public:
|
||||||
Session();
|
explicit Session(service_manager::mojom::ServiceRequest request);
|
||||||
~Session() override;
|
~Session() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -22,6 +24,8 @@ class Session : public service_manager::Service {
|
|||||||
|
|
||||||
void StartWindowManager();
|
void StartWindowManager();
|
||||||
|
|
||||||
|
service_manager::ServiceBinding service_binding_;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(Session);
|
DISALLOW_COPY_AND_ASSIGN(Session);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -3,9 +3,9 @@
|
|||||||
# found in the LICENSE file.
|
# found in the LICENSE file.
|
||||||
|
|
||||||
import("//build/config/ui.gni")
|
import("//build/config/ui.gni")
|
||||||
|
import("//mojo/public/tools/bindings/mojom.gni")
|
||||||
import("//services/service_manager/public/cpp/service.gni")
|
import("//services/service_manager/public/cpp/service.gni")
|
||||||
import("//services/service_manager/public/service_manifest.gni")
|
import("//services/service_manager/public/service_manifest.gni")
|
||||||
import("//mojo/public/tools/bindings/mojom.gni")
|
|
||||||
|
|
||||||
source_set("lib") {
|
source_set("lib") {
|
||||||
sources = [
|
sources = [
|
||||||
@@ -27,6 +27,7 @@ source_set("lib") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
service("task_viewer") {
|
service("task_viewer") {
|
||||||
|
use_cpp_main = true
|
||||||
sources = [
|
sources = [
|
||||||
"main.cc",
|
"main.cc",
|
||||||
]
|
]
|
||||||
|
@@ -2,11 +2,11 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
#include "base/message_loop/message_loop.h"
|
||||||
#include "mash/task_viewer/task_viewer.h"
|
#include "mash/task_viewer/task_viewer.h"
|
||||||
#include "services/service_manager/public/c/main.h"
|
#include "services/service_manager/public/cpp/standalone_service/service_main.h"
|
||||||
#include "services/service_manager/public/cpp/service_runner.h"
|
|
||||||
|
|
||||||
MojoResult ServiceMain(MojoHandle service_request_handle) {
|
void ServiceMain(service_manager::mojom::ServiceRequest request) {
|
||||||
service_manager::ServiceRunner runner(new mash::task_viewer::TaskViewer);
|
base::MessageLoop message_loop;
|
||||||
return runner.Run(service_request_handle);
|
mash::task_viewer::TaskViewer(std::move(request)).RunUntilTermination();
|
||||||
}
|
}
|
||||||
|
@@ -20,7 +20,6 @@
|
|||||||
#include "services/catalog/public/mojom/catalog.mojom.h"
|
#include "services/catalog/public/mojom/catalog.mojom.h"
|
||||||
#include "services/catalog/public/mojom/constants.mojom.h"
|
#include "services/catalog/public/mojom/constants.mojom.h"
|
||||||
#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/mojom/constants.mojom.h"
|
#include "services/service_manager/public/mojom/constants.mojom.h"
|
||||||
#include "services/service_manager/public/mojom/service_manager.mojom.h"
|
#include "services/service_manager/public/mojom/service_manager.mojom.h"
|
||||||
#include "ui/base/models/table_model.h"
|
#include "ui/base/models/table_model.h"
|
||||||
@@ -282,10 +281,12 @@ class TaskViewerContents
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
TaskViewer::TaskViewer() {
|
TaskViewer::TaskViewer(service_manager::mojom::ServiceRequest request)
|
||||||
|
: service_binding_(this, std::move(request)) {
|
||||||
registry_.AddInterface<::mash::mojom::Launchable>(
|
registry_.AddInterface<::mash::mojom::Launchable>(
|
||||||
base::Bind(&TaskViewer::Create, base::Unretained(this)));
|
base::Bind(&TaskViewer::Create, base::Unretained(this)));
|
||||||
}
|
}
|
||||||
|
|
||||||
TaskViewer::~TaskViewer() = default;
|
TaskViewer::~TaskViewer() = default;
|
||||||
|
|
||||||
void TaskViewer::RemoveWindow(views::Widget* widget) {
|
void TaskViewer::RemoveWindow(views::Widget* widget) {
|
||||||
@@ -293,16 +294,16 @@ void TaskViewer::RemoveWindow(views::Widget* widget) {
|
|||||||
DCHECK(it != windows_.end());
|
DCHECK(it != windows_.end());
|
||||||
windows_.erase(it);
|
windows_.erase(it);
|
||||||
if (windows_.empty())
|
if (windows_.empty())
|
||||||
context()->QuitNow();
|
Terminate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskViewer::OnStart() {
|
void TaskViewer::OnStart() {
|
||||||
views::AuraInit::InitParams params;
|
views::AuraInit::InitParams params;
|
||||||
params.connector = context()->connector();
|
params.connector = service_binding_.GetConnector();
|
||||||
params.identity = context()->identity();
|
params.identity = service_binding_.identity();
|
||||||
aura_init_ = views::AuraInit::Create(params);
|
aura_init_ = views::AuraInit::Create(params);
|
||||||
if (!aura_init_)
|
if (!aura_init_)
|
||||||
context()->QuitNow();
|
Terminate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskViewer::OnBindInterface(
|
void TaskViewer::OnBindInterface(
|
||||||
@@ -321,11 +322,12 @@ void TaskViewer::Launch(uint32_t what, mojom::LaunchMode how) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
service_manager::mojom::ServiceManagerPtr service_manager;
|
service_manager::mojom::ServiceManagerPtr service_manager;
|
||||||
context()->connector()->BindInterface(service_manager::mojom::kServiceName,
|
service_binding_.GetConnector()->BindInterface(
|
||||||
&service_manager);
|
service_manager::mojom::kServiceName, &service_manager);
|
||||||
|
|
||||||
catalog::mojom::CatalogPtr catalog;
|
catalog::mojom::CatalogPtr catalog;
|
||||||
context()->connector()->BindInterface(catalog::mojom::kServiceName, &catalog);
|
service_binding_.GetConnector()->BindInterface(catalog::mojom::kServiceName,
|
||||||
|
&catalog);
|
||||||
|
|
||||||
service_manager::mojom::ServiceManagerListenerPtr listener;
|
service_manager::mojom::ServiceManagerListenerPtr listener;
|
||||||
TaskViewerContents* task_viewer = new TaskViewerContents(
|
TaskViewerContents* task_viewer = new TaskViewerContents(
|
||||||
|
@@ -14,6 +14,8 @@
|
|||||||
#include "mojo/public/cpp/bindings/binding_set.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/cpp/service_binding.h"
|
||||||
|
#include "services/service_manager/public/mojom/service.mojom.h"
|
||||||
|
|
||||||
namespace views {
|
namespace views {
|
||||||
class AuraInit;
|
class AuraInit;
|
||||||
@@ -26,7 +28,7 @@ namespace task_viewer {
|
|||||||
class TaskViewer : public service_manager::Service,
|
class TaskViewer : public service_manager::Service,
|
||||||
public ::mash::mojom::Launchable {
|
public ::mash::mojom::Launchable {
|
||||||
public:
|
public:
|
||||||
TaskViewer();
|
explicit TaskViewer(service_manager::mojom::ServiceRequest request);
|
||||||
~TaskViewer() override;
|
~TaskViewer() override;
|
||||||
|
|
||||||
void RemoveWindow(views::Widget* widget);
|
void RemoveWindow(views::Widget* widget);
|
||||||
@@ -43,6 +45,7 @@ class TaskViewer : public service_manager::Service,
|
|||||||
|
|
||||||
void Create(::mash::mojom::LaunchableRequest request);
|
void Create(::mash::mojom::LaunchableRequest request);
|
||||||
|
|
||||||
|
service_manager::ServiceBinding service_binding_;
|
||||||
mojo::BindingSet<::mash::mojom::Launchable> bindings_;
|
mojo::BindingSet<::mash::mojom::Launchable> bindings_;
|
||||||
std::vector<views::Widget*> windows_;
|
std::vector<views::Widget*> windows_;
|
||||||
|
|
||||||
|
@@ -6,7 +6,6 @@
|
|||||||
|
|
||||||
#include "build/build_config.h"
|
#include "build/build_config.h"
|
||||||
#include "mojo/public/cpp/bindings/strong_binding.h"
|
#include "mojo/public/cpp/bindings/strong_binding.h"
|
||||||
#include "services/service_manager/public/cpp/service_context.h"
|
|
||||||
#include "services/video_capture/device_factory_provider_impl.h"
|
#include "services/video_capture/device_factory_provider_impl.h"
|
||||||
#include "services/video_capture/public/mojom/constants.mojom.h"
|
#include "services/video_capture/public/mojom/constants.mojom.h"
|
||||||
#include "services/video_capture/public/uma/video_capture_service_event.h"
|
#include "services/video_capture/public/uma/video_capture_service_event.h"
|
||||||
|
@@ -6,6 +6,7 @@ import("//services/service_manager/public/cpp/service.gni")
|
|||||||
import("//services/service_manager/public/service_manifest.gni")
|
import("//services/service_manager/public/service_manifest.gni")
|
||||||
|
|
||||||
service("viz") {
|
service("viz") {
|
||||||
|
use_cpp_main = true
|
||||||
sources = [
|
sources = [
|
||||||
"main.cc",
|
"main.cc",
|
||||||
]
|
]
|
||||||
|
@@ -2,14 +2,11 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#include "services/service_manager/public/c/main.h"
|
|
||||||
#include "base/message_loop/message_loop.h"
|
#include "base/message_loop/message_loop.h"
|
||||||
#include "services/service_manager/public/cpp/service_runner.h"
|
#include "services/service_manager/public/cpp/standalone_service/service_main.h"
|
||||||
#include "services/viz/service.h"
|
#include "services/viz/service.h"
|
||||||
|
|
||||||
MojoResult ServiceMain(MojoHandle service_request_handle) {
|
void ServiceMain(service_manager::mojom::ServiceRequest request) {
|
||||||
viz::Service* viz_service = new viz::Service();
|
base::MessageLoop message_loop(base::MessageLoop::TYPE_UI);
|
||||||
service_manager::ServiceRunner runner(viz_service);
|
viz::Service(std::move(request)).RunUntilTermination();
|
||||||
runner.set_message_loop_type(base::MessageLoop::TYPE_UI);
|
|
||||||
return runner.Run(service_request_handle);
|
|
||||||
}
|
}
|
||||||
|
@@ -5,12 +5,12 @@
|
|||||||
#include "services/viz/service.h"
|
#include "services/viz/service.h"
|
||||||
|
|
||||||
#include "components/viz/service/main/viz_main_impl.h"
|
#include "components/viz/service/main/viz_main_impl.h"
|
||||||
#include "services/service_manager/public/cpp/service_context.h"
|
|
||||||
#include "services/viz/privileged/interfaces/viz_main.mojom.h"
|
#include "services/viz/privileged/interfaces/viz_main.mojom.h"
|
||||||
|
|
||||||
namespace viz {
|
namespace viz {
|
||||||
|
|
||||||
Service::Service() = default;
|
Service::Service(service_manager::mojom::ServiceRequest request)
|
||||||
|
: service_binding_(this, std::move(request)) {}
|
||||||
|
|
||||||
Service::~Service() = default;
|
Service::~Service() = default;
|
||||||
|
|
||||||
@@ -21,7 +21,7 @@ void Service::OnStart() {
|
|||||||
|
|
||||||
VizMainImpl::ExternalDependencies deps;
|
VizMainImpl::ExternalDependencies deps;
|
||||||
deps.create_display_compositor = true;
|
deps.create_display_compositor = true;
|
||||||
deps.connector = context()->connector();
|
deps.connector = service_binding_.GetConnector();
|
||||||
viz_main_ = std::make_unique<VizMainImpl>(nullptr, std::move(deps));
|
viz_main_ = std::make_unique<VizMainImpl>(nullptr, std::move(deps));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -7,6 +7,8 @@
|
|||||||
|
|
||||||
#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/cpp/service_binding.h"
|
||||||
|
#include "services/service_manager/public/mojom/service.mojom.h"
|
||||||
#include "services/viz/privileged/interfaces/viz_main.mojom.h"
|
#include "services/viz/privileged/interfaces/viz_main.mojom.h"
|
||||||
|
|
||||||
namespace viz {
|
namespace viz {
|
||||||
@@ -15,7 +17,7 @@ class VizMainImpl;
|
|||||||
|
|
||||||
class Service : public service_manager::Service {
|
class Service : public service_manager::Service {
|
||||||
public:
|
public:
|
||||||
Service();
|
explicit Service(service_manager::mojom::ServiceRequest request);
|
||||||
~Service() override;
|
~Service() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -27,6 +29,7 @@ class Service : public service_manager::Service {
|
|||||||
const std::string& interface_name,
|
const std::string& interface_name,
|
||||||
mojo::ScopedMessagePipeHandle interface_pipe) override;
|
mojo::ScopedMessagePipeHandle interface_pipe) override;
|
||||||
|
|
||||||
|
service_manager::ServiceBinding service_binding_;
|
||||||
service_manager::BinderRegistry registry_;
|
service_manager::BinderRegistry registry_;
|
||||||
|
|
||||||
std::unique_ptr<VizMainImpl> viz_main_;
|
std::unique_ptr<VizMainImpl> viz_main_;
|
||||||
|
@@ -140,18 +140,17 @@ TEST(ScreenProviderTest, DisplaysSentOnConnection) {
|
|||||||
|
|
||||||
// Create another WindowService.
|
// Create another WindowService.
|
||||||
TestWindowServiceDelegate test_window_service_delegate;
|
TestWindowServiceDelegate test_window_service_delegate;
|
||||||
std::unique_ptr<WindowService> window_service_ptr =
|
WindowService window_service(&test_window_service_delegate, nullptr,
|
||||||
std::make_unique<WindowService>(&test_window_service_delegate, nullptr,
|
test_setup.focus_controller());
|
||||||
test_setup.focus_controller());
|
|
||||||
std::unique_ptr<service_manager::TestConnectorFactory> factory =
|
service_manager::TestConnectorFactory factory;
|
||||||
service_manager::TestConnectorFactory::CreateForUniqueService(
|
window_service.BindServiceRequest(
|
||||||
std::move(window_service_ptr));
|
factory.RegisterInstance(mojom::kServiceName));
|
||||||
std::unique_ptr<service_manager::Connector> connector =
|
|
||||||
factory->CreateConnector();
|
|
||||||
|
|
||||||
// Connect to |window_service| and ask for a new WindowTree.
|
// Connect to |window_service| and ask for a new WindowTree.
|
||||||
mojom::WindowTreeFactoryPtr window_tree_factory;
|
mojom::WindowTreeFactoryPtr window_tree_factory;
|
||||||
connector->BindInterface(mojom::kServiceName, &window_tree_factory);
|
factory.GetDefaultConnector()->BindInterface(mojom::kServiceName,
|
||||||
|
&window_tree_factory);
|
||||||
mojom::WindowTreePtr window_tree;
|
mojom::WindowTreePtr window_tree;
|
||||||
mojom::WindowTreeClientPtr client;
|
mojom::WindowTreeClientPtr client;
|
||||||
mojom::WindowTreeClientRequest client_request = MakeRequest(&client);
|
mojom::WindowTreeClientRequest client_request = MakeRequest(&client);
|
||||||
|
@@ -8,7 +8,7 @@ import("//services/service_manager/public/service_manifest.gni")
|
|||||||
|
|
||||||
service("test_ws") {
|
service("test_ws") {
|
||||||
testonly = true
|
testonly = true
|
||||||
|
use_cpp_main = true
|
||||||
sources = [
|
sources = [
|
||||||
"test_ws.cc",
|
"test_ws.cc",
|
||||||
]
|
]
|
||||||
|
@@ -50,7 +50,9 @@ class TestWindowService::VisibilitySynchronizer : public aura::WindowTracker {
|
|||||||
DISALLOW_COPY_AND_ASSIGN(VisibilitySynchronizer);
|
DISALLOW_COPY_AND_ASSIGN(VisibilitySynchronizer);
|
||||||
};
|
};
|
||||||
|
|
||||||
TestWindowService::TestWindowService() = default;
|
TestWindowService::TestWindowService(
|
||||||
|
service_manager::mojom::ServiceRequest request)
|
||||||
|
: service_binding_(this, std::move(request)) {}
|
||||||
|
|
||||||
TestWindowService::~TestWindowService() {
|
TestWindowService::~TestWindowService() {
|
||||||
Shutdown(base::NullCallback());
|
Shutdown(base::NullCallback());
|
||||||
@@ -176,16 +178,15 @@ void TestWindowService::CreateService(
|
|||||||
DCHECK(!ui_service_created_);
|
DCHECK(!ui_service_created_);
|
||||||
ui_service_created_ = true;
|
ui_service_created_ = true;
|
||||||
|
|
||||||
auto window_service = std::make_unique<WindowService>(
|
window_service_ = std::make_unique<WindowService>(
|
||||||
this, std::move(gpu_interface_provider_),
|
this, std::move(gpu_interface_provider_),
|
||||||
aura_test_helper_->focus_client(), /*decrement_client_ids=*/false,
|
aura_test_helper_->focus_client(), /*decrement_client_ids=*/false,
|
||||||
aura_test_helper_->GetEnv());
|
aura_test_helper_->GetEnv());
|
||||||
test_host_event_dispatcher_ =
|
test_host_event_dispatcher_ =
|
||||||
std::make_unique<TestHostEventDispatcher>(aura_test_helper_->host());
|
std::make_unique<TestHostEventDispatcher>(aura_test_helper_->host());
|
||||||
host_event_queue_ = window_service->RegisterHostEventDispatcher(
|
host_event_queue_ = window_service_->RegisterHostEventDispatcher(
|
||||||
aura_test_helper_->host(), test_host_event_dispatcher_.get());
|
aura_test_helper_->host(), test_host_event_dispatcher_.get());
|
||||||
service_context_ = std::make_unique<service_manager::ServiceContext>(
|
window_service_->BindServiceRequest(std::move(request));
|
||||||
std::move(window_service), std::move(request));
|
|
||||||
pid_receiver->SetPID(base::GetCurrentProcId());
|
pid_receiver->SetPID(base::GetCurrentProcId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -204,7 +205,7 @@ void TestWindowService::MaximizeNextWindow(MaximizeNextWindowCallback cb) {
|
|||||||
void TestWindowService::Shutdown(
|
void TestWindowService::Shutdown(
|
||||||
test_ws::mojom::TestWs::ShutdownCallback callback) {
|
test_ws::mojom::TestWs::ShutdownCallback callback) {
|
||||||
// WindowService depends upon Screen, which is owned by AuraTestHelper.
|
// WindowService depends upon Screen, which is owned by AuraTestHelper.
|
||||||
service_context_.reset();
|
window_service_.reset();
|
||||||
|
|
||||||
// |aura_test_helper_| could be null when exiting before fully initialized.
|
// |aura_test_helper_| could be null when exiting before fully initialized.
|
||||||
if (aura_test_helper_) {
|
if (aura_test_helper_) {
|
||||||
@@ -235,7 +236,8 @@ void TestWindowService::CreateGpuHost() {
|
|||||||
std::make_unique<discardable_memory::DiscardableSharedMemoryManager>();
|
std::make_unique<discardable_memory::DiscardableSharedMemoryManager>();
|
||||||
|
|
||||||
gpu_host_ = std::make_unique<gpu_host::GpuHost>(
|
gpu_host_ = std::make_unique<gpu_host::GpuHost>(
|
||||||
this, context()->connector(), discardable_shared_memory_manager_.get());
|
this, service_binding_.GetConnector(),
|
||||||
|
discardable_shared_memory_manager_.get());
|
||||||
|
|
||||||
gpu_interface_provider_ = std::make_unique<TestGpuInterfaceProvider>(
|
gpu_interface_provider_ = std::make_unique<TestGpuInterfaceProvider>(
|
||||||
gpu_host_.get(), discardable_shared_memory_manager_.get());
|
gpu_host_.get(), discardable_shared_memory_manager_.get());
|
||||||
|
@@ -13,7 +13,8 @@
|
|||||||
#include "mojo/public/cpp/bindings/binding_set.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/cpp/service_context.h"
|
#include "services/service_manager/public/cpp/service_binding.h"
|
||||||
|
#include "services/service_manager/public/mojom/service.mojom.h"
|
||||||
#include "services/service_manager/public/mojom/service_factory.mojom.h"
|
#include "services/service_manager/public/mojom/service_factory.mojom.h"
|
||||||
#include "services/ws/gpu_host/gpu_host.h"
|
#include "services/ws/gpu_host/gpu_host.h"
|
||||||
#include "services/ws/gpu_host/gpu_host_delegate.h"
|
#include "services/ws/gpu_host/gpu_host_delegate.h"
|
||||||
@@ -35,6 +36,7 @@ namespace ws {
|
|||||||
|
|
||||||
class HostEventQueue;
|
class HostEventQueue;
|
||||||
class TestHostEventDispatcher;
|
class TestHostEventDispatcher;
|
||||||
|
class WindowService;
|
||||||
|
|
||||||
namespace test {
|
namespace test {
|
||||||
|
|
||||||
@@ -46,7 +48,7 @@ class TestWindowService : public service_manager::Service,
|
|||||||
public WindowServiceDelegate,
|
public WindowServiceDelegate,
|
||||||
public test_ws::mojom::TestWs {
|
public test_ws::mojom::TestWs {
|
||||||
public:
|
public:
|
||||||
TestWindowService();
|
explicit TestWindowService(service_manager::mojom::ServiceRequest request);
|
||||||
~TestWindowService() override;
|
~TestWindowService() override;
|
||||||
|
|
||||||
void InitForInProcess(
|
void InitForInProcess(
|
||||||
@@ -106,14 +108,14 @@ class TestWindowService : public service_manager::Service,
|
|||||||
void SetupAuraTestHelper(ui::ContextFactory* context_factory,
|
void SetupAuraTestHelper(ui::ContextFactory* context_factory,
|
||||||
ui::ContextFactoryPrivate* context_factory_private);
|
ui::ContextFactoryPrivate* context_factory_private);
|
||||||
|
|
||||||
|
service_manager::ServiceBinding service_binding_;
|
||||||
service_manager::BinderRegistry registry_;
|
service_manager::BinderRegistry registry_;
|
||||||
|
|
||||||
mojo::BindingSet<service_manager::mojom::ServiceFactory>
|
mojo::BindingSet<service_manager::mojom::ServiceFactory>
|
||||||
service_factory_bindings_;
|
service_factory_bindings_;
|
||||||
mojo::BindingSet<test_ws::mojom::TestWs> test_ws_bindings_;
|
mojo::BindingSet<test_ws::mojom::TestWs> test_ws_bindings_;
|
||||||
|
|
||||||
// Handles the ServiceRequest. Owns the WindowService instance.
|
std::unique_ptr<WindowService> window_service_;
|
||||||
std::unique_ptr<service_manager::ServiceContext> service_context_;
|
|
||||||
|
|
||||||
std::unique_ptr<aura::test::AuraTestHelper> aura_test_helper_;
|
std::unique_ptr<aura::test::AuraTestHelper> aura_test_helper_;
|
||||||
|
|
||||||
|
@@ -16,16 +16,17 @@ namespace test {
|
|||||||
std::unique_ptr<service_manager::Service> CreateInProcessWindowService(
|
std::unique_ptr<service_manager::Service> CreateInProcessWindowService(
|
||||||
ui::ContextFactory* context_factory,
|
ui::ContextFactory* context_factory,
|
||||||
ui::ContextFactoryPrivate* context_factory_private,
|
ui::ContextFactoryPrivate* context_factory_private,
|
||||||
std::unique_ptr<GpuInterfaceProvider> gpu_interface_provider) {
|
std::unique_ptr<GpuInterfaceProvider> gpu_interface_provider,
|
||||||
auto window_service = std::make_unique<TestWindowService>();
|
service_manager::mojom::ServiceRequest request) {
|
||||||
|
auto window_service = std::make_unique<TestWindowService>(std::move(request));
|
||||||
window_service->InitForInProcess(context_factory, context_factory_private,
|
window_service->InitForInProcess(context_factory, context_factory_private,
|
||||||
std::move(gpu_interface_provider));
|
std::move(gpu_interface_provider));
|
||||||
return window_service;
|
return window_service;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<service_manager::Service> CreateOutOfProcessWindowService() {
|
std::unique_ptr<service_manager::Service> CreateOutOfProcessWindowService(
|
||||||
auto window_service = std::make_unique<TestWindowService>();
|
service_manager::mojom::ServiceRequest request) {
|
||||||
return window_service;
|
return std::make_unique<TestWindowService>(std::move(request));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace test
|
} // namespace test
|
||||||
|
@@ -7,6 +7,8 @@
|
|||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
#include "services/service_manager/public/mojom/service.mojom.h"
|
||||||
|
|
||||||
namespace service_manager {
|
namespace service_manager {
|
||||||
class Service;
|
class Service;
|
||||||
} // namespace service_manager
|
} // namespace service_manager
|
||||||
@@ -26,9 +28,11 @@ namespace test {
|
|||||||
std::unique_ptr<service_manager::Service> CreateInProcessWindowService(
|
std::unique_ptr<service_manager::Service> CreateInProcessWindowService(
|
||||||
ui::ContextFactory* context_factory,
|
ui::ContextFactory* context_factory,
|
||||||
ui::ContextFactoryPrivate* context_factory_private,
|
ui::ContextFactoryPrivate* context_factory_private,
|
||||||
std::unique_ptr<GpuInterfaceProvider> gpu_interface_provider);
|
std::unique_ptr<GpuInterfaceProvider> gpu_interface_provider,
|
||||||
|
service_manager::mojom::ServiceRequest request);
|
||||||
|
|
||||||
std::unique_ptr<service_manager::Service> CreateOutOfProcessWindowService();
|
std::unique_ptr<service_manager::Service> CreateOutOfProcessWindowService(
|
||||||
|
service_manager::mojom::ServiceRequest request);
|
||||||
|
|
||||||
} // namespace test
|
} // namespace test
|
||||||
} // namespace ws
|
} // namespace ws
|
||||||
|
@@ -3,18 +3,14 @@
|
|||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#include "base/message_loop/message_loop.h"
|
#include "base/message_loop/message_loop.h"
|
||||||
#include "services/service_manager/public/c/main.h"
|
|
||||||
#include "services/service_manager/public/cpp/service.h"
|
#include "services/service_manager/public/cpp/service.h"
|
||||||
#include "services/service_manager/public/cpp/service_runner.h"
|
#include "services/service_manager/public/cpp/standalone_service/service_main.h"
|
||||||
#include "services/ws/test_ws/test_window_service_factory.h"
|
#include "services/ws/test_ws/test_window_service_factory.h"
|
||||||
#include "ui/base/ui_base_paths.h"
|
#include "ui/base/ui_base_paths.h"
|
||||||
|
|
||||||
MojoResult ServiceMain(MojoHandle service_request_handle) {
|
void ServiceMain(service_manager::mojom::ServiceRequest request) {
|
||||||
ui::RegisterPathProvider();
|
ui::RegisterPathProvider();
|
||||||
|
base::MessageLoop message_loop(base::MessageLoop::TYPE_UI);
|
||||||
// |runner| takes ownership of the created test_ws service.
|
auto service = ws::test::CreateOutOfProcessWindowService(std::move(request));
|
||||||
service_manager::ServiceRunner runner(
|
service->RunUntilTermination();
|
||||||
ws::test::CreateOutOfProcessWindowService().release());
|
|
||||||
runner.set_message_loop_type(base::MessageLoop::TYPE_UI);
|
|
||||||
return runner.Run(service_request_handle);
|
|
||||||
}
|
}
|
||||||
|
@@ -79,6 +79,12 @@ WindowService::~WindowService() {
|
|||||||
DCHECK(window_trees_.empty());
|
DCHECK(window_trees_.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WindowService::BindServiceRequest(
|
||||||
|
service_manager::mojom::ServiceRequest request) {
|
||||||
|
DCHECK(!service_binding_.is_bound());
|
||||||
|
service_binding_.Bind(std::move(request));
|
||||||
|
}
|
||||||
|
|
||||||
ServerWindow* WindowService::GetServerWindowForWindowCreateIfNecessary(
|
ServerWindow* WindowService::GetServerWindowForWindowCreateIfNecessary(
|
||||||
aura::Window* window) {
|
aura::Window* window) {
|
||||||
ServerWindow* server_window = ServerWindow::GetMayBeNull(window);
|
ServerWindow* server_window = ServerWindow::GetMayBeNull(window);
|
||||||
|
@@ -16,6 +16,8 @@
|
|||||||
#include "base/observer_list.h"
|
#include "base/observer_list.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/cpp/service_binding.h"
|
||||||
|
#include "services/service_manager/public/mojom/service.mojom.h"
|
||||||
#include "services/ws/ids.h"
|
#include "services/ws/ids.h"
|
||||||
#include "services/ws/ime/ime_driver_bridge.h"
|
#include "services/ws/ime/ime_driver_bridge.h"
|
||||||
#include "services/ws/ime/ime_registrar_impl.h"
|
#include "services/ws/ime/ime_registrar_impl.h"
|
||||||
@@ -87,6 +89,10 @@ class COMPONENT_EXPORT(WINDOW_SERVICE) WindowService
|
|||||||
aura::Env* env = nullptr);
|
aura::Env* env = nullptr);
|
||||||
~WindowService() override;
|
~WindowService() override;
|
||||||
|
|
||||||
|
// Binds this WindowService instance to a ServiceRequest from the Service
|
||||||
|
// Manger.
|
||||||
|
void BindServiceRequest(service_manager::mojom::ServiceRequest request);
|
||||||
|
|
||||||
// Gets the ServerWindow for |window|, creating if necessary.
|
// Gets the ServerWindow for |window|, creating if necessary.
|
||||||
ServerWindow* GetServerWindowForWindowCreateIfNecessary(aura::Window* window);
|
ServerWindow* GetServerWindowForWindowCreateIfNecessary(aura::Window* window);
|
||||||
|
|
||||||
@@ -219,6 +225,8 @@ class COMPONENT_EXPORT(WINDOW_SERVICE) WindowService
|
|||||||
|
|
||||||
aura::Env* env_;
|
aura::Env* env_;
|
||||||
|
|
||||||
|
service_manager::ServiceBinding service_binding_{this};
|
||||||
|
|
||||||
// GpuInterfaceProvider may be null in tests.
|
// GpuInterfaceProvider may be null in tests.
|
||||||
std::unique_ptr<GpuInterfaceProvider> gpu_interface_provider_;
|
std::unique_ptr<GpuInterfaceProvider> gpu_interface_provider_;
|
||||||
|
|
||||||
|
@@ -36,19 +36,16 @@ TEST(WindowServiceTest, DeleteWithClients) {
|
|||||||
|
|
||||||
// Create another WindowService.
|
// Create another WindowService.
|
||||||
TestWindowServiceDelegate test_window_service_delegate;
|
TestWindowServiceDelegate test_window_service_delegate;
|
||||||
std::unique_ptr<WindowService> window_service_ptr =
|
WindowService window_service(&test_window_service_delegate, nullptr,
|
||||||
std::make_unique<WindowService>(&test_window_service_delegate, nullptr,
|
test_setup.focus_controller());
|
||||||
test_setup.focus_controller());
|
service_manager::TestConnectorFactory factory;
|
||||||
WindowService* window_service = window_service_ptr.get();
|
window_service.BindServiceRequest(
|
||||||
std::unique_ptr<service_manager::TestConnectorFactory> factory =
|
factory.RegisterInstance(mojom::kServiceName));
|
||||||
service_manager::TestConnectorFactory::CreateForUniqueService(
|
|
||||||
std::move(window_service_ptr));
|
|
||||||
std::unique_ptr<service_manager::Connector> connector =
|
|
||||||
factory->CreateConnector();
|
|
||||||
|
|
||||||
// Connect to |window_service| and ask for a new WindowTree.
|
// Connect to |window_service| and ask for a new WindowTree.
|
||||||
mojom::WindowTreeFactoryPtr window_tree_factory;
|
mojom::WindowTreeFactoryPtr window_tree_factory;
|
||||||
connector->BindInterface(mojom::kServiceName, &window_tree_factory);
|
factory.GetDefaultConnector()->BindInterface(mojom::kServiceName,
|
||||||
|
&window_tree_factory);
|
||||||
mojom::WindowTreePtr window_tree;
|
mojom::WindowTreePtr window_tree;
|
||||||
mojom::WindowTreeClientPtr client;
|
mojom::WindowTreeClientPtr client;
|
||||||
mojom::WindowTreeClientRequest client_request = MakeRequest(&client);
|
mojom::WindowTreeClientRequest client_request = MakeRequest(&client);
|
||||||
@@ -59,7 +56,7 @@ TEST(WindowServiceTest, DeleteWithClients) {
|
|||||||
window_tree_factory.FlushForTesting();
|
window_tree_factory.FlushForTesting();
|
||||||
|
|
||||||
// There should be at least one WindowTree.
|
// There should be at least one WindowTree.
|
||||||
EXPECT_FALSE(window_service->window_trees().empty());
|
EXPECT_FALSE(window_service.window_trees().empty());
|
||||||
|
|
||||||
// Destroying the |window_service| should remove all the WindowTrees and
|
// Destroying the |window_service| should remove all the WindowTrees and
|
||||||
// ensure a DCHECK isn't hit in ~WindowTree.
|
// ensure a DCHECK isn't hit in ~WindowTree.
|
||||||
@@ -116,18 +113,16 @@ TEST(WindowServiceTest, GetWindowManagerInterface) {
|
|||||||
|
|
||||||
// Create another WindowService.
|
// Create another WindowService.
|
||||||
TestWindowServiceDelegateWithInterface test_window_service_delegate;
|
TestWindowServiceDelegateWithInterface test_window_service_delegate;
|
||||||
std::unique_ptr<WindowService> window_service_ptr =
|
WindowService window_service(&test_window_service_delegate, nullptr,
|
||||||
std::make_unique<WindowService>(&test_window_service_delegate, nullptr,
|
test_setup.focus_controller());
|
||||||
test_setup.focus_controller());
|
service_manager::TestConnectorFactory factory;
|
||||||
std::unique_ptr<service_manager::TestConnectorFactory> factory =
|
window_service.BindServiceRequest(
|
||||||
service_manager::TestConnectorFactory::CreateForUniqueService(
|
factory.RegisterInstance(mojom::kServiceName));
|
||||||
std::move(window_service_ptr));
|
|
||||||
std::unique_ptr<service_manager::Connector> connector =
|
|
||||||
factory->CreateConnector();
|
|
||||||
|
|
||||||
// Connect to |window_service| and ask for a new WindowTree.
|
// Connect to |window_service| and ask for a new WindowTree.
|
||||||
mojom::WindowTreeFactoryPtr window_tree_factory;
|
mojom::WindowTreeFactoryPtr window_tree_factory;
|
||||||
connector->BindInterface(mojom::kServiceName, &window_tree_factory);
|
factory.GetDefaultConnector()->BindInterface(mojom::kServiceName,
|
||||||
|
&window_tree_factory);
|
||||||
mojom::WindowTreePtr window_tree;
|
mojom::WindowTreePtr window_tree;
|
||||||
mojom::WindowTreeClientPtr client;
|
mojom::WindowTreeClientPtr client;
|
||||||
mojom::WindowTreeClientRequest client_request = MakeRequest(&client);
|
mojom::WindowTreeClientRequest client_request = MakeRequest(&client);
|
||||||
|
@@ -21,7 +21,7 @@
|
|||||||
#include "services/service_manager/public/cpp/connector.h"
|
#include "services/service_manager/public/cpp/connector.h"
|
||||||
#include "services/service_manager/public/cpp/constants.h"
|
#include "services/service_manager/public/cpp/constants.h"
|
||||||
#include "services/service_manager/public/cpp/service.h"
|
#include "services/service_manager/public/cpp/service.h"
|
||||||
#include "services/service_manager/public/cpp/service_context.h"
|
#include "services/service_manager/public/cpp/service_binding.h"
|
||||||
#include "services/ws/common/switches.h"
|
#include "services/ws/common/switches.h"
|
||||||
#include "testing/gtest/include/gtest/gtest.h"
|
#include "testing/gtest/include/gtest/gtest.h"
|
||||||
#include "ui/aura/env.h"
|
#include "ui/aura/env.h"
|
||||||
@@ -51,24 +51,11 @@ void EnsureCommandLineSwitch(const std::string& name) {
|
|||||||
cmd_line->AppendSwitch(name);
|
cmd_line->AppendSwitch(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
class DefaultService : public service_manager::Service {
|
|
||||||
public:
|
|
||||||
DefaultService() {}
|
|
||||||
~DefaultService() override {}
|
|
||||||
|
|
||||||
// service_manager::Service:
|
|
||||||
void OnBindInterface(const service_manager::BindSourceInfo& source_info,
|
|
||||||
const std::string& interface_name,
|
|
||||||
mojo::ScopedMessagePipeHandle interface_pipe) override {}
|
|
||||||
|
|
||||||
private:
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(DefaultService);
|
|
||||||
};
|
|
||||||
|
|
||||||
class ServiceManagerConnection {
|
class ServiceManagerConnection {
|
||||||
public:
|
public:
|
||||||
ServiceManagerConnection()
|
ServiceManagerConnection()
|
||||||
: thread_("Persistent service_manager connections") {
|
: thread_("Persistent service_manager connections"),
|
||||||
|
default_service_binding_(&default_service_) {
|
||||||
catalog::Catalog::LoadDefaultCatalogManifest(
|
catalog::Catalog::LoadDefaultCatalogManifest(
|
||||||
base::FilePath(kCatalogFilename));
|
base::FilePath(kCatalogFilename));
|
||||||
base::WaitableEvent wait(base::WaitableEvent::ResetPolicy::AUTOMATIC,
|
base::WaitableEvent wait(base::WaitableEvent::ResetPolicy::AUTOMATIC,
|
||||||
@@ -115,7 +102,8 @@ class ServiceManagerConnection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CloneConnector(base::WaitableEvent* wait) {
|
void CloneConnector(base::WaitableEvent* wait) {
|
||||||
service_manager_connector_ = context_->connector()->Clone();
|
service_manager_connector_ =
|
||||||
|
default_service_binding_.GetConnector()->Clone();
|
||||||
wait->Signal();
|
wait->Signal();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -124,20 +112,20 @@ class ServiceManagerConnection {
|
|||||||
std::make_unique<service_manager::BackgroundServiceManager>(nullptr,
|
std::make_unique<service_manager::BackgroundServiceManager>(nullptr,
|
||||||
nullptr);
|
nullptr);
|
||||||
service_manager::mojom::ServicePtr service;
|
service_manager::mojom::ServicePtr service;
|
||||||
context_ = std::make_unique<service_manager::ServiceContext>(
|
default_service_binding_.Bind(mojo::MakeRequest(&service));
|
||||||
std::make_unique<DefaultService>(), mojo::MakeRequest(&service));
|
|
||||||
background_service_manager_->RegisterService(
|
background_service_manager_->RegisterService(
|
||||||
service_manager::Identity(GetTestName(),
|
service_manager::Identity(GetTestName(),
|
||||||
service_manager::kSystemInstanceGroup,
|
service_manager::kSystemInstanceGroup,
|
||||||
base::Token{}, base::Token::CreateRandom()),
|
base::Token{}, base::Token::CreateRandom()),
|
||||||
std::move(service), nullptr);
|
std::move(service), nullptr);
|
||||||
service_manager_connector_ = context_->connector()->Clone();
|
service_manager_connector_ =
|
||||||
service_manager_identity_ = context_->identity();
|
default_service_binding_.GetConnector()->Clone();
|
||||||
|
service_manager_identity_ = default_service_binding_.identity();
|
||||||
wait->Signal();
|
wait->Signal();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TearDownConnectionsOnBackgroundThread(base::WaitableEvent* wait) {
|
void TearDownConnectionsOnBackgroundThread(base::WaitableEvent* wait) {
|
||||||
context_.reset();
|
default_service_binding_.Close();
|
||||||
background_service_manager_.reset();
|
background_service_manager_.reset();
|
||||||
wait->Signal();
|
wait->Signal();
|
||||||
}
|
}
|
||||||
@@ -154,7 +142,8 @@ class ServiceManagerConnection {
|
|||||||
base::Thread thread_;
|
base::Thread thread_;
|
||||||
std::unique_ptr<service_manager::BackgroundServiceManager>
|
std::unique_ptr<service_manager::BackgroundServiceManager>
|
||||||
background_service_manager_;
|
background_service_manager_;
|
||||||
std::unique_ptr<service_manager::ServiceContext> context_;
|
service_manager::Service default_service_;
|
||||||
|
service_manager::ServiceBinding default_service_binding_;
|
||||||
std::unique_ptr<service_manager::Connector> service_manager_connector_;
|
std::unique_ptr<service_manager::Connector> service_manager_connector_;
|
||||||
service_manager::Identity service_manager_identity_;
|
service_manager::Identity service_manager_identity_;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user