Chromium Code Reviews| 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/mus/mus_app.h" | 5 #include "components/mus/mus_app.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "base/threading/platform_thread.h" | 13 #include "base/threading/platform_thread.h" |
| 14 #include "build/build_config.h" | 14 #include "build/build_config.h" |
| 15 #include "components/mus/common/args.h" | 15 #include "components/mus/common/args.h" |
| 16 #include "components/mus/gles2/gpu_impl.h" | 16 #include "components/mus/gles2/gpu_impl.h" |
| 17 #include "components/mus/ws/display.h" | 17 #include "components/mus/ws/display.h" |
| 18 #include "components/mus/ws/display_binding.h" | 18 #include "components/mus/ws/display_binding.h" |
| 19 #include "components/mus/ws/display_manager.h" | 19 #include "components/mus/ws/display_manager.h" |
| 20 #include "components/mus/ws/platform_screen.h" | |
| 20 #include "components/mus/ws/user_display_manager.h" | 21 #include "components/mus/ws/user_display_manager.h" |
| 21 #include "components/mus/ws/window_server.h" | 22 #include "components/mus/ws/window_server.h" |
| 22 #include "components/mus/ws/window_server_test_impl.h" | 23 #include "components/mus/ws/window_server_test_impl.h" |
| 23 #include "components/mus/ws/window_tree.h" | 24 #include "components/mus/ws/window_tree.h" |
| 24 #include "components/mus/ws/window_tree_binding.h" | 25 #include "components/mus/ws/window_tree_binding.h" |
| 25 #include "components/mus/ws/window_tree_factory.h" | 26 #include "components/mus/ws/window_tree_factory.h" |
| 26 #include "components/mus/ws/window_tree_host_factory.h" | 27 #include "components/mus/ws/window_tree_host_factory.h" |
| 27 #include "components/resource_provider/public/cpp/resource_loader.h" | 28 #include "components/resource_provider/public/cpp/resource_loader.h" |
| 28 #include "mojo/public/c/system/main.h" | 29 #include "mojo/public/c/system/main.h" |
| 29 #include "services/shell/public/cpp/connection.h" | 30 #include "services/shell/public/cpp/connection.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 63 // TODO(sky): this is a pretty typical pattern, make it easier to do. | 64 // TODO(sky): this is a pretty typical pattern, make it easier to do. |
| 64 struct MandolineUIServicesApp::PendingRequest { | 65 struct MandolineUIServicesApp::PendingRequest { |
| 65 shell::Connection* connection; | 66 shell::Connection* connection; |
| 66 std::unique_ptr<mojo::InterfaceRequest<mojom::WindowTreeFactory>> wtf_request; | 67 std::unique_ptr<mojo::InterfaceRequest<mojom::WindowTreeFactory>> wtf_request; |
| 67 }; | 68 }; |
| 68 | 69 |
| 69 struct MandolineUIServicesApp::UserState { | 70 struct MandolineUIServicesApp::UserState { |
| 70 std::unique_ptr<ws::WindowTreeHostFactory> window_tree_host_factory; | 71 std::unique_ptr<ws::WindowTreeHostFactory> window_tree_host_factory; |
| 71 }; | 72 }; |
| 72 | 73 |
| 73 MandolineUIServicesApp::MandolineUIServicesApp() : test_config_(false) {} | 74 MandolineUIServicesApp::MandolineUIServicesApp() |
| 75 : test_config_(false), | |
| 76 platform_screen_(new ws::PlatformScreen()), | |
| 77 weak_ptr_factory_(this) {} | |
| 74 | 78 |
| 75 MandolineUIServicesApp::~MandolineUIServicesApp() { | 79 MandolineUIServicesApp::~MandolineUIServicesApp() { |
| 76 // Destroy |window_server_| first, since it depends on |event_source_|. | 80 // Destroy |window_server_| first, since it depends on |event_source_|. |
| 77 // WindowServer (or more correctly its Displays) may have state that needs to | 81 // WindowServer (or more correctly its Displays) may have state that needs to |
| 78 // be destroyed before GpuState as well. | 82 // be destroyed before GpuState as well. |
| 79 window_server_.reset(); | 83 window_server_.reset(); |
| 80 | 84 |
| 81 if (platform_display_init_params_.gpu_state) | 85 if (platform_display_init_params_.gpu_state) |
| 82 platform_display_init_params_.gpu_state->StopThreads(); | 86 platform_display_init_params_.gpu_state->StopThreads(); |
| 83 } | 87 } |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 163 // TODO(rjkroege): Enter sandbox here before we start threads in GpuState | 167 // TODO(rjkroege): Enter sandbox here before we start threads in GpuState |
| 164 // http://crbug.com/584532 | 168 // http://crbug.com/584532 |
| 165 | 169 |
| 166 #if !defined(OS_ANDROID) | 170 #if !defined(OS_ANDROID) |
| 167 event_source_ = ui::PlatformEventSource::CreateDefault(); | 171 event_source_ = ui::PlatformEventSource::CreateDefault(); |
| 168 #endif | 172 #endif |
| 169 | 173 |
| 170 // TODO(rjkroege): It is possible that we might want to generalize the | 174 // TODO(rjkroege): It is possible that we might want to generalize the |
| 171 // GpuState object. | 175 // GpuState object. |
| 172 platform_display_init_params_.gpu_state = new GpuState(); | 176 platform_display_init_params_.gpu_state = new GpuState(); |
| 177 | |
| 178 // Gpu must be running before the PlatformScreen can be initialized. | |
| 179 platform_screen_->Init(); | |
| 173 window_server_.reset( | 180 window_server_.reset( |
| 174 new ws::WindowServer(this, platform_display_init_params_.surfaces_state)); | 181 new ws::WindowServer(this, platform_display_init_params_.surfaces_state)); |
| 175 } | 182 } |
| 176 | 183 |
| 177 bool MandolineUIServicesApp::AcceptConnection(Connection* connection) { | 184 bool MandolineUIServicesApp::AcceptConnection(Connection* connection) { |
| 178 connection->AddInterface<Gpu>(this); | 185 connection->AddInterface<Gpu>(this); |
| 179 connection->AddInterface<mojom::DisplayManager>(this); | 186 connection->AddInterface<mojom::DisplayManager>(this); |
| 180 connection->AddInterface<mojom::UserAccessManager>(this); | 187 connection->AddInterface<mojom::UserAccessManager>(this); |
| 181 connection->AddInterface<WindowTreeHostFactory>(this); | 188 connection->AddInterface<WindowTreeHostFactory>(this); |
| 182 connection->AddInterface<mojom::WindowManagerFactoryService>(this); | 189 connection->AddInterface<mojom::WindowManagerFactoryService>(this); |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 196 void MandolineUIServicesApp::OnNoMoreDisplays() { | 203 void MandolineUIServicesApp::OnNoMoreDisplays() { |
| 197 // We may get here from the destructor, in which case there is no messageloop. | 204 // We may get here from the destructor, in which case there is no messageloop. |
| 198 if (base::MessageLoop::current()) | 205 if (base::MessageLoop::current()) |
| 199 base::MessageLoop::current()->QuitWhenIdle(); | 206 base::MessageLoop::current()->QuitWhenIdle(); |
| 200 } | 207 } |
| 201 | 208 |
| 202 bool MandolineUIServicesApp::IsTestConfig() const { | 209 bool MandolineUIServicesApp::IsTestConfig() const { |
| 203 return test_config_; | 210 return test_config_; |
| 204 } | 211 } |
| 205 | 212 |
| 206 void MandolineUIServicesApp::CreateDefaultDisplays() { | 213 void MandolineUIServicesApp::CreatePhysicalDisplayCallback(int64_t id, |
|
sky
2016/05/03 02:39:50
Make position match that of header.
rjkroege
2016/05/03 21:03:03
Done.
| |
| 214 gfx::Rect bounds) { | |
| 215 platform_display_init_params_.display_bounds = bounds; | |
| 216 platform_display_init_params_.display_id = id; | |
| 217 | |
| 207 // Display manages its own lifetime. | 218 // Display manages its own lifetime. |
| 208 ws::Display* host_impl = | 219 ws::Display* host_impl = |
| 209 new ws::Display(window_server_.get(), platform_display_init_params_); | 220 new ws::Display(window_server_.get(), platform_display_init_params_); |
| 210 host_impl->Init(nullptr); | 221 host_impl->Init(nullptr); |
| 211 } | 222 } |
| 212 | 223 |
| 224 void MandolineUIServicesApp::CreateDefaultDisplays() { | |
| 225 // An asynchronous callback will create the Displays once the physical | |
| 226 // displays are ready. | |
| 227 platform_screen_->ConfigurePhysicalDisplay( | |
| 228 base::Bind(&MandolineUIServicesApp::CreatePhysicalDisplayCallback, | |
| 229 weak_ptr_factory_.GetWeakPtr())); | |
| 230 } | |
| 231 | |
| 213 void MandolineUIServicesApp::Create(shell::Connection* connection, | 232 void MandolineUIServicesApp::Create(shell::Connection* connection, |
| 214 mojom::DisplayManagerRequest request) { | 233 mojom::DisplayManagerRequest request) { |
| 215 window_server_->display_manager() | 234 window_server_->display_manager() |
| 216 ->GetUserDisplayManager(connection->GetRemoteIdentity().user_id()) | 235 ->GetUserDisplayManager(connection->GetRemoteIdentity().user_id()) |
| 217 ->AddDisplayManagerBinding(std::move(request)); | 236 ->AddDisplayManagerBinding(std::move(request)); |
| 218 } | 237 } |
| 219 | 238 |
| 220 void MandolineUIServicesApp::Create(shell::Connection* connection, | 239 void MandolineUIServicesApp::Create(shell::Connection* connection, |
| 221 mojom::UserAccessManagerRequest request) { | 240 mojom::UserAccessManagerRequest request) { |
| 222 window_server_->user_id_tracker()->Bind(std::move(request)); | 241 window_server_->user_id_tracker()->Bind(std::move(request)); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 267 new ws::WindowServerTestImpl(window_server_.get(), std::move(request)); | 286 new ws::WindowServerTestImpl(window_server_.get(), std::move(request)); |
| 268 } | 287 } |
| 269 | 288 |
| 270 void MandolineUIServicesApp::Create(shell::Connection* connection, | 289 void MandolineUIServicesApp::Create(shell::Connection* connection, |
| 271 mojom::GpuRequest request) { | 290 mojom::GpuRequest request) { |
| 272 DCHECK(platform_display_init_params_.gpu_state); | 291 DCHECK(platform_display_init_params_.gpu_state); |
| 273 new GpuImpl(std::move(request), platform_display_init_params_.gpu_state); | 292 new GpuImpl(std::move(request), platform_display_init_params_.gpu_state); |
| 274 } | 293 } |
| 275 | 294 |
| 276 } // namespace mus | 295 } // namespace mus |
| OLD | NEW |