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/trace_event/trace_event.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/views/mus/aura_init.h"
|
||||
|
||||
namespace keyboard_shortcut_viewer {
|
||||
|
||||
ShortcutViewerApplication::ShortcutViewerApplication()
|
||||
: shortcut_viewer_binding_(this) {
|
||||
ShortcutViewerApplication::ShortcutViewerApplication(
|
||||
service_manager::mojom::ServiceRequest request)
|
||||
: service_binding_(this, std::move(request)) {
|
||||
registry_.AddInterface<shortcut_viewer::mojom::ShortcutViewer>(
|
||||
base::BindRepeating(&ShortcutViewerApplication::AddBinding,
|
||||
base::Unretained(this)));
|
||||
@ -32,13 +32,13 @@ void ShortcutViewerApplication::RegisterForTraceEvents() {
|
||||
|
||||
void ShortcutViewerApplication::OnStart() {
|
||||
views::AuraInit::InitParams params;
|
||||
params.connector = context()->connector();
|
||||
params.identity = context()->identity();
|
||||
params.connector = service_binding_.GetConnector();
|
||||
params.identity = service_binding_.identity();
|
||||
params.register_path_provider = false;
|
||||
params.use_accessibility_host = true;
|
||||
aura_init_ = views::AuraInit::Create(params);
|
||||
if (!aura_init_) {
|
||||
context()->QuitNow();
|
||||
Terminate();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -46,8 +46,9 @@ void ShortcutViewerApplication::OnStart() {
|
||||
ash::ash_client::Init();
|
||||
|
||||
// Quit the application when the window is closed.
|
||||
last_window_closed_observer_ = std::make_unique<LastWindowClosedObserver>(
|
||||
context()->CreateQuitClosure());
|
||||
last_window_closed_observer_ =
|
||||
std::make_unique<LastWindowClosedObserver>(base::BindRepeating(
|
||||
&ShortcutViewerApplication::Terminate, base::Unretained(this)));
|
||||
}
|
||||
|
||||
void ShortcutViewerApplication::OnBindInterface(
|
||||
|
@ -13,6 +13,8 @@
|
||||
#include "mojo/public/cpp/bindings/binding.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_binding.h"
|
||||
#include "services/service_manager/public/mojom/service.mojom.h"
|
||||
#include "ui/events/devices/input_device_event_observer.h"
|
||||
|
||||
namespace views {
|
||||
@ -29,7 +31,8 @@ class ShortcutViewerApplication
|
||||
public ui::InputDeviceEventObserver,
|
||||
public shortcut_viewer::mojom::ShortcutViewer {
|
||||
public:
|
||||
ShortcutViewerApplication();
|
||||
explicit ShortcutViewerApplication(
|
||||
service_manager::mojom::ServiceRequest request);
|
||||
~ShortcutViewerApplication() override;
|
||||
|
||||
// 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);
|
||||
|
||||
service_manager::ServiceBinding service_binding_;
|
||||
|
||||
std::unique_ptr<views::AuraInit> aura_init_;
|
||||
std::unique_ptr<LastWindowClosedObserver> last_window_closed_observer_;
|
||||
|
||||
service_manager::BinderRegistry registry_;
|
||||
|
||||
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
|
||||
// showing the window. Used for metrics.
|
||||
|
@ -10,7 +10,6 @@
|
||||
#include "ash/public/cpp/shell_window_ids.h"
|
||||
#include "base/macros.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/mojom/window_manager.mojom.h"
|
||||
#include "services/ws/public/mojom/window_tree_constants.mojom.h"
|
||||
@ -24,7 +23,9 @@
|
||||
|
||||
namespace tap_visualizer {
|
||||
|
||||
TapVisualizerApp::TapVisualizerApp() = default;
|
||||
TapVisualizerApp::TapVisualizerApp(
|
||||
service_manager::mojom::ServiceRequest request)
|
||||
: service_binding_(this, std::move(request)) {}
|
||||
|
||||
TapVisualizerApp::~TapVisualizerApp() {
|
||||
display::Screen::GetScreen()->RemoveObserver(this);
|
||||
@ -46,12 +47,12 @@ void TapVisualizerApp::Start() {
|
||||
|
||||
void TapVisualizerApp::OnStart() {
|
||||
views::AuraInit::InitParams params;
|
||||
params.connector = context()->connector();
|
||||
params.identity = context()->identity();
|
||||
params.connector = service_binding_.GetConnector();
|
||||
params.identity = service_binding_.identity();
|
||||
params.register_path_provider = false;
|
||||
aura_init_ = views::AuraInit::Create(params);
|
||||
if (!aura_init_) {
|
||||
context()->QuitNow();
|
||||
Terminate();
|
||||
return;
|
||||
}
|
||||
Start();
|
||||
|
@ -12,6 +12,8 @@
|
||||
|
||||
#include "base/macros.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/events/event_observer.h"
|
||||
|
||||
@ -29,7 +31,8 @@ class TapVisualizerApp : public service_manager::Service,
|
||||
public ui::EventObserver,
|
||||
public display::DisplayObserver {
|
||||
public:
|
||||
TapVisualizerApp();
|
||||
explicit TapVisualizerApp(service_manager::mojom::ServiceRequest request);
|
||||
|
||||
~TapVisualizerApp() override;
|
||||
|
||||
private:
|
||||
@ -51,6 +54,8 @@ class TapVisualizerApp : public service_manager::Service,
|
||||
// Creates the touch HUD widget for a display.
|
||||
void CreateWidgetForDisplay(int64_t display_id);
|
||||
|
||||
service_manager::ServiceBinding service_binding_;
|
||||
|
||||
// Maps display::Display::id() to the renderer for that display.
|
||||
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) {
|
||||
// Simulate the service starting.
|
||||
TapVisualizerApp app;
|
||||
TapVisualizerApp app(nullptr);
|
||||
TapVisualizerAppTestApi test_api(&app);
|
||||
test_api.Start();
|
||||
|
||||
@ -111,7 +111,7 @@ TEST_F(TapVisualizerAppTest, MultiDisplay) {
|
||||
display::DisplayList::Type::NOT_PRIMARY);
|
||||
|
||||
// Simulate the service starting.
|
||||
TapVisualizerApp app;
|
||||
TapVisualizerApp app(nullptr);
|
||||
TapVisualizerAppTestApi test_api(&app);
|
||||
test_api.Start();
|
||||
|
||||
|
@ -33,15 +33,17 @@ std::unique_ptr<service_manager::Service> CreateQuickLaunch(
|
||||
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");
|
||||
return std::make_unique<
|
||||
keyboard_shortcut_viewer::ShortcutViewerApplication>();
|
||||
return std::make_unique<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");
|
||||
return std::make_unique<tap_visualizer::TapVisualizerApp>();
|
||||
return std::make_unique<tap_visualizer::TapVisualizerApp>(std::move(request));
|
||||
}
|
||||
|
||||
std::unique_ptr<service_manager::Service> CreateTestImeDriver(
|
||||
@ -55,19 +57,6 @@ class ShellContentUtilityClient : public content::ContentUtilityClient {
|
||||
~ShellContentUtilityClient() override = default;
|
||||
|
||||
// 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(
|
||||
const std::string& service_name,
|
||||
service_manager::mojom::ServiceRequest request) override {
|
||||
@ -75,6 +64,10 @@ class ShellContentUtilityClient : public content::ContentUtilityClient {
|
||||
return CreateQuickLaunch(std::move(request));
|
||||
if (service_name == test_ime_driver::mojom::kServiceName)
|
||||
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;
|
||||
}
|
||||
|
@ -13,9 +13,7 @@
|
||||
#include "base/lazy_instance.h"
|
||||
#include "base/unguessable_token.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/window_service.h"
|
||||
#include "ui/base/ui_base_features.h"
|
||||
#include "ui/display/display.h"
|
||||
#include "ui/display/screen.h"
|
||||
@ -65,23 +63,21 @@ class ServerRemoteContentViewManager
|
||||
WindowServiceOwner::WindowServiceOwner(
|
||||
std::unique_ptr<ws::GpuInterfaceProvider> gpu_interface_provider)
|
||||
: window_service_delegate_(std::make_unique<WindowServiceDelegateImpl>()),
|
||||
owned_window_service_(
|
||||
std::make_unique<ws::WindowService>(window_service_delegate_.get(),
|
||||
std::move(gpu_interface_provider),
|
||||
Shell::Get()->focus_controller(),
|
||||
!::features::IsMultiProcessMash(),
|
||||
Shell::Get()->aura_env())),
|
||||
window_service_(owned_window_service_.get()) {
|
||||
window_service_->SetFrameDecorationValues(
|
||||
window_service_(window_service_delegate_.get(),
|
||||
std::move(gpu_interface_provider),
|
||||
Shell::Get()->focus_controller(),
|
||||
!::features::IsMultiProcessMash(),
|
||||
Shell::Get()->aura_env()) {
|
||||
window_service_.SetFrameDecorationValues(
|
||||
NonClientFrameController::GetPreferredClientAreaInsets(),
|
||||
NonClientFrameController::GetMaxTitleBarButtonWidth());
|
||||
window_service_->SetDisplayForNewWindows(
|
||||
window_service_.SetDisplayForNewWindows(
|
||||
display::Screen::GetScreen()->GetDisplayForNewWindows().id());
|
||||
RegisterWindowProperties(window_service_->property_converter());
|
||||
RegisterWindowProperties(window_service_.property_converter());
|
||||
|
||||
#if BUILDFLAG(ENABLE_REMOTE_NAVIGABLE_CONTENTS_VIEW)
|
||||
content::NavigableContentsView::SetRemoteViewManager(
|
||||
std::make_unique<ServerRemoteContentViewManager>(window_service_));
|
||||
std::make_unique<ServerRemoteContentViewManager>(&window_service_));
|
||||
#endif // BUILDFLAG(ENABLE_REMOTE_NAVIGABLE_CONTENTS_VIEW)
|
||||
}
|
||||
|
||||
@ -89,13 +85,7 @@ WindowServiceOwner::~WindowServiceOwner() = default;
|
||||
|
||||
void WindowServiceOwner::BindWindowService(
|
||||
service_manager::mojom::ServiceRequest request) {
|
||||
// This should only be called once. If called more than once it means the
|
||||
// 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));
|
||||
window_service_.BindServiceRequest(std::move(request));
|
||||
}
|
||||
|
||||
} // namespace ash
|
||||
|
@ -11,14 +11,10 @@
|
||||
#include "ash/shell_init_params.h"
|
||||
#include "base/memory/scoped_refptr.h"
|
||||
#include "services/service_manager/public/mojom/service.mojom.h"
|
||||
|
||||
namespace service_manager {
|
||||
class ServiceContext;
|
||||
}
|
||||
#include "services/ws/window_service.h"
|
||||
|
||||
namespace ws {
|
||||
class GpuInterfaceProvider;
|
||||
class WindowService;
|
||||
} // namespace ws
|
||||
|
||||
namespace ash {
|
||||
@ -38,22 +34,13 @@ class ASH_EXPORT WindowServiceOwner {
|
||||
// WindowService.
|
||||
void BindWindowService(service_manager::mojom::ServiceRequest request);
|
||||
|
||||
ws::WindowService* window_service() { return window_service_; }
|
||||
ws::WindowService* window_service() { return &window_service_; }
|
||||
|
||||
private:
|
||||
friend class AshTestHelper;
|
||||
|
||||
std::unique_ptr<WindowServiceDelegateImpl> window_service_delegate_;
|
||||
|
||||
// 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_;
|
||||
ws::WindowService window_service_;
|
||||
|
||||
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
|
||||
|
||||
#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)
|
||||
{
|
||||
service_manager::EmbeddedServiceInfo service_info;
|
||||
|
@ -35,17 +35,6 @@ enum class MashService {
|
||||
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.
|
||||
void RecordMashServiceLaunch(MashService service) {
|
||||
UMA_HISTOGRAM_ENUMERATION("Launch.MashService", service);
|
||||
@ -66,17 +55,19 @@ std::unique_ptr<service_manager::Service> CreateQuickLaunchService(
|
||||
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);
|
||||
logging::SetLogPrefix("shortcut");
|
||||
return std::make_unique<
|
||||
keyboard_shortcut_viewer::ShortcutViewerApplication>();
|
||||
return std::make_unique<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);
|
||||
logging::SetLogPrefix("tap");
|
||||
return std::make_unique<tap_visualizer::TapVisualizerApp>();
|
||||
return std::make_unique<tap_visualizer::TapVisualizerApp>(std::move(request));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@ -85,16 +76,6 @@ 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>
|
||||
MashServiceFactory::HandleServiceRequest(
|
||||
const std::string& service_name,
|
||||
@ -103,6 +84,13 @@ MashServiceFactory::HandleServiceRequest(
|
||||
return CreateAshService(std::move(request));
|
||||
if (service_name == quick_launch::mojom::kServiceName)
|
||||
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;
|
||||
}
|
||||
|
@ -18,10 +18,6 @@ class 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
|
||||
// null if the named service is unknown or cannot be created.
|
||||
std::unique_ptr<service_manager::Service> HandleServiceRequest(
|
||||
|
@ -194,24 +194,6 @@ void ShellContentBrowserClient::BindInterfaceRequestFromFrame(
|
||||
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(
|
||||
OutOfProcessServiceMap* services) {
|
||||
(*services)[kTestServiceUrl] =
|
||||
@ -235,6 +217,16 @@ void ShellContentBrowserClient::HandleServiceRequest(
|
||||
media::CreateMediaServiceForTesting(std::move(request)));
|
||||
}
|
||||
#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(
|
||||
|
@ -38,8 +38,6 @@ class ShellContentBrowserClient : public ContentBrowserClient {
|
||||
content::RenderFrameHost* render_frame_host,
|
||||
const std::string& interface_name,
|
||||
mojo::ScopedMessagePipeHandle interface_pipe) override;
|
||||
void RegisterInProcessServices(StaticServiceMap* services,
|
||||
ServiceManagerConnection* connection) override;
|
||||
void RegisterOutOfProcessServices(OutOfProcessServiceMap* services) override;
|
||||
void HandleServiceRequest(
|
||||
const std::string& service_name,
|
||||
|
@ -130,15 +130,20 @@ void ShellContentUtilityClient::RegisterServices(StaticServiceMap* services) {
|
||||
info.factory = base::BindRepeating(&echo::CreateEchoService);
|
||||
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 (features::IsMultiProcessMash()) {
|
||||
service_manager::EmbeddedServiceInfo info;
|
||||
info.factory =
|
||||
base::BindRepeating(&ws::test::CreateOutOfProcessWindowService);
|
||||
services->insert(std::make_pair(test_ws::mojom::kServiceName, info));
|
||||
if (features::IsMultiProcessMash() &&
|
||||
service_name == test_ws::mojom::kServiceName) {
|
||||
return ws::test::CreateOutOfProcessWindowService(std::move(request));
|
||||
}
|
||||
#endif
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void ShellContentUtilityClient::RegisterNetworkBinders(
|
||||
|
@ -20,6 +20,9 @@ class ShellContentUtilityClient : public ContentUtilityClient {
|
||||
// ContentUtilityClient:
|
||||
void UtilityThreadStarted() 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(
|
||||
service_manager::BinderRegistry* registry) override;
|
||||
void RegisterAudioBinders(service_manager::BinderRegistry* registry) override;
|
||||
|
@ -1,3 +1,6 @@
|
||||
# Mac Sandbox profiles.
|
||||
per-file *.sb=set noparent
|
||||
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)
|
||||
|
||||
std::unique_ptr<service_manager::Service> CreateVizService() {
|
||||
return std::make_unique<viz::Service>();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
UtilityServiceFactory::UtilityServiceFactory()
|
||||
@ -153,10 +149,6 @@ void UtilityServiceFactory::RegisterServices(ServiceMap* services) {
|
||||
}
|
||||
#endif // BUILDFLAG(ENABLE_CROS_LIBASSISTANT)
|
||||
#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(
|
||||
@ -183,6 +175,8 @@ bool UtilityServiceFactory::HandleServiceRequest(
|
||||
} else if (name == video_capture::mojom::kServiceName) {
|
||||
running_service_ =
|
||||
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)
|
||||
else if (name == media::mojom::kCdmServiceName) {
|
||||
|
@ -3,9 +3,9 @@
|
||||
# found in the LICENSE file.
|
||||
|
||||
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/service_manifest.gni")
|
||||
import("//mojo/public/tools/bindings/mojom.gni")
|
||||
|
||||
source_set("lib") {
|
||||
sources = [
|
||||
@ -27,6 +27,7 @@ source_set("lib") {
|
||||
}
|
||||
|
||||
service("catalog_viewer") {
|
||||
use_cpp_main = true
|
||||
sources = [
|
||||
"main.cc",
|
||||
]
|
||||
|
@ -207,7 +207,8 @@ class CatalogViewerContents : public views::WidgetDelegateView,
|
||||
|
||||
} // namespace
|
||||
|
||||
CatalogViewer::CatalogViewer() {
|
||||
CatalogViewer::CatalogViewer(service_manager::mojom::ServiceRequest request)
|
||||
: service_binding_(this, std::move(request)) {
|
||||
registry_.AddInterface<mojom::Launchable>(
|
||||
base::Bind(&CatalogViewer::Create, base::Unretained(this)));
|
||||
}
|
||||
@ -218,16 +219,16 @@ void CatalogViewer::RemoveWindow(views::Widget* window) {
|
||||
DCHECK(it != windows_.end());
|
||||
windows_.erase(it);
|
||||
if (windows_.empty())
|
||||
context()->QuitNow();
|
||||
Terminate();
|
||||
}
|
||||
|
||||
void CatalogViewer::OnStart() {
|
||||
views::AuraInit::InitParams params;
|
||||
params.connector = context()->connector();
|
||||
params.identity = context()->identity();
|
||||
params.connector = service_binding_.GetConnector();
|
||||
params.identity = service_binding_.identity();
|
||||
aura_init_ = views::AuraInit::Create(params);
|
||||
if (!aura_init_)
|
||||
context()->QuitNow();
|
||||
Terminate();
|
||||
}
|
||||
|
||||
void CatalogViewer::OnBindInterface(
|
||||
@ -245,7 +246,8 @@ void CatalogViewer::Launch(uint32_t what, mojom::LaunchMode how) {
|
||||
return;
|
||||
}
|
||||
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(
|
||||
new CatalogViewerContents(this, std::move(catalog)), nullptr,
|
||||
|
@ -14,6 +14,8 @@
|
||||
#include "mojo/public/cpp/bindings/binding_set.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_binding.h"
|
||||
#include "services/service_manager/public/mojom/service.mojom.h"
|
||||
|
||||
namespace views {
|
||||
class AuraInit;
|
||||
@ -26,7 +28,7 @@ namespace catalog_viewer {
|
||||
class CatalogViewer : public service_manager::Service,
|
||||
public mojom::Launchable {
|
||||
public:
|
||||
CatalogViewer();
|
||||
explicit CatalogViewer(service_manager::mojom::ServiceRequest request);
|
||||
~CatalogViewer() override;
|
||||
|
||||
void RemoveWindow(views::Widget* window);
|
||||
@ -43,6 +45,7 @@ class CatalogViewer : public service_manager::Service,
|
||||
|
||||
void Create(mojom::LaunchableRequest request);
|
||||
|
||||
service_manager::ServiceBinding service_binding_;
|
||||
mojo::BindingSet<mojom::Launchable> bindings_;
|
||||
std::vector<views::Widget*> windows_;
|
||||
|
||||
|
@ -2,12 +2,11 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "mash/catalog_viewer/catalog_viewer.h"
|
||||
#include "services/service_manager/public/c/main.h"
|
||||
#include "services/service_manager/public/cpp/service_runner.h"
|
||||
#include "services/service_manager/public/cpp/standalone_service/service_main.h"
|
||||
|
||||
MojoResult ServiceMain(MojoHandle service_request_handle) {
|
||||
service_manager::ServiceRunner runner(
|
||||
new mash::catalog_viewer::CatalogViewer);
|
||||
return runner.Run(service_request_handle);
|
||||
void ServiceMain(service_manager::mojom::ServiceRequest request) {
|
||||
base::MessageLoop message_loop;
|
||||
mash::catalog_viewer::CatalogViewer(std::move(request)).RunUntilTermination();
|
||||
}
|
||||
|
@ -3,14 +3,14 @@
|
||||
# found in the LICENSE file.
|
||||
|
||||
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/service_manifest.gni")
|
||||
import("//mojo/public/tools/bindings/mojom.gni")
|
||||
import("//tools/grit/repack.gni")
|
||||
|
||||
service("views_examples") {
|
||||
testonly = true
|
||||
|
||||
use_cpp_main = true
|
||||
sources = [
|
||||
"views_examples.cc",
|
||||
]
|
||||
|
@ -7,14 +7,15 @@
|
||||
|
||||
#include "base/macros.h"
|
||||
#include "base/memory/ptr_util.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "mash/public/mojom/launchable.mojom.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/connector.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_runner.h"
|
||||
#include "services/service_manager/public/cpp/service_binding.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/examples_window.h"
|
||||
#include "ui/views/mus/aura_init.h"
|
||||
@ -22,7 +23,8 @@
|
||||
class ViewsExamples : public service_manager::Service,
|
||||
public mash::mojom::Launchable {
|
||||
public:
|
||||
ViewsExamples() {
|
||||
explicit ViewsExamples(service_manager::mojom::ServiceRequest request)
|
||||
: service_binding_(this, std::move(request)) {
|
||||
registry_.AddInterface<mash::mojom::Launchable>(
|
||||
base::Bind(&ViewsExamples::Create, base::Unretained(this)));
|
||||
}
|
||||
@ -32,11 +34,11 @@ class ViewsExamples : public service_manager::Service,
|
||||
// service_manager::Service:
|
||||
void OnStart() override {
|
||||
views::AuraInit::InitParams params;
|
||||
params.connector = context()->connector();
|
||||
params.identity = context()->identity();
|
||||
params.connector = service_binding_.GetConnector();
|
||||
params.identity = service_binding_.identity();
|
||||
aura_init_ = views::AuraInit::Create(params);
|
||||
if (!aura_init_)
|
||||
context()->QuitNow();
|
||||
Terminate();
|
||||
}
|
||||
void OnBindInterface(const service_manager::BindSourceInfo& source_info,
|
||||
const std::string& interface_name,
|
||||
@ -47,14 +49,14 @@ class ViewsExamples : public service_manager::Service,
|
||||
// mash::mojom::Launchable:
|
||||
void Launch(uint32_t what, mash::mojom::LaunchMode how) override {
|
||||
views::examples::ShowExamplesWindow(
|
||||
base::BindOnce(&service_manager::ServiceContext::QuitNow,
|
||||
base::Unretained(context())));
|
||||
base::BindOnce(&ViewsExamples::Terminate, base::Unretained(this)));
|
||||
}
|
||||
|
||||
void Create(mash::mojom::LaunchableRequest request) {
|
||||
bindings_.AddBinding(this, std::move(request));
|
||||
}
|
||||
|
||||
service_manager::ServiceBinding service_binding_;
|
||||
mojo::BindingSet<mash::mojom::Launchable> bindings_;
|
||||
|
||||
service_manager::BinderRegistry registry_;
|
||||
@ -64,7 +66,7 @@ class ViewsExamples : public service_manager::Service,
|
||||
DISALLOW_COPY_AND_ASSIGN(ViewsExamples);
|
||||
};
|
||||
|
||||
MojoResult ServiceMain(MojoHandle service_request_handle) {
|
||||
return service_manager::ServiceRunner(new ViewsExamples)
|
||||
.Run(service_request_handle);
|
||||
void ServiceMain(service_manager::mojom::ServiceRequest request) {
|
||||
base::MessageLoop message_loop;
|
||||
ViewsExamples(std::move(request)).RunUntilTermination();
|
||||
}
|
||||
|
@ -3,14 +3,14 @@
|
||||
# found in the LICENSE file.
|
||||
|
||||
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/service_manifest.gni")
|
||||
import("//mojo/public/tools/bindings/mojom.gni")
|
||||
import("//tools/grit/repack.gni")
|
||||
|
||||
service("window_type_launcher") {
|
||||
testonly = true
|
||||
|
||||
use_cpp_main = true
|
||||
sources = [
|
||||
"window_type_launcher.cc",
|
||||
"window_type_launcher.h",
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
#include "base/macros.h"
|
||||
#include "base/memory/ptr_util.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "base/strings/string_number_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/cpp/connector.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_runner.h"
|
||||
#include "services/service_manager/public/cpp/standalone_service/service_main.h"
|
||||
#include "services/ws/public/cpp/property_type_converters.h"
|
||||
#include "services/ws/public/mojom/window_manager.mojom.h"
|
||||
#include "ui/aura/window.h"
|
||||
@ -438,7 +438,9 @@ class WindowTypeLauncherView : public views::WidgetDelegateView,
|
||||
|
||||
} // namespace
|
||||
|
||||
WindowTypeLauncher::WindowTypeLauncher() {
|
||||
WindowTypeLauncher::WindowTypeLauncher(
|
||||
service_manager::mojom::ServiceRequest request)
|
||||
: service_binding_(this, std::move(request)) {
|
||||
registry_.AddInterface<mash::mojom::Launchable>(
|
||||
base::Bind(&WindowTypeLauncher::Create, base::Unretained(this)));
|
||||
}
|
||||
@ -449,16 +451,16 @@ void WindowTypeLauncher::RemoveWindow(views::Widget* window) {
|
||||
DCHECK(it != windows_.end());
|
||||
windows_.erase(it);
|
||||
if (windows_.empty())
|
||||
context()->QuitNow();
|
||||
Terminate();
|
||||
}
|
||||
|
||||
void WindowTypeLauncher::OnStart() {
|
||||
views::AuraInit::InitParams params;
|
||||
params.connector = context()->connector();
|
||||
params.identity = context()->identity();
|
||||
params.connector = service_binding_.GetConnector();
|
||||
params.identity = service_binding_.identity();
|
||||
aura_init_ = views::AuraInit::Create(params);
|
||||
if (!aura_init_)
|
||||
context()->QuitNow();
|
||||
Terminate();
|
||||
}
|
||||
|
||||
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::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->Show();
|
||||
windows_.push_back(window);
|
||||
@ -487,7 +490,7 @@ void WindowTypeLauncher::Create(mash::mojom::LaunchableRequest request) {
|
||||
bindings_.AddBinding(this, std::move(request));
|
||||
}
|
||||
|
||||
MojoResult ServiceMain(MojoHandle service_request_handle) {
|
||||
return service_manager::ServiceRunner(new WindowTypeLauncher)
|
||||
.Run(service_request_handle);
|
||||
void ServiceMain(service_manager::mojom::ServiceRequest request) {
|
||||
base::MessageLoop message_loop;
|
||||
WindowTypeLauncher(std::move(request)).RunUntilTermination();
|
||||
}
|
||||
|
@ -12,6 +12,8 @@
|
||||
#include "mojo/public/cpp/bindings/binding_set.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_binding.h"
|
||||
#include "services/service_manager/public/mojom/service.mojom.h"
|
||||
|
||||
namespace views {
|
||||
class AuraInit;
|
||||
@ -21,7 +23,7 @@ class Widget;
|
||||
class WindowTypeLauncher : public service_manager::Service,
|
||||
public mash::mojom::Launchable {
|
||||
public:
|
||||
WindowTypeLauncher();
|
||||
explicit WindowTypeLauncher(service_manager::mojom::ServiceRequest request);
|
||||
~WindowTypeLauncher() override;
|
||||
|
||||
void RemoveWindow(views::Widget* window);
|
||||
@ -38,6 +40,7 @@ class WindowTypeLauncher : public service_manager::Service,
|
||||
|
||||
void Create(mash::mojom::LaunchableRequest request);
|
||||
|
||||
service_manager::ServiceBinding service_binding_;
|
||||
mojo::BindingSet<mash::mojom::Launchable> bindings_;
|
||||
std::vector<views::Widget*> windows_;
|
||||
|
||||
|
@ -3,9 +3,9 @@
|
||||
# found in the LICENSE file.
|
||||
|
||||
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/service_manifest.gni")
|
||||
import("//mojo/public/tools/bindings/mojom.gni")
|
||||
import("//tools/grit/repack.gni")
|
||||
|
||||
source_set("lib") {
|
||||
@ -33,7 +33,7 @@ source_set("lib") {
|
||||
|
||||
service("session") {
|
||||
output_name = "mash_session"
|
||||
|
||||
use_cpp_main = true
|
||||
sources = [
|
||||
"main.cc",
|
||||
]
|
||||
|
@ -2,11 +2,11 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "mash/session/session.h"
|
||||
#include "services/service_manager/public/c/main.h"
|
||||
#include "services/service_manager/public/cpp/service_runner.h"
|
||||
#include "services/service_manager/public/cpp/standalone_service/service_main.h"
|
||||
|
||||
MojoResult ServiceMain(MojoHandle service_request_handle) {
|
||||
service_manager::ServiceRunner runner(new mash::session::Session);
|
||||
return runner.Run(service_request_handle);
|
||||
void ServiceMain(service_manager::mojom::ServiceRequest request) {
|
||||
base::MessageLoop message_loop;
|
||||
mash::session::Session(std::move(request)).RunUntilTermination();
|
||||
}
|
||||
|
@ -8,7 +8,6 @@
|
||||
#include "base/command_line.h"
|
||||
#include "mash/common/config.h"
|
||||
#include "services/service_manager/public/cpp/connector.h"
|
||||
#include "services/service_manager/public/cpp/service_context.h"
|
||||
|
||||
#if defined(OS_CHROMEOS)
|
||||
#include "ash/components/quick_launch/public/mojom/constants.mojom.h" // nogncheck
|
||||
@ -17,7 +16,9 @@
|
||||
namespace mash {
|
||||
namespace session {
|
||||
|
||||
Session::Session() = default;
|
||||
Session::Session(service_manager::mojom::ServiceRequest request)
|
||||
: service_binding_(this, std::move(request)) {}
|
||||
|
||||
Session::~Session() = default;
|
||||
|
||||
void Session::OnStart() {
|
||||
@ -29,8 +30,9 @@ void Session::OnStart() {
|
||||
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
|
||||
quick_launch::mojom::kServiceName)) {
|
||||
// TODO(https://crbug.com/904148): This should not use |WarmService()|.
|
||||
context()->connector()->WarmService(service_manager::ServiceFilter::ByName(
|
||||
quick_launch::mojom::kServiceName));
|
||||
service_binding_.GetConnector()->WarmService(
|
||||
service_manager::ServiceFilter::ByName(
|
||||
quick_launch::mojom::kServiceName));
|
||||
}
|
||||
#endif // defined(OS_CHROMEOS)
|
||||
}
|
||||
@ -38,8 +40,9 @@ void Session::OnStart() {
|
||||
void Session::StartWindowManager() {
|
||||
// TODO(beng): monitor this service for death & bring down the whole system
|
||||
// if necessary.
|
||||
context()->connector()->WarmService(service_manager::ServiceFilter::ByName(
|
||||
common::GetWindowManagerServiceName()));
|
||||
service_binding_.GetConnector()->WarmService(
|
||||
service_manager::ServiceFilter::ByName(
|
||||
common::GetWindowManagerServiceName()));
|
||||
}
|
||||
|
||||
} // namespace session
|
||||
|
@ -7,13 +7,15 @@
|
||||
|
||||
#include "base/macros.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 session {
|
||||
|
||||
class Session : public service_manager::Service {
|
||||
public:
|
||||
Session();
|
||||
explicit Session(service_manager::mojom::ServiceRequest request);
|
||||
~Session() override;
|
||||
|
||||
private:
|
||||
@ -22,6 +24,8 @@ class Session : public service_manager::Service {
|
||||
|
||||
void StartWindowManager();
|
||||
|
||||
service_manager::ServiceBinding service_binding_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(Session);
|
||||
};
|
||||
|
||||
|
@ -3,9 +3,9 @@
|
||||
# found in the LICENSE file.
|
||||
|
||||
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/service_manifest.gni")
|
||||
import("//mojo/public/tools/bindings/mojom.gni")
|
||||
|
||||
source_set("lib") {
|
||||
sources = [
|
||||
@ -27,6 +27,7 @@ source_set("lib") {
|
||||
}
|
||||
|
||||
service("task_viewer") {
|
||||
use_cpp_main = true
|
||||
sources = [
|
||||
"main.cc",
|
||||
]
|
||||
|
@ -2,11 +2,11 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "mash/task_viewer/task_viewer.h"
|
||||
#include "services/service_manager/public/c/main.h"
|
||||
#include "services/service_manager/public/cpp/service_runner.h"
|
||||
#include "services/service_manager/public/cpp/standalone_service/service_main.h"
|
||||
|
||||
MojoResult ServiceMain(MojoHandle service_request_handle) {
|
||||
service_manager::ServiceRunner runner(new mash::task_viewer::TaskViewer);
|
||||
return runner.Run(service_request_handle);
|
||||
void ServiceMain(service_manager::mojom::ServiceRequest request) {
|
||||
base::MessageLoop message_loop;
|
||||
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/constants.mojom.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/service_manager.mojom.h"
|
||||
#include "ui/base/models/table_model.h"
|
||||
@ -282,10 +281,12 @@ class TaskViewerContents
|
||||
|
||||
} // namespace
|
||||
|
||||
TaskViewer::TaskViewer() {
|
||||
TaskViewer::TaskViewer(service_manager::mojom::ServiceRequest request)
|
||||
: service_binding_(this, std::move(request)) {
|
||||
registry_.AddInterface<::mash::mojom::Launchable>(
|
||||
base::Bind(&TaskViewer::Create, base::Unretained(this)));
|
||||
}
|
||||
|
||||
TaskViewer::~TaskViewer() = default;
|
||||
|
||||
void TaskViewer::RemoveWindow(views::Widget* widget) {
|
||||
@ -293,16 +294,16 @@ void TaskViewer::RemoveWindow(views::Widget* widget) {
|
||||
DCHECK(it != windows_.end());
|
||||
windows_.erase(it);
|
||||
if (windows_.empty())
|
||||
context()->QuitNow();
|
||||
Terminate();
|
||||
}
|
||||
|
||||
void TaskViewer::OnStart() {
|
||||
views::AuraInit::InitParams params;
|
||||
params.connector = context()->connector();
|
||||
params.identity = context()->identity();
|
||||
params.connector = service_binding_.GetConnector();
|
||||
params.identity = service_binding_.identity();
|
||||
aura_init_ = views::AuraInit::Create(params);
|
||||
if (!aura_init_)
|
||||
context()->QuitNow();
|
||||
Terminate();
|
||||
}
|
||||
|
||||
void TaskViewer::OnBindInterface(
|
||||
@ -321,11 +322,12 @@ void TaskViewer::Launch(uint32_t what, mojom::LaunchMode how) {
|
||||
}
|
||||
|
||||
service_manager::mojom::ServiceManagerPtr service_manager;
|
||||
context()->connector()->BindInterface(service_manager::mojom::kServiceName,
|
||||
&service_manager);
|
||||
service_binding_.GetConnector()->BindInterface(
|
||||
service_manager::mojom::kServiceName, &service_manager);
|
||||
|
||||
catalog::mojom::CatalogPtr catalog;
|
||||
context()->connector()->BindInterface(catalog::mojom::kServiceName, &catalog);
|
||||
service_binding_.GetConnector()->BindInterface(catalog::mojom::kServiceName,
|
||||
&catalog);
|
||||
|
||||
service_manager::mojom::ServiceManagerListenerPtr listener;
|
||||
TaskViewerContents* task_viewer = new TaskViewerContents(
|
||||
|
@ -14,6 +14,8 @@
|
||||
#include "mojo/public/cpp/bindings/binding_set.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_binding.h"
|
||||
#include "services/service_manager/public/mojom/service.mojom.h"
|
||||
|
||||
namespace views {
|
||||
class AuraInit;
|
||||
@ -26,7 +28,7 @@ namespace task_viewer {
|
||||
class TaskViewer : public service_manager::Service,
|
||||
public ::mash::mojom::Launchable {
|
||||
public:
|
||||
TaskViewer();
|
||||
explicit TaskViewer(service_manager::mojom::ServiceRequest request);
|
||||
~TaskViewer() override;
|
||||
|
||||
void RemoveWindow(views::Widget* widget);
|
||||
@ -43,6 +45,7 @@ class TaskViewer : public service_manager::Service,
|
||||
|
||||
void Create(::mash::mojom::LaunchableRequest request);
|
||||
|
||||
service_manager::ServiceBinding service_binding_;
|
||||
mojo::BindingSet<::mash::mojom::Launchable> bindings_;
|
||||
std::vector<views::Widget*> windows_;
|
||||
|
||||
|
@ -6,7 +6,6 @@
|
||||
|
||||
#include "build/build_config.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/public/mojom/constants.mojom.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")
|
||||
|
||||
service("viz") {
|
||||
use_cpp_main = true
|
||||
sources = [
|
||||
"main.cc",
|
||||
]
|
||||
|
@ -2,14 +2,11 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "services/service_manager/public/c/main.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"
|
||||
|
||||
MojoResult ServiceMain(MojoHandle service_request_handle) {
|
||||
viz::Service* viz_service = new viz::Service();
|
||||
service_manager::ServiceRunner runner(viz_service);
|
||||
runner.set_message_loop_type(base::MessageLoop::TYPE_UI);
|
||||
return runner.Run(service_request_handle);
|
||||
void ServiceMain(service_manager::mojom::ServiceRequest request) {
|
||||
base::MessageLoop message_loop(base::MessageLoop::TYPE_UI);
|
||||
viz::Service(std::move(request)).RunUntilTermination();
|
||||
}
|
||||
|
@ -5,12 +5,12 @@
|
||||
#include "services/viz/service.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"
|
||||
|
||||
namespace viz {
|
||||
|
||||
Service::Service() = default;
|
||||
Service::Service(service_manager::mojom::ServiceRequest request)
|
||||
: service_binding_(this, std::move(request)) {}
|
||||
|
||||
Service::~Service() = default;
|
||||
|
||||
@ -21,7 +21,7 @@ void Service::OnStart() {
|
||||
|
||||
VizMainImpl::ExternalDependencies deps;
|
||||
deps.create_display_compositor = true;
|
||||
deps.connector = context()->connector();
|
||||
deps.connector = service_binding_.GetConnector();
|
||||
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/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"
|
||||
|
||||
namespace viz {
|
||||
@ -15,7 +17,7 @@ class VizMainImpl;
|
||||
|
||||
class Service : public service_manager::Service {
|
||||
public:
|
||||
Service();
|
||||
explicit Service(service_manager::mojom::ServiceRequest request);
|
||||
~Service() override;
|
||||
|
||||
private:
|
||||
@ -27,6 +29,7 @@ class Service : public service_manager::Service {
|
||||
const std::string& interface_name,
|
||||
mojo::ScopedMessagePipeHandle interface_pipe) override;
|
||||
|
||||
service_manager::ServiceBinding service_binding_;
|
||||
service_manager::BinderRegistry registry_;
|
||||
|
||||
std::unique_ptr<VizMainImpl> viz_main_;
|
||||
|
@ -140,18 +140,17 @@ TEST(ScreenProviderTest, DisplaysSentOnConnection) {
|
||||
|
||||
// Create another WindowService.
|
||||
TestWindowServiceDelegate test_window_service_delegate;
|
||||
std::unique_ptr<WindowService> window_service_ptr =
|
||||
std::make_unique<WindowService>(&test_window_service_delegate, nullptr,
|
||||
test_setup.focus_controller());
|
||||
std::unique_ptr<service_manager::TestConnectorFactory> factory =
|
||||
service_manager::TestConnectorFactory::CreateForUniqueService(
|
||||
std::move(window_service_ptr));
|
||||
std::unique_ptr<service_manager::Connector> connector =
|
||||
factory->CreateConnector();
|
||||
WindowService window_service(&test_window_service_delegate, nullptr,
|
||||
test_setup.focus_controller());
|
||||
|
||||
service_manager::TestConnectorFactory factory;
|
||||
window_service.BindServiceRequest(
|
||||
factory.RegisterInstance(mojom::kServiceName));
|
||||
|
||||
// Connect to |window_service| and ask for a new WindowTree.
|
||||
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::WindowTreeClientPtr client;
|
||||
mojom::WindowTreeClientRequest client_request = MakeRequest(&client);
|
||||
|
@ -8,7 +8,7 @@ import("//services/service_manager/public/service_manifest.gni")
|
||||
|
||||
service("test_ws") {
|
||||
testonly = true
|
||||
|
||||
use_cpp_main = true
|
||||
sources = [
|
||||
"test_ws.cc",
|
||||
]
|
||||
|
@ -50,7 +50,9 @@ class TestWindowService::VisibilitySynchronizer : public aura::WindowTracker {
|
||||
DISALLOW_COPY_AND_ASSIGN(VisibilitySynchronizer);
|
||||
};
|
||||
|
||||
TestWindowService::TestWindowService() = default;
|
||||
TestWindowService::TestWindowService(
|
||||
service_manager::mojom::ServiceRequest request)
|
||||
: service_binding_(this, std::move(request)) {}
|
||||
|
||||
TestWindowService::~TestWindowService() {
|
||||
Shutdown(base::NullCallback());
|
||||
@ -176,16 +178,15 @@ void TestWindowService::CreateService(
|
||||
DCHECK(!ui_service_created_);
|
||||
ui_service_created_ = true;
|
||||
|
||||
auto window_service = std::make_unique<WindowService>(
|
||||
window_service_ = std::make_unique<WindowService>(
|
||||
this, std::move(gpu_interface_provider_),
|
||||
aura_test_helper_->focus_client(), /*decrement_client_ids=*/false,
|
||||
aura_test_helper_->GetEnv());
|
||||
test_host_event_dispatcher_ =
|
||||
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());
|
||||
service_context_ = std::make_unique<service_manager::ServiceContext>(
|
||||
std::move(window_service), std::move(request));
|
||||
window_service_->BindServiceRequest(std::move(request));
|
||||
pid_receiver->SetPID(base::GetCurrentProcId());
|
||||
}
|
||||
|
||||
@ -204,7 +205,7 @@ void TestWindowService::MaximizeNextWindow(MaximizeNextWindowCallback cb) {
|
||||
void TestWindowService::Shutdown(
|
||||
test_ws::mojom::TestWs::ShutdownCallback callback) {
|
||||
// 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.
|
||||
if (aura_test_helper_) {
|
||||
@ -235,7 +236,8 @@ void TestWindowService::CreateGpuHost() {
|
||||
std::make_unique<discardable_memory::DiscardableSharedMemoryManager>();
|
||||
|
||||
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_host_.get(), discardable_shared_memory_manager_.get());
|
||||
|
@ -13,7 +13,8 @@
|
||||
#include "mojo/public/cpp/bindings/binding_set.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_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/ws/gpu_host/gpu_host.h"
|
||||
#include "services/ws/gpu_host/gpu_host_delegate.h"
|
||||
@ -35,6 +36,7 @@ namespace ws {
|
||||
|
||||
class HostEventQueue;
|
||||
class TestHostEventDispatcher;
|
||||
class WindowService;
|
||||
|
||||
namespace test {
|
||||
|
||||
@ -46,7 +48,7 @@ class TestWindowService : public service_manager::Service,
|
||||
public WindowServiceDelegate,
|
||||
public test_ws::mojom::TestWs {
|
||||
public:
|
||||
TestWindowService();
|
||||
explicit TestWindowService(service_manager::mojom::ServiceRequest request);
|
||||
~TestWindowService() override;
|
||||
|
||||
void InitForInProcess(
|
||||
@ -106,14 +108,14 @@ class TestWindowService : public service_manager::Service,
|
||||
void SetupAuraTestHelper(ui::ContextFactory* context_factory,
|
||||
ui::ContextFactoryPrivate* context_factory_private);
|
||||
|
||||
service_manager::ServiceBinding service_binding_;
|
||||
service_manager::BinderRegistry registry_;
|
||||
|
||||
mojo::BindingSet<service_manager::mojom::ServiceFactory>
|
||||
service_factory_bindings_;
|
||||
mojo::BindingSet<test_ws::mojom::TestWs> test_ws_bindings_;
|
||||
|
||||
// Handles the ServiceRequest. Owns the WindowService instance.
|
||||
std::unique_ptr<service_manager::ServiceContext> service_context_;
|
||||
std::unique_ptr<WindowService> window_service_;
|
||||
|
||||
std::unique_ptr<aura::test::AuraTestHelper> aura_test_helper_;
|
||||
|
||||
|
@ -16,16 +16,17 @@ namespace test {
|
||||
std::unique_ptr<service_manager::Service> CreateInProcessWindowService(
|
||||
ui::ContextFactory* context_factory,
|
||||
ui::ContextFactoryPrivate* context_factory_private,
|
||||
std::unique_ptr<GpuInterfaceProvider> gpu_interface_provider) {
|
||||
auto window_service = std::make_unique<TestWindowService>();
|
||||
std::unique_ptr<GpuInterfaceProvider> gpu_interface_provider,
|
||||
service_manager::mojom::ServiceRequest request) {
|
||||
auto window_service = std::make_unique<TestWindowService>(std::move(request));
|
||||
window_service->InitForInProcess(context_factory, context_factory_private,
|
||||
std::move(gpu_interface_provider));
|
||||
return window_service;
|
||||
}
|
||||
|
||||
std::unique_ptr<service_manager::Service> CreateOutOfProcessWindowService() {
|
||||
auto window_service = std::make_unique<TestWindowService>();
|
||||
return window_service;
|
||||
std::unique_ptr<service_manager::Service> CreateOutOfProcessWindowService(
|
||||
service_manager::mojom::ServiceRequest request) {
|
||||
return std::make_unique<TestWindowService>(std::move(request));
|
||||
}
|
||||
|
||||
} // namespace test
|
||||
|
@ -7,6 +7,8 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "services/service_manager/public/mojom/service.mojom.h"
|
||||
|
||||
namespace service_manager {
|
||||
class Service;
|
||||
} // namespace service_manager
|
||||
@ -26,9 +28,11 @@ namespace test {
|
||||
std::unique_ptr<service_manager::Service> CreateInProcessWindowService(
|
||||
ui::ContextFactory* context_factory,
|
||||
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 ws
|
||||
|
@ -3,18 +3,14 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
#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_runner.h"
|
||||
#include "services/service_manager/public/cpp/standalone_service/service_main.h"
|
||||
#include "services/ws/test_ws/test_window_service_factory.h"
|
||||
#include "ui/base/ui_base_paths.h"
|
||||
|
||||
MojoResult ServiceMain(MojoHandle service_request_handle) {
|
||||
void ServiceMain(service_manager::mojom::ServiceRequest request) {
|
||||
ui::RegisterPathProvider();
|
||||
|
||||
// |runner| takes ownership of the created test_ws service.
|
||||
service_manager::ServiceRunner runner(
|
||||
ws::test::CreateOutOfProcessWindowService().release());
|
||||
runner.set_message_loop_type(base::MessageLoop::TYPE_UI);
|
||||
return runner.Run(service_request_handle);
|
||||
base::MessageLoop message_loop(base::MessageLoop::TYPE_UI);
|
||||
auto service = ws::test::CreateOutOfProcessWindowService(std::move(request));
|
||||
service->RunUntilTermination();
|
||||
}
|
||||
|
@ -79,6 +79,12 @@ WindowService::~WindowService() {
|
||||
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(
|
||||
aura::Window* window) {
|
||||
ServerWindow* server_window = ServerWindow::GetMayBeNull(window);
|
||||
|
@ -16,6 +16,8 @@
|
||||
#include "base/observer_list.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_binding.h"
|
||||
#include "services/service_manager/public/mojom/service.mojom.h"
|
||||
#include "services/ws/ids.h"
|
||||
#include "services/ws/ime/ime_driver_bridge.h"
|
||||
#include "services/ws/ime/ime_registrar_impl.h"
|
||||
@ -87,6 +89,10 @@ class COMPONENT_EXPORT(WINDOW_SERVICE) WindowService
|
||||
aura::Env* env = nullptr);
|
||||
~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.
|
||||
ServerWindow* GetServerWindowForWindowCreateIfNecessary(aura::Window* window);
|
||||
|
||||
@ -219,6 +225,8 @@ class COMPONENT_EXPORT(WINDOW_SERVICE) WindowService
|
||||
|
||||
aura::Env* env_;
|
||||
|
||||
service_manager::ServiceBinding service_binding_{this};
|
||||
|
||||
// GpuInterfaceProvider may be null in tests.
|
||||
std::unique_ptr<GpuInterfaceProvider> gpu_interface_provider_;
|
||||
|
||||
|
@ -36,19 +36,16 @@ TEST(WindowServiceTest, DeleteWithClients) {
|
||||
|
||||
// Create another WindowService.
|
||||
TestWindowServiceDelegate test_window_service_delegate;
|
||||
std::unique_ptr<WindowService> window_service_ptr =
|
||||
std::make_unique<WindowService>(&test_window_service_delegate, nullptr,
|
||||
test_setup.focus_controller());
|
||||
WindowService* window_service = window_service_ptr.get();
|
||||
std::unique_ptr<service_manager::TestConnectorFactory> factory =
|
||||
service_manager::TestConnectorFactory::CreateForUniqueService(
|
||||
std::move(window_service_ptr));
|
||||
std::unique_ptr<service_manager::Connector> connector =
|
||||
factory->CreateConnector();
|
||||
WindowService window_service(&test_window_service_delegate, nullptr,
|
||||
test_setup.focus_controller());
|
||||
service_manager::TestConnectorFactory factory;
|
||||
window_service.BindServiceRequest(
|
||||
factory.RegisterInstance(mojom::kServiceName));
|
||||
|
||||
// Connect to |window_service| and ask for a new WindowTree.
|
||||
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::WindowTreeClientPtr client;
|
||||
mojom::WindowTreeClientRequest client_request = MakeRequest(&client);
|
||||
@ -59,7 +56,7 @@ TEST(WindowServiceTest, DeleteWithClients) {
|
||||
window_tree_factory.FlushForTesting();
|
||||
|
||||
// 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
|
||||
// ensure a DCHECK isn't hit in ~WindowTree.
|
||||
@ -116,18 +113,16 @@ TEST(WindowServiceTest, GetWindowManagerInterface) {
|
||||
|
||||
// Create another WindowService.
|
||||
TestWindowServiceDelegateWithInterface test_window_service_delegate;
|
||||
std::unique_ptr<WindowService> window_service_ptr =
|
||||
std::make_unique<WindowService>(&test_window_service_delegate, nullptr,
|
||||
test_setup.focus_controller());
|
||||
std::unique_ptr<service_manager::TestConnectorFactory> factory =
|
||||
service_manager::TestConnectorFactory::CreateForUniqueService(
|
||||
std::move(window_service_ptr));
|
||||
std::unique_ptr<service_manager::Connector> connector =
|
||||
factory->CreateConnector();
|
||||
WindowService window_service(&test_window_service_delegate, nullptr,
|
||||
test_setup.focus_controller());
|
||||
service_manager::TestConnectorFactory factory;
|
||||
window_service.BindServiceRequest(
|
||||
factory.RegisterInstance(mojom::kServiceName));
|
||||
|
||||
// Connect to |window_service| and ask for a new WindowTree.
|
||||
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::WindowTreeClientPtr 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/constants.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 "testing/gtest/include/gtest/gtest.h"
|
||||
#include "ui/aura/env.h"
|
||||
@ -51,24 +51,11 @@ void EnsureCommandLineSwitch(const std::string& 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 {
|
||||
public:
|
||||
ServiceManagerConnection()
|
||||
: thread_("Persistent service_manager connections") {
|
||||
: thread_("Persistent service_manager connections"),
|
||||
default_service_binding_(&default_service_) {
|
||||
catalog::Catalog::LoadDefaultCatalogManifest(
|
||||
base::FilePath(kCatalogFilename));
|
||||
base::WaitableEvent wait(base::WaitableEvent::ResetPolicy::AUTOMATIC,
|
||||
@ -115,7 +102,8 @@ class ServiceManagerConnection {
|
||||
}
|
||||
|
||||
void CloneConnector(base::WaitableEvent* wait) {
|
||||
service_manager_connector_ = context_->connector()->Clone();
|
||||
service_manager_connector_ =
|
||||
default_service_binding_.GetConnector()->Clone();
|
||||
wait->Signal();
|
||||
}
|
||||
|
||||
@ -124,20 +112,20 @@ class ServiceManagerConnection {
|
||||
std::make_unique<service_manager::BackgroundServiceManager>(nullptr,
|
||||
nullptr);
|
||||
service_manager::mojom::ServicePtr service;
|
||||
context_ = std::make_unique<service_manager::ServiceContext>(
|
||||
std::make_unique<DefaultService>(), mojo::MakeRequest(&service));
|
||||
default_service_binding_.Bind(mojo::MakeRequest(&service));
|
||||
background_service_manager_->RegisterService(
|
||||
service_manager::Identity(GetTestName(),
|
||||
service_manager::kSystemInstanceGroup,
|
||||
base::Token{}, base::Token::CreateRandom()),
|
||||
std::move(service), nullptr);
|
||||
service_manager_connector_ = context_->connector()->Clone();
|
||||
service_manager_identity_ = context_->identity();
|
||||
service_manager_connector_ =
|
||||
default_service_binding_.GetConnector()->Clone();
|
||||
service_manager_identity_ = default_service_binding_.identity();
|
||||
wait->Signal();
|
||||
}
|
||||
|
||||
void TearDownConnectionsOnBackgroundThread(base::WaitableEvent* wait) {
|
||||
context_.reset();
|
||||
default_service_binding_.Close();
|
||||
background_service_manager_.reset();
|
||||
wait->Signal();
|
||||
}
|
||||
@ -154,7 +142,8 @@ class ServiceManagerConnection {
|
||||
base::Thread thread_;
|
||||
std::unique_ptr<service_manager::BackgroundServiceManager>
|
||||
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_;
|
||||
service_manager::Identity service_manager_identity_;
|
||||
|
||||
|
Reference in New Issue
Block a user