Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(235)

Side by Side Diff: components/view_manager/surfaces/surfaces_service_application.cc

Issue 1245683004: Mandoline: Merge Surfaces and Views apps (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed bot issues (I hope) Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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/view_manager/surfaces/surfaces_service_application.h"
6
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_state.h"
11
12 namespace surfaces {
13
14 SurfacesServiceApplication::SurfacesServiceApplication() {
15 }
16
17 SurfacesServiceApplication::~SurfacesServiceApplication() {
18 // Make a copy of the sets before deleting them because their destructor will
19 // call back into this class to remove them from the set.
20 auto displays = displays_;
21 for (auto& display : displays)
22 display->CloseConnection();
23
24 auto surfaces = surfaces_;
25 for (auto& surface : surfaces)
26 surface->CloseConnection();
27 }
28
29 void SurfacesServiceApplication::Initialize(mojo::ApplicationImpl* app) {
30 tracing_.Initialize(app);
31 surfaces_state_ = new SurfacesState;
32 }
33
34 bool SurfacesServiceApplication::ConfigureIncomingConnection(
35 mojo::ApplicationConnection* connection) {
36 connection->AddService<mojo::DisplayFactory>(this);
37 connection->AddService<mojo::Surface>(this);
38 return true;
39 }
40
41 void SurfacesServiceApplication::Create(
42 mojo::ApplicationConnection* connection,
43 mojo::InterfaceRequest<mojo::DisplayFactory> request) {
44 new DisplayFactoryImpl(this, surfaces_state_, request.Pass());
45 }
46
47 void SurfacesServiceApplication::Create(
48 mojo::ApplicationConnection* connection,
49 mojo::InterfaceRequest<mojo::Surface> request) {
50 // SurfacesImpl manages its own lifetime.
51 surfaces_.insert(new SurfacesImpl(this, surfaces_state_, request.Pass()));
52 }
53
54 void SurfacesServiceApplication::OnDisplayCreated(DisplayImpl* display) {
55 displays_.insert(display);
56 }
57
58 void SurfacesServiceApplication::OnDisplayConnectionClosed(
59 DisplayImpl* display) {
60 displays_.erase(display);
61 }
62
63 void SurfacesServiceApplication::OnSurfaceConnectionClosed(
64 SurfacesImpl* surface) {
65 surfaces_.erase(surface);
66 }
67
68 } // namespace surfaces
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698