Chromium Code Reviews| 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 // Make a copy of the sets before deleting them because their destructor will | |
| 20 // call back into this class to remove them from the set. | |
| 21 auto displays = displays_; | |
| 22 STLDeleteElements(&displays_); | |
|
Elliot Glaysher
2015/05/18 17:41:29
I suspect that autocomplete went out of control he
jam
2015/05/18 17:44:20
oops, fixed, thanks.
| |
| 23 auto surfaces = surfaces_; | |
| 24 STLDeleteElements(&surfaces); | |
| 18 } | 25 } |
| 19 | 26 |
| 20 void SurfacesServiceApplication::Initialize(mojo::ApplicationImpl* app) { | 27 void SurfacesServiceApplication::Initialize(mojo::ApplicationImpl* app) { |
| 21 tracing_.Initialize(app); | 28 tracing_.Initialize(app); |
| 22 scheduler_.reset(new SurfacesScheduler); | 29 scheduler_.reset(new SurfacesScheduler); |
| 23 } | 30 } |
| 24 | 31 |
| 25 bool SurfacesServiceApplication::ConfigureIncomingConnection( | 32 bool SurfacesServiceApplication::ConfigureIncomingConnection( |
| 26 mojo::ApplicationConnection* connection) { | 33 mojo::ApplicationConnection* connection) { |
| 27 connection->AddService<mojo::DisplayFactory>(this); | 34 connection->AddService<mojo::DisplayFactory>(this); |
| 28 connection->AddService<mojo::Surface>(this); | 35 connection->AddService<mojo::Surface>(this); |
| 29 return true; | 36 return true; |
| 30 } | 37 } |
| 31 | 38 |
| 32 void SurfacesServiceApplication::Create( | 39 void SurfacesServiceApplication::Create( |
| 33 mojo::ApplicationConnection* connection, | 40 mojo::ApplicationConnection* connection, |
| 34 mojo::InterfaceRequest<mojo::DisplayFactory> request) { | 41 mojo::InterfaceRequest<mojo::DisplayFactory> request) { |
| 35 new DisplayFactoryImpl(&manager_, next_id_namespace_++, scheduler_.get(), | 42 new DisplayFactoryImpl(this, &manager_, next_id_namespace_++, |
| 36 request.Pass()); | 43 scheduler_.get(), request.Pass()); |
| 37 } | 44 } |
| 38 | 45 |
| 39 void SurfacesServiceApplication::Create( | 46 void SurfacesServiceApplication::Create( |
| 40 mojo::ApplicationConnection* connection, | 47 mojo::ApplicationConnection* connection, |
| 41 mojo::InterfaceRequest<mojo::Surface> request) { | 48 mojo::InterfaceRequest<mojo::Surface> request) { |
| 42 new SurfacesImpl(&manager_, next_id_namespace_++, scheduler_.get(), | 49 surfaces_.insert( |
| 43 request.Pass()); | 50 new SurfacesImpl(this, &manager_, next_id_namespace_++, scheduler_.get(), |
| 51 request.Pass())); | |
| 52 } | |
| 53 | |
| 54 void SurfacesServiceApplication::DisplayCreated(DisplayImpl* display) { | |
| 55 displays_.insert(display); | |
| 56 } | |
| 57 | |
| 58 void SurfacesServiceApplication::DisplayDestroyed(DisplayImpl* display) { | |
| 59 displays_.erase(display); | |
| 60 } | |
| 61 | |
| 62 void SurfacesServiceApplication::SurfaceDestroyed(SurfacesImpl* surface) { | |
| 63 surfaces_.erase(surface); | |
| 44 } | 64 } |
| 45 | 65 |
| 46 } // namespace surfaces | 66 } // namespace surfaces |
| OLD | NEW |