| 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 DisplayImpl; |
| 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 DisplayCreated(DisplayImpl* display); |
| 49 void DisplayDestroyed(DisplayImpl* display); |
| 50 void SurfaceDestroyed(SurfacesImpl* surface); |
| 51 |
| 44 private: | 52 private: |
| 45 cc::SurfaceManager manager_; | 53 cc::SurfaceManager manager_; |
| 46 uint32_t next_id_namespace_; | 54 uint32_t next_id_namespace_; |
| 47 scoped_ptr<SurfacesScheduler> scheduler_; | 55 scoped_ptr<SurfacesScheduler> scheduler_; |
| 48 mojo::TracingImpl tracing_; | 56 mojo::TracingImpl tracing_; |
| 49 | 57 |
| 58 // Since these two classes have non-owning pointers to |manager_|, need to |
| 59 // destroy them if this class is destructed first. |
| 60 std::set<DisplayImpl*> displays_; |
| 61 std::set<SurfacesImpl*> surfaces_; |
| 62 |
| 50 DISALLOW_COPY_AND_ASSIGN(SurfacesServiceApplication); | 63 DISALLOW_COPY_AND_ASSIGN(SurfacesServiceApplication); |
| 51 }; | 64 }; |
| 52 | 65 |
| 53 } // namespace surfaces | 66 } // namespace surfaces |
| 54 | 67 |
| 55 #endif // COMPONENTS_SURFACES_SURFACES_SERVICE_APPLICATION_H_ | 68 #endif // COMPONENTS_SURFACES_SURFACES_SERVICE_APPLICATION_H_ |
| OLD | NEW |