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 "services/ui/service.h" | 5 #include "services/ui/service.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 "base/trace_event/trace_event.h" | 14 #include "base/trace_event/trace_event.h" |
15 #include "build/build_config.h" | 15 #include "build/build_config.h" |
16 #include "mojo/public/cpp/bindings/strong_binding.h" | 16 #include "mojo/public/cpp/bindings/strong_binding.h" |
17 #include "services/catalog/public/cpp/resource_loader.h" | 17 #include "services/catalog/public/cpp/resource_loader.h" |
18 #include "services/catalog/public/interfaces/constants.mojom.h" | 18 #include "services/catalog/public/interfaces/constants.mojom.h" |
19 #include "services/service_manager/public/c/main.h" | 19 #include "services/service_manager/public/c/main.h" |
20 #include "services/service_manager/public/cpp/connection.h" | 20 #include "services/service_manager/public/cpp/connection.h" |
21 #include "services/service_manager/public/cpp/connector.h" | 21 #include "services/service_manager/public/cpp/connector.h" |
22 #include "services/service_manager/public/cpp/interface_registry.h" | 22 #include "services/service_manager/public/cpp/interface_registry.h" |
23 #include "services/service_manager/public/cpp/service_context.h" | 23 #include "services/service_manager/public/cpp/service_context.h" |
24 #include "services/tracing/public/cpp/provider.h" | 24 #include "services/tracing/public/cpp/provider.h" |
25 #include "services/ui/clipboard/clipboard_impl.h" | 25 #include "services/ui/clipboard/clipboard_impl.h" |
26 #include "services/ui/common/switches.h" | 26 #include "services/ui/common/switches.h" |
27 #include "services/ui/display/platform_screen.h" | 27 #include "services/ui/display/screen_manager.h" |
28 #include "services/ui/ime/ime_registrar_impl.h" | 28 #include "services/ui/ime/ime_registrar_impl.h" |
29 #include "services/ui/ime/ime_server_impl.h" | 29 #include "services/ui/ime/ime_server_impl.h" |
30 #include "services/ui/ws/accessibility_manager.h" | 30 #include "services/ui/ws/accessibility_manager.h" |
31 #include "services/ui/ws/display.h" | 31 #include "services/ui/ws/display.h" |
32 #include "services/ui/ws/display_binding.h" | 32 #include "services/ui/ws/display_binding.h" |
33 #include "services/ui/ws/display_manager.h" | 33 #include "services/ui/ws/display_manager.h" |
34 #include "services/ui/ws/gpu_service_proxy.h" | 34 #include "services/ui/ws/gpu_service_proxy.h" |
35 #include "services/ui/ws/user_activity_monitor.h" | 35 #include "services/ui/ws/user_activity_monitor.h" |
36 #include "services/ui/ws/user_display_manager.h" | 36 #include "services/ui/ws/user_display_manager.h" |
37 #include "services/ui/ws/window_server.h" | 37 #include "services/ui/ws/window_server.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 }; | 80 }; |
81 | 81 |
82 struct Service::UserState { | 82 struct Service::UserState { |
83 std::unique_ptr<clipboard::ClipboardImpl> clipboard; | 83 std::unique_ptr<clipboard::ClipboardImpl> clipboard; |
84 std::unique_ptr<ws::AccessibilityManager> accessibility; | 84 std::unique_ptr<ws::AccessibilityManager> accessibility; |
85 std::unique_ptr<ws::WindowTreeHostFactory> window_tree_host_factory; | 85 std::unique_ptr<ws::WindowTreeHostFactory> window_tree_host_factory; |
86 }; | 86 }; |
87 | 87 |
88 Service::Service() | 88 Service::Service() |
89 : test_config_(false), | 89 : test_config_(false), |
90 platform_screen_(display::PlatformScreen::Create()), | 90 screen_manager_(display::ScreenManager::Create()), |
91 ime_registrar_(&ime_server_) {} | 91 ime_registrar_(&ime_server_) {} |
92 | 92 |
93 Service::~Service() { | 93 Service::~Service() { |
94 // Destroy |window_server_| first, since it depends on |event_source_|. | 94 // Destroy |window_server_| first, since it depends on |event_source_|. |
95 // WindowServer (or more correctly its Displays) may have state that needs to | 95 // WindowServer (or more correctly its Displays) may have state that needs to |
96 // be destroyed before GpuState as well. | 96 // be destroyed before GpuState as well. |
97 window_server_.reset(); | 97 window_server_.reset(); |
98 } | 98 } |
99 | 99 |
100 void Service::InitializeResources(service_manager::Connector* connector) { | 100 void Service::InitializeResources(service_manager::Connector* connector) { |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 | 180 |
181 #if !defined(OS_ANDROID) | 181 #if !defined(OS_ANDROID) |
182 event_source_ = ui::PlatformEventSource::CreateDefault(); | 182 event_source_ = ui::PlatformEventSource::CreateDefault(); |
183 #endif | 183 #endif |
184 | 184 |
185 // This needs to happen after DeviceDataManager has been constructed. That | 185 // This needs to happen after DeviceDataManager has been constructed. That |
186 // happens either during OzonePlatform or PlatformEventSource initialization, | 186 // happens either during OzonePlatform or PlatformEventSource initialization, |
187 // so keep this line below both of those. | 187 // so keep this line below both of those. |
188 input_device_server_.RegisterAsObserver(); | 188 input_device_server_.RegisterAsObserver(); |
189 | 189 |
190 // Gpu must be running before the PlatformScreen can be initialized. | 190 // Gpu must be running before the ScreenManager can be initialized. |
191 window_server_.reset(new ws::WindowServer(this)); | 191 window_server_.reset(new ws::WindowServer(this)); |
192 | 192 |
193 // DeviceDataManager must be initialized before TouchController. On non-Linux | 193 // DeviceDataManager must be initialized before TouchController. On non-Linux |
194 // platforms there is no DeviceDataManager so don't create touch controller. | 194 // platforms there is no DeviceDataManager so don't create touch controller. |
195 if (ui::DeviceDataManager::HasInstance()) | 195 if (ui::DeviceDataManager::HasInstance()) |
196 touch_controller_.reset( | 196 touch_controller_.reset( |
197 new ws::TouchController(window_server_->display_manager())); | 197 new ws::TouchController(window_server_->display_manager())); |
198 | 198 |
199 ime_server_.Init(context()->connector(), test_config_); | 199 ime_server_.Init(context()->connector(), test_config_); |
200 } | 200 } |
(...skipping 12 matching lines...) Expand all Loading... |
213 registry->AddInterface<mojom::WindowManagerWindowTreeFactory>(this); | 213 registry->AddInterface<mojom::WindowManagerWindowTreeFactory>(this); |
214 registry->AddInterface<mojom::WindowTreeFactory>(this); | 214 registry->AddInterface<mojom::WindowTreeFactory>(this); |
215 if (test_config_) | 215 if (test_config_) |
216 registry->AddInterface<WindowServerTest>(this); | 216 registry->AddInterface<WindowServerTest>(this); |
217 | 217 |
218 // On non-Linux platforms there will be no DeviceDataManager instance and no | 218 // On non-Linux platforms there will be no DeviceDataManager instance and no |
219 // purpose in adding the Mojo interface to connect to. | 219 // purpose in adding the Mojo interface to connect to. |
220 if (input_device_server_.IsRegisteredAsObserver()) | 220 if (input_device_server_.IsRegisteredAsObserver()) |
221 input_device_server_.AddInterface(registry); | 221 input_device_server_.AddInterface(registry); |
222 | 222 |
223 platform_screen_->AddInterfaces(registry); | 223 screen_manager_->AddInterfaces(registry); |
224 | 224 |
225 #if defined(USE_OZONE) | 225 #if defined(USE_OZONE) |
226 ui::OzonePlatform::GetInstance()->AddInterfaces(registry); | 226 ui::OzonePlatform::GetInstance()->AddInterfaces(registry); |
227 #endif | 227 #endif |
228 | 228 |
229 return true; | 229 return true; |
230 } | 230 } |
231 | 231 |
232 void Service::StartDisplayInit() { | 232 void Service::StartDisplayInit() { |
233 platform_screen_->Init(window_server_->display_manager()); | 233 screen_manager_->Init(window_server_->display_manager()); |
234 } | 234 } |
235 | 235 |
236 void Service::OnFirstDisplayReady() { | 236 void Service::OnFirstDisplayReady() { |
237 PendingRequests requests; | 237 PendingRequests requests; |
238 requests.swap(pending_requests_); | 238 requests.swap(pending_requests_); |
239 for (auto& request : requests) { | 239 for (auto& request : requests) { |
240 if (request->wtf_request) | 240 if (request->wtf_request) |
241 Create(request->remote_identity, std::move(*request->wtf_request)); | 241 Create(request->remote_identity, std::move(*request->wtf_request)); |
242 else | 242 else |
243 Create(request->remote_identity, std::move(*request->dm_request)); | 243 Create(request->remote_identity, std::move(*request->dm_request)); |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 mojom::WindowServerTestRequest request) { | 363 mojom::WindowServerTestRequest request) { |
364 if (!test_config_) | 364 if (!test_config_) |
365 return; | 365 return; |
366 mojo::MakeStrongBinding( | 366 mojo::MakeStrongBinding( |
367 base::MakeUnique<ws::WindowServerTestImpl>(window_server_.get()), | 367 base::MakeUnique<ws::WindowServerTestImpl>(window_server_.get()), |
368 std::move(request)); | 368 std::move(request)); |
369 } | 369 } |
370 | 370 |
371 | 371 |
372 } // namespace ui | 372 } // namespace ui |
OLD | NEW |