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

Side by Side Diff: components/view_manager/view_manager_app.cc

Issue 1149083010: Mandoline: Remove native_viewport.mojom (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More cleanup Created 5 years, 6 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 "components/view_manager/client_connection.h" 8 #include "components/view_manager/client_connection.h"
9 #include "components/view_manager/connection_manager.h" 9 #include "components/view_manager/connection_manager.h"
10 #include "components/view_manager/display_manager.h" 10 #include "components/view_manager/display_manager.h"
11 #include "components/view_manager/native_viewport/native_viewport_impl.h"
12 #include "components/view_manager/public/cpp/args.h" 11 #include "components/view_manager/public/cpp/args.h"
13 #include "components/view_manager/view_manager_service_impl.h" 12 #include "components/view_manager/view_manager_service_impl.h"
14 #include "mojo/application/public/cpp/application_connection.h" 13 #include "mojo/application/public/cpp/application_connection.h"
15 #include "mojo/application/public/cpp/application_impl.h" 14 #include "mojo/application/public/cpp/application_impl.h"
16 #include "mojo/application/public/cpp/application_runner.h" 15 #include "mojo/application/public/cpp/application_runner.h"
17 #include "mojo/common/tracing_impl.h" 16 #include "mojo/common/tracing_impl.h"
18 #include "third_party/mojo/src/mojo/public/c/system/main.h" 17 #include "third_party/mojo/src/mojo/public/c/system/main.h"
19 #include "ui/events/event_switches.h" 18 #include "ui/events/event_switches.h"
20 #include "ui/events/platform/platform_event_source.h" 19 #include "ui/events/platform/platform_event_source.h"
21 #include "ui/gl/gl_surface.h" 20 #include "ui/gl/gl_surface.h"
22 21
23 using mojo::ApplicationConnection; 22 using mojo::ApplicationConnection;
24 using mojo::ApplicationImpl; 23 using mojo::ApplicationImpl;
25 using mojo::Gpu; 24 using mojo::Gpu;
26 using mojo::InterfaceRequest; 25 using mojo::InterfaceRequest;
27 using mojo::NativeViewport;
28 using mojo::ViewManagerRoot; 26 using mojo::ViewManagerRoot;
29 using mojo::ViewManagerService; 27 using mojo::ViewManagerService;
30 28
31 namespace view_manager { 29 namespace view_manager {
32 30
33 ViewManagerApp::ViewManagerApp() : app_impl_(nullptr), is_headless_(false) { 31 ViewManagerApp::ViewManagerApp() : app_impl_(nullptr), is_headless_(false) {
34 } 32 }
35 33
36 ViewManagerApp::~ViewManagerApp() {} 34 ViewManagerApp::~ViewManagerApp() {}
37 35
38 void ViewManagerApp::Initialize(ApplicationImpl* app) { 36 void ViewManagerApp::Initialize(ApplicationImpl* app) {
39 app_impl_ = app; 37 app_impl_ = app;
40 tracing_.Initialize(app); 38 tracing_.Initialize(app);
41 39
42 scoped_ptr<DefaultDisplayManager> display_manager(new DefaultDisplayManager(
43 app_impl_, base::Bind(&ViewManagerApp::OnLostConnectionToWindowManager,
44 base::Unretained(this))));
45 connection_manager_.reset(
46 new ConnectionManager(this, display_manager.Pass()));
47
48 #if !defined(OS_ANDROID) 40 #if !defined(OS_ANDROID)
49 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 41 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
50 is_headless_ = command_line->HasSwitch(mojo::kUseHeadlessConfig); 42 is_headless_ = command_line->HasSwitch(mojo::kUseHeadlessConfig);
51 if (!is_headless_) { 43 if (!is_headless_) {
52 event_source_ = ui::PlatformEventSource::CreateDefault(); 44 event_source_ = ui::PlatformEventSource::CreateDefault();
53 if (command_line->HasSwitch(mojo::kUseTestConfig)) 45 if (command_line->HasSwitch(mojo::kUseTestConfig))
54 gfx::GLSurface::InitializeOneOffForTests(); 46 gfx::GLSurface::InitializeOneOffForTests();
55 else 47 else
56 gfx::GLSurface::InitializeOneOff(); 48 gfx::GLSurface::InitializeOneOff();
57 } 49 }
58 #endif 50 #endif
51
52 if (!gpu_state_.get())
53 gpu_state_ = new gles2::GpuState;
54 scoped_ptr<DefaultDisplayManager> display_manager(new DefaultDisplayManager(
55 app_impl_,
56 gpu_state_,
57 base::Bind(&ViewManagerApp::OnLostConnectionToWindowManager,
58 base::Unretained(this))));
59 connection_manager_.reset(
60 new ConnectionManager(this, display_manager.Pass()));
59 } 61 }
60 62
61 bool ViewManagerApp::ConfigureIncomingConnection( 63 bool ViewManagerApp::ConfigureIncomingConnection(
62 ApplicationConnection* connection) { 64 ApplicationConnection* connection) {
63 65
64 // |connection| originates from the WindowManager. Let it connect directly 66 // |connection| originates from the WindowManager. Let it connect directly
65 // to the ViewManager. 67 // to the ViewManager.
66 connection->AddService<ViewManagerService>(this); 68 connection->AddService<ViewManagerService>(this);
67 connection->AddService<ViewManagerRoot>(this); 69 connection->AddService<ViewManagerRoot>(this);
68 connection->AddService<NativeViewport>(this);
69 connection->AddService<Gpu>(this); 70 connection->AddService<Gpu>(this);
70 71
71 return true; 72 return true;
72 } 73 }
73 74
74 void ViewManagerApp::OnLostConnectionToWindowManager() { 75 void ViewManagerApp::OnLostConnectionToWindowManager() {
75 app_impl_->Terminate(); 76 app_impl_->Terminate();
76 } 77 }
77 78
78 ClientConnection* ViewManagerApp::CreateClientConnectionForEmbedAtView( 79 ClientConnection* ViewManagerApp::CreateClientConnectionForEmbedAtView(
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 135
135 // ConfigureIncomingConnection() must have been called before getting here. 136 // ConfigureIncomingConnection() must have been called before getting here.
136 DCHECK(connection_manager_.get()); 137 DCHECK(connection_manager_.get());
137 view_manager_root_binding_.reset(new mojo::Binding<ViewManagerRoot>( 138 view_manager_root_binding_.reset(new mojo::Binding<ViewManagerRoot>(
138 connection_manager_.get(), request.Pass())); 139 connection_manager_.get(), request.Pass()));
139 view_manager_root_binding_->set_error_handler(this); 140 view_manager_root_binding_->set_error_handler(this);
140 } 141 }
141 142
142 void ViewManagerApp::Create( 143 void ViewManagerApp::Create(
143 mojo::ApplicationConnection* connection, 144 mojo::ApplicationConnection* connection,
144 mojo::InterfaceRequest<NativeViewport> request) {
145 if (!gpu_state_.get())
146 gpu_state_ = new gles2::GpuState;
147 new native_viewport::NativeViewportImpl(
148 is_headless_,
149 gpu_state_,
150 request.Pass(),
151 app_impl_->app_lifetime_helper()->CreateAppRefCount());
152 }
153
154 void ViewManagerApp::Create(
155 mojo::ApplicationConnection* connection,
156 mojo::InterfaceRequest<Gpu> request) { 145 mojo::InterfaceRequest<Gpu> request) {
157 if (!gpu_state_.get()) 146 if (!gpu_state_.get())
158 gpu_state_ = new gles2::GpuState; 147 gpu_state_ = new gles2::GpuState;
159 new gles2::GpuImpl(request.Pass(), gpu_state_); 148 new gles2::GpuImpl(request.Pass(), gpu_state_);
160 } 149 }
161 150
162 void ViewManagerApp::OnConnectionError() { 151 void ViewManagerApp::OnConnectionError() {
163 app_impl_->Terminate(); 152 app_impl_->Terminate();
164 } 153 }
165 154
166 } // namespace view_manager 155 } // namespace view_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698