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

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

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

Powered by Google App Engine
This is Rietveld 408576698