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

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: Addressed Rob's comments 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();
39 } 44 }
40 45
41 void ViewManagerApp::Initialize(ApplicationImpl* app) { 46 void ViewManagerApp::Initialize(ApplicationImpl* app) {
42 app_impl_ = app; 47 app_impl_ = app;
43 tracing_.Initialize(app); 48 tracing_.Initialize(app);
49 surfaces_state_ = new surfaces::SurfacesState;
44 50
45 #if !defined(OS_ANDROID) 51 #if !defined(OS_ANDROID)
46 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 52 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
47 is_headless_ = command_line->HasSwitch(mojo::kUseHeadlessConfig); 53 is_headless_ = command_line->HasSwitch(mojo::kUseHeadlessConfig);
48 if (!is_headless_) { 54 if (!is_headless_) {
49 event_source_ = ui::PlatformEventSource::CreateDefault(); 55 event_source_ = ui::PlatformEventSource::CreateDefault();
50 if (command_line->HasSwitch(mojo::kUseTestConfig)) 56 if (command_line->HasSwitch(mojo::kUseTestConfig))
51 gfx::GLSurfaceTestSupport::InitializeOneOff(); 57 gfx::GLSurfaceTestSupport::InitializeOneOff();
52 else 58 else
53 gfx::GLSurface::InitializeOneOff(); 59 gfx::GLSurface::InitializeOneOff();
54 } 60 }
55 #endif 61 #endif
56 62
57 if (!gpu_state_.get()) 63 if (!gpu_state_.get())
58 gpu_state_ = new gles2::GpuState; 64 gpu_state_ = new gles2::GpuState;
59 connection_manager_.reset(new ConnectionManager(this)); 65 connection_manager_.reset(new ConnectionManager(this));
60 } 66 }
61 67
62 bool ViewManagerApp::ConfigureIncomingConnection( 68 bool ViewManagerApp::ConfigureIncomingConnection(
63 ApplicationConnection* connection) { 69 ApplicationConnection* connection) {
70 // ViewManager
64 connection->AddService<ViewManagerRoot>(this); 71 connection->AddService<ViewManagerRoot>(this);
72 // Surfaces
73 // TODO(fsamuel): This should go away soon.
74 connection->AddService<mojo::Surface>(this);
75 // GPU
65 connection->AddService<Gpu>(this); 76 connection->AddService<Gpu>(this);
66
67 return true; 77 return true;
68 } 78 }
69 79
70 void ViewManagerApp::OnNoMoreRootConnections() { 80 void ViewManagerApp::OnNoMoreRootConnections() {
71 app_impl_->Terminate(); 81 app_impl_->Terminate();
72 } 82 }
73 83
74 ClientConnection* ViewManagerApp::CreateClientConnectionForEmbedAtView( 84 ClientConnection* ViewManagerApp::CreateClientConnectionForEmbedAtView(
75 ConnectionManager* connection_manager, 85 ConnectionManager* connection_manager,
76 mojo::InterfaceRequest<mojo::ViewManagerService> service_request, 86 mojo::InterfaceRequest<mojo::ViewManagerService> service_request,
(...skipping 21 matching lines...) Expand all
98 service_request.Pass(), 108 service_request.Pass(),
99 view_manager_client.Pass()); 109 view_manager_client.Pass());
100 } 110 }
101 111
102 void ViewManagerApp::Create(ApplicationConnection* connection, 112 void ViewManagerApp::Create(ApplicationConnection* connection,
103 InterfaceRequest<ViewManagerRoot> request) { 113 InterfaceRequest<ViewManagerRoot> request) {
104 DCHECK(connection_manager_.get()); 114 DCHECK(connection_manager_.get());
105 // TODO(fsamuel): We need to make sure that only the window manager can create 115 // TODO(fsamuel): We need to make sure that only the window manager can create
106 // new roots. 116 // new roots.
107 ViewManagerRootImpl* view_manager_root = new ViewManagerRootImpl( 117 ViewManagerRootImpl* view_manager_root = new ViewManagerRootImpl(
108 connection_manager_.get(), is_headless_, app_impl_, gpu_state_); 118 connection_manager_.get(), is_headless_, app_impl_, gpu_state_,
119 surfaces_state_);
109 120
110 mojo::ViewManagerClientPtr client; 121 mojo::ViewManagerClientPtr client;
111 connection->ConnectToService(&client); 122 connection->ConnectToService(&client);
112 123
113 // ViewManagerRootConnection manages its own lifetime. 124 // ViewManagerRootConnection manages its own lifetime.
114 view_manager_root->Init(new ViewManagerRootConnectionImpl( 125 view_manager_root->Init(new ViewManagerRootConnectionImpl(
115 request.Pass(), make_scoped_ptr(view_manager_root), client.Pass(), 126 request.Pass(), make_scoped_ptr(view_manager_root), client.Pass(),
116 connection_manager_.get())); 127 connection_manager_.get()));
117 } 128 }
118 129
119 void ViewManagerApp::Create( 130 void ViewManagerApp::Create(
120 mojo::ApplicationConnection* connection, 131 mojo::ApplicationConnection* connection,
121 mojo::InterfaceRequest<Gpu> request) { 132 mojo::InterfaceRequest<Gpu> request) {
122 if (!gpu_state_.get()) 133 if (!gpu_state_.get())
123 gpu_state_ = new gles2::GpuState; 134 gpu_state_ = new gles2::GpuState;
124 new gles2::GpuImpl(request.Pass(), gpu_state_); 135 new gles2::GpuImpl(request.Pass(), gpu_state_);
125 } 136 }
126 137
138 void ViewManagerApp::Create(
139 mojo::ApplicationConnection* connection,
140 mojo::InterfaceRequest<mojo::Surface> request) {
141 new surfaces::SurfacesImpl(surfaces_state_, request.Pass());
142 }
143
127 } // namespace view_manager 144 } // namespace view_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698