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 #include "components/surfaces/surfaces_service_application.h" | 5 #include "components/surfaces/surfaces_service_application.h" |
6 | 6 |
| 7 #include "base/stl_util.h" |
7 #include "components/surfaces/display_factory_impl.h" | 8 #include "components/surfaces/display_factory_impl.h" |
8 #include "components/surfaces/surfaces_impl.h" | 9 #include "components/surfaces/surfaces_impl.h" |
9 #include "components/surfaces/surfaces_scheduler.h" | 10 #include "components/surfaces/surfaces_scheduler.h" |
10 | 11 |
11 namespace surfaces { | 12 namespace surfaces { |
12 | 13 |
13 SurfacesServiceApplication::SurfacesServiceApplication() | 14 SurfacesServiceApplication::SurfacesServiceApplication() |
14 : next_id_namespace_(1u) { | 15 : next_id_namespace_(1u) { |
15 } | 16 } |
16 | 17 |
17 SurfacesServiceApplication::~SurfacesServiceApplication() { | 18 SurfacesServiceApplication::~SurfacesServiceApplication() { |
| 19 STLDeleteElements(&display_factories_); |
| 20 STLDeleteElements(&surfaces_); |
18 } | 21 } |
19 | 22 |
20 void SurfacesServiceApplication::Initialize(mojo::ApplicationImpl* app) { | 23 void SurfacesServiceApplication::Initialize(mojo::ApplicationImpl* app) { |
21 tracing_.Initialize(app); | 24 tracing_.Initialize(app); |
22 scheduler_.reset(new SurfacesScheduler); | 25 scheduler_.reset(new SurfacesScheduler); |
23 } | 26 } |
24 | 27 |
25 bool SurfacesServiceApplication::ConfigureIncomingConnection( | 28 bool SurfacesServiceApplication::ConfigureIncomingConnection( |
26 mojo::ApplicationConnection* connection) { | 29 mojo::ApplicationConnection* connection) { |
27 connection->AddService<mojo::DisplayFactory>(this); | 30 connection->AddService<mojo::DisplayFactory>(this); |
28 connection->AddService<mojo::Surface>(this); | 31 connection->AddService<mojo::Surface>(this); |
29 return true; | 32 return true; |
30 } | 33 } |
31 | 34 |
32 void SurfacesServiceApplication::Create( | 35 void SurfacesServiceApplication::Create( |
33 mojo::ApplicationConnection* connection, | 36 mojo::ApplicationConnection* connection, |
34 mojo::InterfaceRequest<mojo::DisplayFactory> request) { | 37 mojo::InterfaceRequest<mojo::DisplayFactory> request) { |
35 new DisplayFactoryImpl(&manager_, next_id_namespace_++, scheduler_.get(), | 38 display_factories_.insert( |
36 request.Pass()); | 39 new DisplayFactoryImpl(this, &manager_, next_id_namespace_++, |
| 40 scheduler_.get(), request.Pass())); |
37 } | 41 } |
38 | 42 |
39 void SurfacesServiceApplication::Create( | 43 void SurfacesServiceApplication::Create( |
40 mojo::ApplicationConnection* connection, | 44 mojo::ApplicationConnection* connection, |
41 mojo::InterfaceRequest<mojo::Surface> request) { | 45 mojo::InterfaceRequest<mojo::Surface> request) { |
42 new SurfacesImpl(&manager_, next_id_namespace_++, scheduler_.get(), | 46 surfaces_.insert( |
43 request.Pass()); | 47 new SurfacesImpl(this, &manager_, next_id_namespace_++, scheduler_.get(), |
| 48 request.Pass())); |
| 49 } |
| 50 |
| 51 void SurfacesServiceApplication::DisplayFactoryDestroyed( |
| 52 DisplayFactoryImpl* display_factory) { |
| 53 display_factories_.erase(display_factory); |
| 54 } |
| 55 |
| 56 void SurfacesServiceApplication::SurfaceDestroyed(SurfacesImpl* surface) { |
| 57 surfaces_.erase(surface); |
44 } | 58 } |
45 | 59 |
46 } // namespace surfaces | 60 } // namespace surfaces |
OLD | NEW |