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 "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 "components/discardable_memory/service/discardable_shared_memory_manage r.h" | |
| 16 #include "mojo/public/cpp/bindings/strong_binding.h" | 17 #include "mojo/public/cpp/bindings/strong_binding.h" |
| 17 #include "services/catalog/public/cpp/resource_loader.h" | 18 #include "services/catalog/public/cpp/resource_loader.h" |
| 18 #include "services/catalog/public/interfaces/constants.mojom.h" | 19 #include "services/catalog/public/interfaces/constants.mojom.h" |
| 19 #include "services/service_manager/public/c/main.h" | 20 #include "services/service_manager/public/c/main.h" |
| 20 #include "services/service_manager/public/cpp/connection.h" | 21 #include "services/service_manager/public/cpp/connection.h" |
| 21 #include "services/service_manager/public/cpp/connector.h" | 22 #include "services/service_manager/public/cpp/connector.h" |
| 22 #include "services/service_manager/public/cpp/interface_registry.h" | 23 #include "services/service_manager/public/cpp/interface_registry.h" |
| 23 #include "services/service_manager/public/cpp/service_context.h" | 24 #include "services/service_manager/public/cpp/service_context.h" |
| 24 #include "services/tracing/public/cpp/provider.h" | 25 #include "services/tracing/public/cpp/provider.h" |
| 25 #include "services/ui/clipboard/clipboard_impl.h" | 26 #include "services/ui/clipboard/clipboard_impl.h" |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 190 // Gpu must be running before the ScreenManager can be initialized. | 191 // Gpu must be running before the ScreenManager can be initialized. |
| 191 window_server_.reset(new ws::WindowServer(this)); | 192 window_server_.reset(new ws::WindowServer(this)); |
| 192 | 193 |
| 193 // DeviceDataManager must be initialized before TouchController. On non-Linux | 194 // DeviceDataManager must be initialized before TouchController. On non-Linux |
| 194 // platforms there is no DeviceDataManager so don't create touch controller. | 195 // platforms there is no DeviceDataManager so don't create touch controller. |
| 195 if (ui::DeviceDataManager::HasInstance()) | 196 if (ui::DeviceDataManager::HasInstance()) |
| 196 touch_controller_.reset( | 197 touch_controller_.reset( |
| 197 new ws::TouchController(window_server_->display_manager())); | 198 new ws::TouchController(window_server_->display_manager())); |
| 198 | 199 |
| 199 ime_server_.Init(context()->connector(), test_config_); | 200 ime_server_.Init(context()->connector(), test_config_); |
| 201 | |
| 202 discardable_memory::DiscardableSharedMemoryManager::CreateInstance(); | |
|
sky
2016/12/15 20:40:08
Is there a corresponding destroy?
Peng
2016/12/15 20:53:23
No. When this service in browser process, we do de
Peng
2016/12/15 22:06:32
discardable_memory::DiscardableSharedMemoryManager
| |
| 200 } | 203 } |
| 201 | 204 |
| 202 bool Service::OnConnect(const service_manager::ServiceInfo& remote_info, | 205 bool Service::OnConnect(const service_manager::ServiceInfo& remote_info, |
| 203 service_manager::InterfaceRegistry* registry) { | 206 service_manager::InterfaceRegistry* registry) { |
| 204 registry->AddInterface<mojom::AccessibilityManager>(this); | 207 registry->AddInterface<mojom::AccessibilityManager>(this); |
| 205 registry->AddInterface<mojom::Clipboard>(this); | 208 registry->AddInterface<mojom::Clipboard>(this); |
| 206 registry->AddInterface<mojom::DisplayManager>(this); | 209 registry->AddInterface<mojom::DisplayManager>(this); |
| 207 registry->AddInterface<mojom::GpuService>(this); | 210 registry->AddInterface<mojom::GpuService>(this); |
| 208 registry->AddInterface<mojom::IMERegistrar>(this); | 211 registry->AddInterface<mojom::IMERegistrar>(this); |
| 209 registry->AddInterface<mojom::IMEServer>(this); | 212 registry->AddInterface<mojom::IMEServer>(this); |
| 210 registry->AddInterface<mojom::UserAccessManager>(this); | 213 registry->AddInterface<mojom::UserAccessManager>(this); |
| 211 registry->AddInterface<mojom::UserActivityMonitor>(this); | 214 registry->AddInterface<mojom::UserActivityMonitor>(this); |
| 212 registry->AddInterface<WindowTreeHostFactory>(this); | 215 registry->AddInterface<WindowTreeHostFactory>(this); |
| 213 registry->AddInterface<mojom::WindowManagerWindowTreeFactory>(this); | 216 registry->AddInterface<mojom::WindowManagerWindowTreeFactory>(this); |
| 214 registry->AddInterface<mojom::WindowTreeFactory>(this); | 217 registry->AddInterface<mojom::WindowTreeFactory>(this); |
| 218 registry | |
| 219 ->AddInterface<discardable_memory::mojom::DiscardableSharedMemoryManager>( | |
| 220 this); | |
| 215 if (test_config_) | 221 if (test_config_) |
| 216 registry->AddInterface<WindowServerTest>(this); | 222 registry->AddInterface<WindowServerTest>(this); |
| 217 | 223 |
| 218 // On non-Linux platforms there will be no DeviceDataManager instance and no | 224 // On non-Linux platforms there will be no DeviceDataManager instance and no |
| 219 // purpose in adding the Mojo interface to connect to. | 225 // purpose in adding the Mojo interface to connect to. |
| 220 if (input_device_server_.IsRegisteredAsObserver()) | 226 if (input_device_server_.IsRegisteredAsObserver()) |
| 221 input_device_server_.AddInterface(registry); | 227 input_device_server_.AddInterface(registry); |
| 222 | 228 |
| 223 screen_manager_->AddInterfaces(registry); | 229 screen_manager_->AddInterfaces(registry); |
| 224 | 230 |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 352 void Service::Create(const service_manager::Identity& remote_identity, | 358 void Service::Create(const service_manager::Identity& remote_identity, |
| 353 mojom::WindowTreeHostFactoryRequest request) { | 359 mojom::WindowTreeHostFactoryRequest request) { |
| 354 UserState* user_state = GetUserState(remote_identity); | 360 UserState* user_state = GetUserState(remote_identity); |
| 355 if (!user_state->window_tree_host_factory) { | 361 if (!user_state->window_tree_host_factory) { |
| 356 user_state->window_tree_host_factory.reset(new ws::WindowTreeHostFactory( | 362 user_state->window_tree_host_factory.reset(new ws::WindowTreeHostFactory( |
| 357 window_server_.get(), remote_identity.user_id())); | 363 window_server_.get(), remote_identity.user_id())); |
| 358 } | 364 } |
| 359 user_state->window_tree_host_factory->AddBinding(std::move(request)); | 365 user_state->window_tree_host_factory->AddBinding(std::move(request)); |
| 360 } | 366 } |
| 361 | 367 |
| 368 void Service::Create( | |
| 369 const service_manager::Identity& remote_identity, | |
| 370 discardable_memory::mojom::DiscardableSharedMemoryManagerRequest request) { | |
| 371 discardable_memory::DiscardableSharedMemoryManager::GetInstance()->Bind( | |
| 372 std::move(request)); | |
| 373 } | |
| 374 | |
| 362 void Service::Create(const service_manager::Identity& remote_identity, | 375 void Service::Create(const service_manager::Identity& remote_identity, |
| 363 mojom::WindowServerTestRequest request) { | 376 mojom::WindowServerTestRequest request) { |
| 364 if (!test_config_) | 377 if (!test_config_) |
| 365 return; | 378 return; |
| 366 mojo::MakeStrongBinding( | 379 mojo::MakeStrongBinding( |
| 367 base::MakeUnique<ws::WindowServerTestImpl>(window_server_.get()), | 380 base::MakeUnique<ws::WindowServerTestImpl>(window_server_.get()), |
| 368 std::move(request)); | 381 std::move(request)); |
| 369 } | 382 } |
| 370 | 383 |
| 371 | 384 |
| 372 } // namespace ui | 385 } // namespace ui |
| OLD | NEW |