Chromium Code Reviews| Index: components/surfaces/surfaces_service_application.cc |
| diff --git a/components/surfaces/surfaces_service_application.cc b/components/surfaces/surfaces_service_application.cc |
| index 172a394dd727cdf7c73229239d3eab3b67685f67..af70f763fcea3ef1747527bebafc87325917560c 100644 |
| --- a/components/surfaces/surfaces_service_application.cc |
| +++ b/components/surfaces/surfaces_service_application.cc |
| @@ -4,6 +4,7 @@ |
| #include "components/surfaces/surfaces_service_application.h" |
| +#include "base/stl_util.h" |
| #include "components/surfaces/display_factory_impl.h" |
| #include "components/surfaces/surfaces_impl.h" |
| #include "components/surfaces/surfaces_scheduler.h" |
| @@ -15,6 +16,12 @@ SurfacesServiceApplication::SurfacesServiceApplication() |
| } |
| SurfacesServiceApplication::~SurfacesServiceApplication() { |
| + // Make a copy of the sets before deleting them because their destructor will |
| + // call back into this class to remove them from the set. |
| + auto displays = displays_; |
| + 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.
|
| + auto surfaces = surfaces_; |
| + STLDeleteElements(&surfaces); |
| } |
| void SurfacesServiceApplication::Initialize(mojo::ApplicationImpl* app) { |
| @@ -32,15 +39,28 @@ bool SurfacesServiceApplication::ConfigureIncomingConnection( |
| void SurfacesServiceApplication::Create( |
| mojo::ApplicationConnection* connection, |
| mojo::InterfaceRequest<mojo::DisplayFactory> request) { |
| - new DisplayFactoryImpl(&manager_, next_id_namespace_++, scheduler_.get(), |
| - request.Pass()); |
| + new DisplayFactoryImpl(this, &manager_, next_id_namespace_++, |
| + scheduler_.get(), request.Pass()); |
| } |
| void SurfacesServiceApplication::Create( |
| mojo::ApplicationConnection* connection, |
| mojo::InterfaceRequest<mojo::Surface> request) { |
| - new SurfacesImpl(&manager_, next_id_namespace_++, scheduler_.get(), |
| - request.Pass()); |
| + surfaces_.insert( |
| + new SurfacesImpl(this, &manager_, next_id_namespace_++, scheduler_.get(), |
| + request.Pass())); |
| +} |
| + |
| +void SurfacesServiceApplication::DisplayCreated(DisplayImpl* display) { |
| + displays_.insert(display); |
| +} |
| + |
| +void SurfacesServiceApplication::DisplayDestroyed(DisplayImpl* display) { |
| + displays_.erase(display); |
| +} |
| + |
| +void SurfacesServiceApplication::SurfaceDestroyed(SurfacesImpl* surface) { |
| + surfaces_.erase(surface); |
| } |
| } // namespace surfaces |