Mandoline: Merge Surfaces and Views apps
[chromium-blink-merge.git] / components / view_manager / view_manager_app.h
blobdbe5cef209ddc2aeb71158e0874acd59441ebf29
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_VIEW_MANAGER_VIEW_MANAGER_APP_H_
6 #define COMPONENTS_VIEW_MANAGER_VIEW_MANAGER_APP_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "cc/surfaces/surface_manager.h"
10 #include "components/view_manager/connection_manager_delegate.h"
11 #include "components/view_manager/gles2/gpu_impl.h"
12 #include "components/view_manager/public/interfaces/surfaces.mojom.h"
13 #include "components/view_manager/public/interfaces/view_manager.mojom.h"
14 #include "components/view_manager/public/interfaces/view_manager_root.mojom.h"
15 #include "components/view_manager/surfaces/surfaces_delegate.h"
16 #include "components/view_manager/surfaces/surfaces_state.h"
17 #include "mojo/application/public/cpp/app_lifetime_helper.h"
18 #include "mojo/application/public/cpp/application_delegate.h"
19 #include "mojo/application/public/cpp/interface_factory.h"
20 #include "mojo/common/tracing_impl.h"
22 namespace mojo {
23 class ApplicationImpl;
26 namespace surfaces {
27 class DisplayImpl;
28 class SurfacesImpl;
29 class SurfacesScheduler;
32 namespace ui {
33 class PlatformEventSource;
36 namespace view_manager {
38 class ConnectionManager;
40 class ViewManagerApp : public mojo::ApplicationDelegate,
41 public ConnectionManagerDelegate,
42 public mojo::InterfaceFactory<mojo::Surface>,
43 public mojo::InterfaceFactory<mojo::ViewManagerRoot>,
44 public mojo::InterfaceFactory<mojo::Gpu>,
45 public surfaces::SurfacesDelegate {
46 public:
47 ViewManagerApp();
48 ~ViewManagerApp() override;
50 private:
51 // ApplicationDelegate:
52 void Initialize(mojo::ApplicationImpl* app) override;
53 bool ConfigureIncomingConnection(
54 mojo::ApplicationConnection* connection) override;
56 // ConnectionManagerDelegate:
57 void OnNoMoreRootConnections() override;
58 ClientConnection* CreateClientConnectionForEmbedAtView(
59 ConnectionManager* connection_manager,
60 mojo::InterfaceRequest<mojo::ViewManagerService> service_request,
61 mojo::ConnectionSpecificId creator_id,
62 mojo::URLRequestPtr request,
63 const ViewId& root_id) override;
64 ClientConnection* CreateClientConnectionForEmbedAtView(
65 ConnectionManager* connection_manager,
66 mojo::InterfaceRequest<mojo::ViewManagerService> service_request,
67 mojo::ConnectionSpecificId creator_id,
68 const ViewId& root_id,
69 mojo::ViewManagerClientPtr view_manager_client) override;
71 // mojo::InterfaceFactory<mojo::ViewManagerRoot>:
72 void Create(mojo::ApplicationConnection* connection,
73 mojo::InterfaceRequest<mojo::ViewManagerRoot> request) override;
75 // mojo::InterfaceFactory<mojo::Gpu> implementation.
76 void Create(mojo::ApplicationConnection* connection,
77 mojo::InterfaceRequest<mojo::Gpu> request) override;
79 // InterfaceFactory<Surface> implementation.
80 void Create(mojo::ApplicationConnection* connection,
81 mojo::InterfaceRequest<mojo::Surface> request) override;
83 // SurfacesDelegat implementation.
84 void OnSurfaceConnectionClosed(surfaces::SurfacesImpl* surface) override;
86 // ViewManager
87 mojo::ApplicationImpl* app_impl_;
88 scoped_ptr<ConnectionManager> connection_manager_;
89 mojo::TracingImpl tracing_;
90 scoped_refptr<gles2::GpuState> gpu_state_;
91 scoped_ptr<ui::PlatformEventSource> event_source_;
92 bool is_headless_;
94 // Surfaces
95 std::set<surfaces::SurfacesImpl*> surfaces_;
96 scoped_refptr<surfaces::SurfacesState> surfaces_state_;
98 DISALLOW_COPY_AND_ASSIGN(ViewManagerApp);
101 } // namespace view_manager
103 #endif // COMPONENTS_VIEW_MANAGER_VIEW_MANAGER_APP_H_