OLD | NEW |
---|---|
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()) | |
sky
2015/06/05 23:25:50
Why the check here? Isn't this the only place that
Fady Samuel
2015/06/05 23:34:52
No it's not. GpuImpl service also needs a gpu_stat
| |
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())); | |
59 } | 62 } |
60 | 63 |
61 bool ViewManagerApp::ConfigureIncomingConnection( | 64 bool ViewManagerApp::ConfigureIncomingConnection( |
62 ApplicationConnection* connection) { | 65 ApplicationConnection* connection) { |
63 | 66 |
64 // |connection| originates from the WindowManager. Let it connect directly | 67 // |connection| originates from the WindowManager. Let it connect directly |
65 // to the ViewManager. | 68 // to the ViewManager. |
66 connection->AddService<ViewManagerService>(this); | 69 connection->AddService<ViewManagerService>(this); |
67 connection->AddService<ViewManagerRoot>(this); | 70 connection->AddService<ViewManagerRoot>(this); |
68 connection->AddService<NativeViewport>(this); | |
69 connection->AddService<Gpu>(this); | 71 connection->AddService<Gpu>(this); |
70 | 72 |
71 return true; | 73 return true; |
72 } | 74 } |
73 | 75 |
74 void ViewManagerApp::OnLostConnectionToWindowManager() { | 76 void ViewManagerApp::OnLostConnectionToWindowManager() { |
75 app_impl_->Terminate(); | 77 app_impl_->Terminate(); |
76 } | 78 } |
77 | 79 |
78 ClientConnection* ViewManagerApp::CreateClientConnectionForEmbedAtView( | 80 ClientConnection* ViewManagerApp::CreateClientConnectionForEmbedAtView( |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
134 | 136 |
135 // ConfigureIncomingConnection() must have been called before getting here. | 137 // ConfigureIncomingConnection() must have been called before getting here. |
136 DCHECK(connection_manager_.get()); | 138 DCHECK(connection_manager_.get()); |
137 view_manager_root_binding_.reset(new mojo::Binding<ViewManagerRoot>( | 139 view_manager_root_binding_.reset(new mojo::Binding<ViewManagerRoot>( |
138 connection_manager_.get(), request.Pass())); | 140 connection_manager_.get(), request.Pass())); |
139 view_manager_root_binding_->set_error_handler(this); | 141 view_manager_root_binding_->set_error_handler(this); |
140 } | 142 } |
141 | 143 |
142 void ViewManagerApp::Create( | 144 void ViewManagerApp::Create( |
143 mojo::ApplicationConnection* connection, | 145 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) { | 146 mojo::InterfaceRequest<Gpu> request) { |
157 if (!gpu_state_.get()) | 147 if (!gpu_state_.get()) |
158 gpu_state_ = new gles2::GpuState; | 148 gpu_state_ = new gles2::GpuState; |
159 new gles2::GpuImpl(request.Pass(), gpu_state_); | 149 new gles2::GpuImpl(request.Pass(), gpu_state_); |
160 } | 150 } |
161 | 151 |
162 void ViewManagerApp::OnConnectionError() { | 152 void ViewManagerApp::OnConnectionError() { |
163 app_impl_->Terminate(); | 153 app_impl_->Terminate(); |
164 } | 154 } |
165 | 155 |
166 } // namespace view_manager | 156 } // namespace view_manager |
OLD | NEW |