| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "components/surfaces/surfaces_service_application.h" | |
| 6 | |
| 7 #include "base/stl_util.h" | |
| 8 #include "components/surfaces/display_factory_impl.h" | |
| 9 #include "components/surfaces/surfaces_impl.h" | |
| 10 #include "components/surfaces/surfaces_scheduler.h" | |
| 11 | |
| 12 namespace surfaces { | |
| 13 | |
| 14 SurfacesServiceApplication::SurfacesServiceApplication() | |
| 15 : next_id_namespace_(1u) { | |
| 16 } | |
| 17 | |
| 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); | |
| 23 auto surfaces = surfaces_; | |
| 24 STLDeleteElements(&surfaces); | |
| 25 } | |
| 26 | |
| 27 void SurfacesServiceApplication::Initialize(mojo::ApplicationImpl* app) { | |
| 28 tracing_.Initialize(app); | |
| 29 scheduler_.reset(new SurfacesScheduler); | |
| 30 } | |
| 31 | |
| 32 bool SurfacesServiceApplication::ConfigureIncomingConnection( | |
| 33 mojo::ApplicationConnection* connection) { | |
| 34 connection->AddService<mojo::DisplayFactory>(this); | |
| 35 connection->AddService<mojo::Surface>(this); | |
| 36 return true; | |
| 37 } | |
| 38 | |
| 39 void SurfacesServiceApplication::Create( | |
| 40 mojo::ApplicationConnection* connection, | |
| 41 mojo::InterfaceRequest<mojo::DisplayFactory> request) { | |
| 42 new DisplayFactoryImpl(this, &manager_, next_id_namespace_++, | |
| 43 scheduler_.get(), request.Pass()); | |
| 44 } | |
| 45 | |
| 46 void SurfacesServiceApplication::Create( | |
| 47 mojo::ApplicationConnection* connection, | |
| 48 mojo::InterfaceRequest<mojo::Surface> request) { | |
| 49 surfaces_.insert( | |
| 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); | |
| 64 } | |
| 65 | |
| 66 } // namespace surfaces | |
| OLD | NEW |