blob: ae7f9edc2c1bd0349c1f13b2ba7beaf6a8bd1a8f [file] [log] [blame]
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <memory>
#include "ash/ash_export.h"
#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;
namespace ui {
namespace ws2 {
class GpuInterfaceProvider;
class WindowService;
} // namespace ws2
} // namespace ui
namespace ash {
class WindowServiceDelegateImpl;
// WindowServiceOwner indirectly owns the WindowService. This class is
// responsible for responding to the ServiceRequest for the WindowService. When
// BindWindowService() is called the WindowService is created.
class ASH_EXPORT WindowServiceOwner {
explicit WindowServiceOwner(
std::unique_ptr<ui::ws2::GpuInterfaceProvider> gpu_interface_provider);
// Called from the ServiceManager when a request is made for the
// WindowService.
void BindWindowService(service_manager::mojom::ServiceRequest request);
// Returns the WindowService, or null if BindWindowService() hasn't been
// called yet.
ui::ws2::WindowService* window_service() { return window_service_; }
friend class AshTestHelper;
// Non-null until |service_context_| is created.
std::unique_ptr<ui::ws2::GpuInterfaceProvider> gpu_interface_provider_;
// The following state is created once BindWindowService() is called.
std::unique_ptr<WindowServiceDelegateImpl> window_service_delegate_;
// Handles the ServiceRequest. Owns |window_service_|.
std::unique_ptr<service_manager::ServiceContext> service_context_;
// The WindowService. This is owned by |service_context_|.
ui::ws2::WindowService* window_service_;
} // namespace ash