Update V8 to version 4.6.52.
[chromium-blink-merge.git] / components / view_manager / surfaces / surfaces_service_application.cc
blob7086794ba020876060212e372652046cf9f164ae
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.
5 #include "components/view_manager/surfaces/surfaces_service_application.h"
7 #include "base/stl_util.h"
8 #include "components/view_manager/surfaces/display_factory_impl.h"
9 #include "components/view_manager/surfaces/surfaces_impl.h"
10 #include "components/view_manager/surfaces/surfaces_scheduler.h"
12 namespace surfaces {
14 SurfacesServiceApplication::SurfacesServiceApplication()
15 : next_id_namespace_(1u) {
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);
27 void SurfacesServiceApplication::Initialize(mojo::ApplicationImpl* app) {
28 tracing_.Initialize(app);
29 scheduler_.reset(new SurfacesScheduler);
32 bool SurfacesServiceApplication::ConfigureIncomingConnection(
33 mojo::ApplicationConnection* connection) {
34 connection->AddService<mojo::DisplayFactory>(this);
35 connection->AddService<mojo::Surface>(this);
36 return true;
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());
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()));
54 void SurfacesServiceApplication::DisplayCreated(DisplayImpl* display) {
55 displays_.insert(display);
58 void SurfacesServiceApplication::DisplayDestroyed(DisplayImpl* display) {
59 displays_.erase(display);
62 void SurfacesServiceApplication::SurfaceDestroyed(SurfacesImpl* surface) {
63 surfaces_.erase(surface);
66 } // namespace surfaces