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

Side by Side Diff: components/view_manager/view_manager_app.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
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/view_manager/view_manager_app.h" 5 #include "components/view_manager/view_manager_app.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/stl_util.h"
8 #include "components/view_manager/client_connection.h" 9 #include "components/view_manager/client_connection.h"
9 #include "components/view_manager/connection_manager.h" 10 #include "components/view_manager/connection_manager.h"
10 #include "components/view_manager/public/cpp/args.h" 11 #include "components/view_manager/public/cpp/args.h"
12 #include "components/view_manager/surfaces/surfaces_impl.h"
13 #include "components/view_manager/surfaces/surfaces_scheduler.h"
11 #include "components/view_manager/view_manager_root_connection.h" 14 #include "components/view_manager/view_manager_root_connection.h"
12 #include "components/view_manager/view_manager_root_impl.h" 15 #include "components/view_manager/view_manager_root_impl.h"
13 #include "components/view_manager/view_manager_service_impl.h" 16 #include "components/view_manager/view_manager_service_impl.h"
14 #include "mojo/application/public/cpp/application_connection.h" 17 #include "mojo/application/public/cpp/application_connection.h"
15 #include "mojo/application/public/cpp/application_impl.h" 18 #include "mojo/application/public/cpp/application_impl.h"
16 #include "mojo/application/public/cpp/application_runner.h" 19 #include "mojo/application/public/cpp/application_runner.h"
17 #include "mojo/common/tracing_impl.h" 20 #include "mojo/common/tracing_impl.h"
18 #include "third_party/mojo/src/mojo/public/c/system/main.h" 21 #include "third_party/mojo/src/mojo/public/c/system/main.h"
19 #include "ui/events/event_switches.h" 22 #include "ui/events/event_switches.h"
20 #include "ui/events/platform/platform_event_source.h" 23 #include "ui/events/platform/platform_event_source.h"
21 #include "ui/gl/gl_surface.h" 24 #include "ui/gl/gl_surface.h"
22 #include "ui/gl/test/gl_surface_test_support.h" 25 #include "ui/gl/test/gl_surface_test_support.h"
23 26
24 using mojo::ApplicationConnection; 27 using mojo::ApplicationConnection;
25 using mojo::ApplicationImpl; 28 using mojo::ApplicationImpl;
26 using mojo::Gpu; 29 using mojo::Gpu;
27 using mojo::InterfaceRequest; 30 using mojo::InterfaceRequest;
28 using mojo::ViewManagerRoot; 31 using mojo::ViewManagerRoot;
29 using mojo::ViewManagerService; 32 using mojo::ViewManagerService;
30 33
31 namespace view_manager { 34 namespace view_manager {
32 35
33 ViewManagerApp::ViewManagerApp() : app_impl_(nullptr), is_headless_(false) { 36 ViewManagerApp::ViewManagerApp()
37 : app_impl_(nullptr),
38 is_headless_(false) {
34 } 39 }
35 40
36 ViewManagerApp::~ViewManagerApp() { 41 ViewManagerApp::~ViewManagerApp() {
37 if (gpu_state_) 42 if (gpu_state_)
38 gpu_state_->StopControlThread(); 43 gpu_state_->StopControlThread();
44
45 auto surfaces = surfaces_;
46 for (auto& surface : surfaces)
47 surface->CloseConnection();
39 } 48 }
40 49
41 void ViewManagerApp::Initialize(ApplicationImpl* app) { 50 void ViewManagerApp::Initialize(ApplicationImpl* app) {
42 app_impl_ = app; 51 app_impl_ = app;
43 tracing_.Initialize(app); 52 tracing_.Initialize(app);
53 surfaces_state_ = new surfaces::SurfacesState;
44 54
45 #if !defined(OS_ANDROID) 55 #if !defined(OS_ANDROID)
46 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 56 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
47 is_headless_ = command_line->HasSwitch(mojo::kUseHeadlessConfig); 57 is_headless_ = command_line->HasSwitch(mojo::kUseHeadlessConfig);
48 if (!is_headless_) { 58 if (!is_headless_) {
49 event_source_ = ui::PlatformEventSource::CreateDefault(); 59 event_source_ = ui::PlatformEventSource::CreateDefault();
50 if (command_line->HasSwitch(mojo::kUseTestConfig)) 60 if (command_line->HasSwitch(mojo::kUseTestConfig))
51 gfx::GLSurfaceTestSupport::InitializeOneOff(); 61 gfx::GLSurfaceTestSupport::InitializeOneOff();
52 else 62 else
53 gfx::GLSurface::InitializeOneOff(); 63 gfx::GLSurface::InitializeOneOff();
54 } 64 }
55 #endif 65 #endif
56 66
57 if (!gpu_state_.get()) 67 if (!gpu_state_.get())
58 gpu_state_ = new gles2::GpuState; 68 gpu_state_ = new gles2::GpuState;
59 connection_manager_.reset(new ConnectionManager(this)); 69 connection_manager_.reset(new ConnectionManager(this));
60 } 70 }
61 71
62 bool ViewManagerApp::ConfigureIncomingConnection( 72 bool ViewManagerApp::ConfigureIncomingConnection(
63 ApplicationConnection* connection) { 73 ApplicationConnection* connection) {
74 // ViewManager
64 connection->AddService<ViewManagerRoot>(this); 75 connection->AddService<ViewManagerRoot>(this);
76 // Surfaces
77 // TODO(fsamuel): This should go away soon.
78 connection->AddService<mojo::Surface>(this);
79 // GPU
65 connection->AddService<Gpu>(this); 80 connection->AddService<Gpu>(this);
66
67 return true; 81 return true;
68 } 82 }
69 83
70 void ViewManagerApp::OnNoMoreRootConnections() { 84 void ViewManagerApp::OnNoMoreRootConnections() {
71 app_impl_->Quit(); 85 app_impl_->Quit();
72 } 86 }
73 87
74 ClientConnection* ViewManagerApp::CreateClientConnectionForEmbedAtView( 88 ClientConnection* ViewManagerApp::CreateClientConnectionForEmbedAtView(
75 ConnectionManager* connection_manager, 89 ConnectionManager* connection_manager,
76 mojo::InterfaceRequest<mojo::ViewManagerService> service_request, 90 mojo::InterfaceRequest<mojo::ViewManagerService> service_request,
(...skipping 21 matching lines...) Expand all
98 service_request.Pass(), 112 service_request.Pass(),
99 view_manager_client.Pass()); 113 view_manager_client.Pass());
100 } 114 }
101 115
102 void ViewManagerApp::Create(ApplicationConnection* connection, 116 void ViewManagerApp::Create(ApplicationConnection* connection,
103 InterfaceRequest<ViewManagerRoot> request) { 117 InterfaceRequest<ViewManagerRoot> request) {
104 DCHECK(connection_manager_.get()); 118 DCHECK(connection_manager_.get());
105 // TODO(fsamuel): We need to make sure that only the window manager can create 119 // TODO(fsamuel): We need to make sure that only the window manager can create
106 // new roots. 120 // new roots.
107 ViewManagerRootImpl* view_manager_root = new ViewManagerRootImpl( 121 ViewManagerRootImpl* view_manager_root = new ViewManagerRootImpl(
108 connection_manager_.get(), is_headless_, app_impl_, gpu_state_); 122 connection_manager_.get(), is_headless_, app_impl_, gpu_state_,
123 surfaces_state_);
109 124
110 mojo::ViewManagerClientPtr client; 125 mojo::ViewManagerClientPtr client;
111 connection->ConnectToService(&client); 126 connection->ConnectToService(&client);
112 127
113 // ViewManagerRootConnection manages its own lifetime. 128 // ViewManagerRootConnection manages its own lifetime.
114 view_manager_root->Init(new ViewManagerRootConnectionImpl( 129 view_manager_root->Init(new ViewManagerRootConnectionImpl(
115 request.Pass(), make_scoped_ptr(view_manager_root), client.Pass(), 130 request.Pass(), make_scoped_ptr(view_manager_root), client.Pass(),
116 connection_manager_.get())); 131 connection_manager_.get()));
117 } 132 }
118 133
119 void ViewManagerApp::Create( 134 void ViewManagerApp::Create(
120 mojo::ApplicationConnection* connection, 135 mojo::ApplicationConnection* connection,
121 mojo::InterfaceRequest<Gpu> request) { 136 mojo::InterfaceRequest<Gpu> request) {
122 if (!gpu_state_.get()) 137 if (!gpu_state_.get())
123 gpu_state_ = new gles2::GpuState; 138 gpu_state_ = new gles2::GpuState;
124 new gles2::GpuImpl(request.Pass(), gpu_state_); 139 new gles2::GpuImpl(request.Pass(), gpu_state_);
125 } 140 }
126 141
142 void ViewManagerApp::Create(
143 mojo::ApplicationConnection* connection,
144 mojo::InterfaceRequest<mojo::Surface> request) {
145 surfaces_.insert(
146 new surfaces::SurfacesImpl(this, surfaces_state_, request.Pass()));
147 }
148
149 void ViewManagerApp::OnSurfaceConnectionClosed(
150 surfaces::SurfacesImpl* surface) {
151 surfaces_.erase(surface);
152 }
153
127 } // namespace view_manager 154 } // namespace view_manager
OLDNEW
« no previous file with comments | « components/view_manager/view_manager_app.h ('k') | components/view_manager/view_manager_root_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698