| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "ash/mus/window_manager_application.h" | 5 #include "ash/mus/window_manager_application.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "ash/common/material_design/material_design_controller.h" | 9 #include "ash/common/material_design/material_design_controller.h" |
| 10 #include "ash/common/mojo_interface_factory.h" | 10 #include "ash/common/mojo_interface_factory.h" |
| 11 #include "ash/common/wm_shell.h" | 11 #include "ash/common/wm_shell.h" |
| 12 #include "ash/mus/accelerators/accelerator_registrar_impl.h" | |
| 13 #include "ash/mus/native_widget_factory_mus.h" | 12 #include "ash/mus/native_widget_factory_mus.h" |
| 14 #include "ash/mus/window_manager.h" | 13 #include "ash/mus/window_manager.h" |
| 15 #include "base/bind.h" | 14 #include "base/bind.h" |
| 16 #include "base/memory/ptr_util.h" | 15 #include "base/memory/ptr_util.h" |
| 17 #include "services/service_manager/public/cpp/connection.h" | 16 #include "services/service_manager/public/cpp/connection.h" |
| 18 #include "services/service_manager/public/cpp/connector.h" | 17 #include "services/service_manager/public/cpp/connector.h" |
| 19 #include "services/tracing/public/cpp/provider.h" | 18 #include "services/tracing/public/cpp/provider.h" |
| 20 #include "services/ui/common/event_matcher_util.h" | 19 #include "services/ui/common/event_matcher_util.h" |
| 21 #include "services/ui/public/cpp/gpu_service.h" | 20 #include "services/ui/public/cpp/gpu_service.h" |
| 22 #include "services/ui/public/cpp/window.h" | 21 #include "services/ui/public/cpp/window.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 38 #include "device/bluetooth/dbus/bluez_dbus_manager.h" // nogncheck | 37 #include "device/bluetooth/dbus/bluez_dbus_manager.h" // nogncheck |
| 39 #endif | 38 #endif |
| 40 | 39 |
| 41 namespace ash { | 40 namespace ash { |
| 42 namespace mus { | 41 namespace mus { |
| 43 | 42 |
| 44 WindowManagerApplication::WindowManagerApplication() | 43 WindowManagerApplication::WindowManagerApplication() |
| 45 : screenlock_state_listener_binding_(this) {} | 44 : screenlock_state_listener_binding_(this) {} |
| 46 | 45 |
| 47 WindowManagerApplication::~WindowManagerApplication() { | 46 WindowManagerApplication::~WindowManagerApplication() { |
| 48 // AcceleratorRegistrarImpl removes an observer in its destructor. Destroy | |
| 49 // it early on. | |
| 50 std::set<AcceleratorRegistrarImpl*> accelerator_registrars( | |
| 51 accelerator_registrars_); | |
| 52 for (AcceleratorRegistrarImpl* registrar : accelerator_registrars) | |
| 53 registrar->Destroy(); | |
| 54 | |
| 55 // Destroy the WindowManager while still valid. This way we ensure | 47 // Destroy the WindowManager while still valid. This way we ensure |
| 56 // OnWillDestroyRootWindowController() is called (if it hasn't been already). | 48 // OnWillDestroyRootWindowController() is called (if it hasn't been already). |
| 57 window_manager_.reset(); | 49 window_manager_.reset(); |
| 58 | 50 |
| 59 if (blocking_pool_) { | 51 if (blocking_pool_) { |
| 60 // Like BrowserThreadImpl, the goal is to make it impossible for ash to | 52 // Like BrowserThreadImpl, the goal is to make it impossible for ash to |
| 61 // 'infinite loop' during shutdown, but to reasonably expect that all | 53 // 'infinite loop' during shutdown, but to reasonably expect that all |
| 62 // BLOCKING_SHUTDOWN tasks queued during shutdown get run. There's nothing | 54 // BLOCKING_SHUTDOWN tasks queued during shutdown get run. There's nothing |
| 63 // particularly scientific about the number chosen. | 55 // particularly scientific about the number chosen. |
| 64 const int kMaxNewShutdownBlockingTasks = 1000; | 56 const int kMaxNewShutdownBlockingTasks = 1000; |
| 65 blocking_pool_->Shutdown(kMaxNewShutdownBlockingTasks); | 57 blocking_pool_->Shutdown(kMaxNewShutdownBlockingTasks); |
| 66 } | 58 } |
| 67 | 59 |
| 68 gpu_service_.reset(); | 60 gpu_service_.reset(); |
| 69 #if defined(OS_CHROMEOS) | 61 #if defined(OS_CHROMEOS) |
| 70 statistics_provider_.reset(); | 62 statistics_provider_.reset(); |
| 71 #endif | 63 #endif |
| 72 ShutdownComponents(); | 64 ShutdownComponents(); |
| 73 } | 65 } |
| 74 | 66 |
| 75 void WindowManagerApplication::OnAcceleratorRegistrarDestroyed( | |
| 76 AcceleratorRegistrarImpl* registrar) { | |
| 77 accelerator_registrars_.erase(registrar); | |
| 78 } | |
| 79 | |
| 80 void WindowManagerApplication::InitWindowManager( | 67 void WindowManagerApplication::InitWindowManager( |
| 81 std::unique_ptr<ui::WindowTreeClient> window_tree_client, | 68 std::unique_ptr<ui::WindowTreeClient> window_tree_client, |
| 82 const scoped_refptr<base::SequencedWorkerPool>& blocking_pool) { | 69 const scoped_refptr<base::SequencedWorkerPool>& blocking_pool) { |
| 83 InitializeComponents(); | 70 InitializeComponents(); |
| 84 #if defined(OS_CHROMEOS) | 71 #if defined(OS_CHROMEOS) |
| 85 // TODO(jamescook): Refactor StatisticsProvider so we can get just the data | 72 // TODO(jamescook): Refactor StatisticsProvider so we can get just the data |
| 86 // we need in ash. Right now StatisticsProviderImpl launches the crossystem | 73 // we need in ash. Right now StatisticsProviderImpl launches the crossystem |
| 87 // binary to get system data, which we don't want to do twice on startup. | 74 // binary to get system data, which we don't want to do twice on startup. |
| 88 statistics_provider_.reset( | 75 statistics_provider_.reset( |
| 89 new chromeos::system::ScopedFakeStatisticsProvider()); | 76 new chromeos::system::ScopedFakeStatisticsProvider()); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 InitWindowManager(std::move(window_tree_client), blocking_pool_); | 143 InitWindowManager(std::move(window_tree_client), blocking_pool_); |
| 157 } | 144 } |
| 158 | 145 |
| 159 bool WindowManagerApplication::OnConnect( | 146 bool WindowManagerApplication::OnConnect( |
| 160 const service_manager::ServiceInfo& remote_info, | 147 const service_manager::ServiceInfo& remote_info, |
| 161 service_manager::InterfaceRegistry* registry) { | 148 service_manager::InterfaceRegistry* registry) { |
| 162 // Register services used in both classic ash and mash. | 149 // Register services used in both classic ash and mash. |
| 163 mojo_interface_factory::RegisterInterfaces( | 150 mojo_interface_factory::RegisterInterfaces( |
| 164 registry, base::ThreadTaskRunnerHandle::Get()); | 151 registry, base::ThreadTaskRunnerHandle::Get()); |
| 165 | 152 |
| 166 registry->AddInterface<ui::mojom::AcceleratorRegistrar>(this); | |
| 167 if (remote_info.identity.name() == "service:mash_session") { | 153 if (remote_info.identity.name() == "service:mash_session") { |
| 168 connector()->ConnectToInterface(remote_info.identity, &session_); | 154 connector()->ConnectToInterface(remote_info.identity, &session_); |
| 169 session_->AddScreenlockStateListener( | 155 session_->AddScreenlockStateListener( |
| 170 screenlock_state_listener_binding_.CreateInterfacePtrAndBind()); | 156 screenlock_state_listener_binding_.CreateInterfacePtrAndBind()); |
| 171 } | 157 } |
| 172 return true; | 158 return true; |
| 173 } | 159 } |
| 174 | 160 |
| 175 void WindowManagerApplication::Create( | |
| 176 const service_manager::Identity& remote_identity, | |
| 177 ui::mojom::AcceleratorRegistrarRequest request) { | |
| 178 if (!window_manager_->window_manager_client()) | |
| 179 return; // Can happen during shutdown. | |
| 180 | |
| 181 uint16_t accelerator_namespace_id; | |
| 182 if (!window_manager_->GetNextAcceleratorNamespaceId( | |
| 183 &accelerator_namespace_id)) { | |
| 184 DVLOG(1) << "Max number of accelerators registered, ignoring request."; | |
| 185 // All ids are used. Normally shouldn't happen, so we close the connection. | |
| 186 return; | |
| 187 } | |
| 188 accelerator_registrars_.insert(new AcceleratorRegistrarImpl( | |
| 189 window_manager_.get(), accelerator_namespace_id, std::move(request), | |
| 190 base::Bind(&WindowManagerApplication::OnAcceleratorRegistrarDestroyed, | |
| 191 base::Unretained(this)))); | |
| 192 } | |
| 193 | |
| 194 void WindowManagerApplication::ScreenlockStateChanged(bool locked) { | 161 void WindowManagerApplication::ScreenlockStateChanged(bool locked) { |
| 195 window_manager_->SetScreenLocked(locked); | 162 window_manager_->SetScreenLocked(locked); |
| 196 } | 163 } |
| 197 | 164 |
| 198 } // namespace mus | 165 } // namespace mus |
| 199 } // namespace ash | 166 } // namespace ash |
| OLD | NEW |