OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef COMPONENTS_SURFACES_SURFACES_SERVICE_APPLICATION_H_ | 5 #ifndef COMPONENTS_SURFACES_SURFACES_SERVICE_APPLICATION_H_ |
6 #define COMPONENTS_SURFACES_SURFACES_SERVICE_APPLICATION_H_ | 6 #define COMPONENTS_SURFACES_SURFACES_SERVICE_APPLICATION_H_ |
7 | 7 |
| 8 #include <set> |
| 9 |
8 #include "base/macros.h" | 10 #include "base/macros.h" |
9 #include "cc/surfaces/surface_manager.h" | 11 #include "cc/surfaces/surface_manager.h" |
10 #include "components/surfaces/public/interfaces/display.mojom.h" | 12 #include "components/surfaces/public/interfaces/display.mojom.h" |
11 #include "components/surfaces/public/interfaces/surfaces.mojom.h" | 13 #include "components/surfaces/public/interfaces/surfaces.mojom.h" |
12 #include "mojo/application/public/cpp/application_delegate.h" | 14 #include "mojo/application/public/cpp/application_delegate.h" |
13 #include "mojo/application/public/cpp/interface_factory.h" | 15 #include "mojo/application/public/cpp/interface_factory.h" |
14 #include "mojo/common/tracing_impl.h" | 16 #include "mojo/common/tracing_impl.h" |
15 | 17 |
16 namespace mojo { | 18 namespace mojo { |
17 class ApplicationConnection; | 19 class ApplicationConnection; |
18 } | 20 } |
19 | 21 |
20 namespace surfaces { | 22 namespace surfaces { |
| 23 class DisplayFactoryImpl; |
| 24 class SurfacesImpl; |
21 class SurfacesScheduler; | 25 class SurfacesScheduler; |
22 | 26 |
23 class SurfacesServiceApplication | 27 class SurfacesServiceApplication |
24 : public mojo::ApplicationDelegate, | 28 : public mojo::ApplicationDelegate, |
25 public mojo::InterfaceFactory<mojo::DisplayFactory>, | 29 public mojo::InterfaceFactory<mojo::DisplayFactory>, |
26 public mojo::InterfaceFactory<mojo::Surface> { | 30 public mojo::InterfaceFactory<mojo::Surface> { |
27 public: | 31 public: |
28 SurfacesServiceApplication(); | 32 SurfacesServiceApplication(); |
29 ~SurfacesServiceApplication() override; | 33 ~SurfacesServiceApplication() override; |
30 | 34 |
31 // ApplicationDelegate implementation. | 35 // ApplicationDelegate implementation. |
32 void Initialize(mojo::ApplicationImpl* app) override; | 36 void Initialize(mojo::ApplicationImpl* app) override; |
33 bool ConfigureIncomingConnection( | 37 bool ConfigureIncomingConnection( |
34 mojo::ApplicationConnection* connection) override; | 38 mojo::ApplicationConnection* connection) override; |
35 | 39 |
36 // InterfaceFactory<DisplayFactory> implementation. | 40 // InterfaceFactory<DisplayFactory> implementation. |
37 void Create(mojo::ApplicationConnection* connection, | 41 void Create(mojo::ApplicationConnection* connection, |
38 mojo::InterfaceRequest<mojo::DisplayFactory> request) override; | 42 mojo::InterfaceRequest<mojo::DisplayFactory> request) override; |
39 | 43 |
40 // InterfaceFactory<Surface> implementation. | 44 // InterfaceFactory<Surface> implementation. |
41 void Create(mojo::ApplicationConnection* connection, | 45 void Create(mojo::ApplicationConnection* connection, |
42 mojo::InterfaceRequest<mojo::Surface> request) override; | 46 mojo::InterfaceRequest<mojo::Surface> request) override; |
43 | 47 |
| 48 void DisplayFactoryDestroyed(DisplayFactoryImpl* display_factory); |
| 49 void SurfaceDestroyed(SurfacesImpl* surface); |
| 50 |
44 private: | 51 private: |
45 cc::SurfaceManager manager_; | 52 cc::SurfaceManager manager_; |
46 uint32_t next_id_namespace_; | 53 uint32_t next_id_namespace_; |
47 scoped_ptr<SurfacesScheduler> scheduler_; | 54 scoped_ptr<SurfacesScheduler> scheduler_; |
48 mojo::TracingImpl tracing_; | 55 mojo::TracingImpl tracing_; |
49 | 56 |
| 57 // Since these two classes have non-owning pointers to |manager_|, need to |
| 58 // destroy them if this class is destructed first. |
| 59 std::set<DisplayFactoryImpl*> display_factories_; |
| 60 std::set<SurfacesImpl*> surfaces_; |
| 61 |
50 DISALLOW_COPY_AND_ASSIGN(SurfacesServiceApplication); | 62 DISALLOW_COPY_AND_ASSIGN(SurfacesServiceApplication); |
51 }; | 63 }; |
52 | 64 |
53 } // namespace surfaces | 65 } // namespace surfaces |
54 | 66 |
55 #endif // COMPONENTS_SURFACES_SURFACES_SERVICE_APPLICATION_H_ | 67 #endif // COMPONENTS_SURFACES_SURFACES_SERVICE_APPLICATION_H_ |
OLD | NEW |