| 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/system/chromeos/power/power_status.h" |
| 11 #include "ash/common/wm_shell.h" | 12 #include "ash/common/wm_shell.h" |
| 13 #include "ash/mus/network_connect_delegate_mus.h" |
| 12 #include "ash/mus/window_manager.h" | 14 #include "ash/mus/window_manager.h" |
| 13 #include "base/bind.h" | 15 #include "base/bind.h" |
| 14 #include "base/memory/ptr_util.h" | 16 #include "base/memory/ptr_util.h" |
| 15 #include "base/threading/thread_task_runner_handle.h" | 17 #include "base/threading/thread_task_runner_handle.h" |
| 18 #include "chromeos/audio/cras_audio_handler.h" |
| 19 #include "chromeos/dbus/dbus_thread_manager.h" |
| 20 #include "chromeos/network/network_connect.h" |
| 21 #include "chromeos/network/network_handler.h" |
| 22 #include "chromeos/system/fake_statistics_provider.h" |
| 23 #include "device/bluetooth/dbus/bluez_dbus_manager.h" // nogncheck |
| 16 #include "services/service_manager/public/cpp/connection.h" | 24 #include "services/service_manager/public/cpp/connection.h" |
| 17 #include "services/service_manager/public/cpp/connector.h" | 25 #include "services/service_manager/public/cpp/connector.h" |
| 18 #include "services/service_manager/public/cpp/service_context.h" | 26 #include "services/service_manager/public/cpp/service_context.h" |
| 19 #include "services/tracing/public/cpp/provider.h" | 27 #include "services/tracing/public/cpp/provider.h" |
| 20 #include "services/ui/common/accelerator_util.h" | 28 #include "services/ui/common/accelerator_util.h" |
| 21 #include "services/ui/public/cpp/gpu/gpu.h" | 29 #include "services/ui/public/cpp/gpu/gpu.h" |
| 22 #include "ui/aura/env.h" | 30 #include "ui/aura/env.h" |
| 23 #include "ui/aura/mus/mus_context_factory.h" | 31 #include "ui/aura/mus/mus_context_factory.h" |
| 24 #include "ui/aura/mus/window_tree_client.h" | 32 #include "ui/aura/mus/window_tree_client.h" |
| 25 #include "ui/events/event.h" | 33 #include "ui/events/event.h" |
| 26 #include "ui/message_center/message_center.h" | 34 #include "ui/message_center/message_center.h" |
| 27 #include "ui/views/mus/aura_init.h" | 35 #include "ui/views/mus/aura_init.h" |
| 28 | 36 |
| 29 #if defined(OS_CHROMEOS) | |
| 30 #include "ash/common/system/chromeos/power/power_status.h" | |
| 31 #include "ash/mus/network_connect_delegate_mus.h" | |
| 32 #include "chromeos/audio/cras_audio_handler.h" | |
| 33 #include "chromeos/dbus/dbus_thread_manager.h" | |
| 34 #include "chromeos/network/network_connect.h" | |
| 35 #include "chromeos/network/network_handler.h" | |
| 36 #include "chromeos/system/fake_statistics_provider.h" | |
| 37 #include "device/bluetooth/dbus/bluez_dbus_manager.h" // nogncheck | |
| 38 #endif | |
| 39 | |
| 40 namespace ash { | 37 namespace ash { |
| 41 namespace mus { | 38 namespace mus { |
| 42 | 39 |
| 43 WindowManagerApplication::WindowManagerApplication() {} | 40 WindowManagerApplication::WindowManagerApplication() {} |
| 44 | 41 |
| 45 WindowManagerApplication::~WindowManagerApplication() { | 42 WindowManagerApplication::~WindowManagerApplication() { |
| 46 // Destroy the WindowManager while still valid. This way we ensure | 43 // Destroy the WindowManager while still valid. This way we ensure |
| 47 // OnWillDestroyRootWindowController() is called (if it hasn't been already). | 44 // OnWillDestroyRootWindowController() is called (if it hasn't been already). |
| 48 window_manager_.reset(); | 45 window_manager_.reset(); |
| 49 | 46 |
| 50 if (blocking_pool_) { | 47 if (blocking_pool_) { |
| 51 // Like BrowserThreadImpl, the goal is to make it impossible for ash to | 48 // Like BrowserThreadImpl, the goal is to make it impossible for ash to |
| 52 // 'infinite loop' during shutdown, but to reasonably expect that all | 49 // 'infinite loop' during shutdown, but to reasonably expect that all |
| 53 // BLOCKING_SHUTDOWN tasks queued during shutdown get run. There's nothing | 50 // BLOCKING_SHUTDOWN tasks queued during shutdown get run. There's nothing |
| 54 // particularly scientific about the number chosen. | 51 // particularly scientific about the number chosen. |
| 55 const int kMaxNewShutdownBlockingTasks = 1000; | 52 const int kMaxNewShutdownBlockingTasks = 1000; |
| 56 blocking_pool_->Shutdown(kMaxNewShutdownBlockingTasks); | 53 blocking_pool_->Shutdown(kMaxNewShutdownBlockingTasks); |
| 57 } | 54 } |
| 58 | 55 |
| 59 gpu_.reset(); | 56 gpu_.reset(); |
| 60 #if defined(OS_CHROMEOS) | |
| 61 statistics_provider_.reset(); | 57 statistics_provider_.reset(); |
| 62 #endif | |
| 63 ShutdownComponents(); | 58 ShutdownComponents(); |
| 64 } | 59 } |
| 65 | 60 |
| 66 void WindowManagerApplication::InitWindowManager( | 61 void WindowManagerApplication::InitWindowManager( |
| 67 std::unique_ptr<aura::WindowTreeClient> window_tree_client, | 62 std::unique_ptr<aura::WindowTreeClient> window_tree_client, |
| 68 const scoped_refptr<base::SequencedWorkerPool>& blocking_pool) { | 63 const scoped_refptr<base::SequencedWorkerPool>& blocking_pool) { |
| 69 // Tests may have already set the WindowTreeClient. | 64 // Tests may have already set the WindowTreeClient. |
| 70 if (!aura::Env::GetInstance()->HasWindowTreeClient()) | 65 if (!aura::Env::GetInstance()->HasWindowTreeClient()) |
| 71 aura::Env::GetInstance()->SetWindowTreeClient(window_tree_client.get()); | 66 aura::Env::GetInstance()->SetWindowTreeClient(window_tree_client.get()); |
| 72 InitializeComponents(); | 67 InitializeComponents(); |
| 73 #if defined(OS_CHROMEOS) | 68 |
| 74 // TODO(jamescook): Refactor StatisticsProvider so we can get just the data | 69 // TODO(jamescook): Refactor StatisticsProvider so we can get just the data |
| 75 // we need in ash. Right now StatisticsProviderImpl launches the crossystem | 70 // we need in ash. Right now StatisticsProviderImpl launches the crossystem |
| 76 // binary to get system data, which we don't want to do twice on startup. | 71 // binary to get system data, which we don't want to do twice on startup. |
| 77 statistics_provider_.reset( | 72 statistics_provider_.reset( |
| 78 new chromeos::system::ScopedFakeStatisticsProvider()); | 73 new chromeos::system::ScopedFakeStatisticsProvider()); |
| 79 statistics_provider_->SetMachineStatistic("initial_locale", "en-US"); | 74 statistics_provider_->SetMachineStatistic("initial_locale", "en-US"); |
| 80 statistics_provider_->SetMachineStatistic("keyboard_layout", ""); | 75 statistics_provider_->SetMachineStatistic("keyboard_layout", ""); |
| 81 #endif | 76 |
| 82 window_manager_->Init(std::move(window_tree_client), blocking_pool); | 77 window_manager_->Init(std::move(window_tree_client), blocking_pool); |
| 83 } | 78 } |
| 84 | 79 |
| 85 void WindowManagerApplication::InitializeComponents() { | 80 void WindowManagerApplication::InitializeComponents() { |
| 86 message_center::MessageCenter::Initialize(); | 81 message_center::MessageCenter::Initialize(); |
| 87 #if defined(OS_CHROMEOS) | 82 |
| 88 // Must occur after mojo::ApplicationRunner has initialized AtExitManager, but | 83 // Must occur after mojo::ApplicationRunner has initialized AtExitManager, but |
| 89 // before WindowManager::Init(). | 84 // before WindowManager::Init(). |
| 90 chromeos::DBusThreadManager::Initialize( | 85 chromeos::DBusThreadManager::Initialize( |
| 91 chromeos::DBusThreadManager::PROCESS_ASH); | 86 chromeos::DBusThreadManager::PROCESS_ASH); |
| 92 | 87 |
| 93 // See ChromeBrowserMainPartsChromeos for ordering details. | 88 // See ChromeBrowserMainPartsChromeos for ordering details. |
| 94 bluez::BluezDBusManager::Initialize( | 89 bluez::BluezDBusManager::Initialize( |
| 95 chromeos::DBusThreadManager::Get()->GetSystemBus(), | 90 chromeos::DBusThreadManager::Get()->GetSystemBus(), |
| 96 chromeos::DBusThreadManager::Get()->IsUsingFakes()); | 91 chromeos::DBusThreadManager::Get()->IsUsingFakes()); |
| 97 chromeos::NetworkHandler::Initialize(); | 92 chromeos::NetworkHandler::Initialize(); |
| 98 network_connect_delegate_.reset(new NetworkConnectDelegateMus()); | 93 network_connect_delegate_.reset(new NetworkConnectDelegateMus()); |
| 99 chromeos::NetworkConnect::Initialize(network_connect_delegate_.get()); | 94 chromeos::NetworkConnect::Initialize(network_connect_delegate_.get()); |
| 100 // TODO(jamescook): Initialize real audio handler. | 95 // TODO(jamescook): Initialize real audio handler. |
| 101 chromeos::CrasAudioHandler::InitializeForTesting(); | 96 chromeos::CrasAudioHandler::InitializeForTesting(); |
| 102 PowerStatus::Initialize(); | 97 PowerStatus::Initialize(); |
| 103 #endif | |
| 104 } | 98 } |
| 105 | 99 |
| 106 void WindowManagerApplication::ShutdownComponents() { | 100 void WindowManagerApplication::ShutdownComponents() { |
| 107 #if defined(OS_CHROMEOS) | |
| 108 PowerStatus::Shutdown(); | 101 PowerStatus::Shutdown(); |
| 109 chromeos::CrasAudioHandler::Shutdown(); | 102 chromeos::CrasAudioHandler::Shutdown(); |
| 110 chromeos::NetworkConnect::Shutdown(); | 103 chromeos::NetworkConnect::Shutdown(); |
| 111 network_connect_delegate_.reset(); | 104 network_connect_delegate_.reset(); |
| 112 chromeos::NetworkHandler::Shutdown(); | 105 chromeos::NetworkHandler::Shutdown(); |
| 113 bluez::BluezDBusManager::Shutdown(); | 106 bluez::BluezDBusManager::Shutdown(); |
| 114 chromeos::DBusThreadManager::Shutdown(); | 107 chromeos::DBusThreadManager::Shutdown(); |
| 115 #endif | |
| 116 message_center::MessageCenter::Shutdown(); | 108 message_center::MessageCenter::Shutdown(); |
| 117 } | 109 } |
| 118 | 110 |
| 119 void WindowManagerApplication::OnStart() { | 111 void WindowManagerApplication::OnStart() { |
| 120 aura_init_ = base::MakeUnique<views::AuraInit>( | 112 aura_init_ = base::MakeUnique<views::AuraInit>( |
| 121 context()->connector(), context()->identity(), "ash_mus_resources.pak", | 113 context()->connector(), context()->identity(), "ash_mus_resources.pak", |
| 122 "ash_mus_resources_200.pak", nullptr, | 114 "ash_mus_resources_200.pak", nullptr, |
| 123 views::AuraInit::Mode::AURA_MUS_WINDOW_MANAGER); | 115 views::AuraInit::Mode::AURA_MUS_WINDOW_MANAGER); |
| 124 gpu_ = ui::Gpu::Create(context()->connector()); | 116 gpu_ = ui::Gpu::Create(context()->connector()); |
| 125 compositor_context_factory_ = | 117 compositor_context_factory_ = |
| (...skipping 22 matching lines...) Expand all Loading... |
| 148 const service_manager::ServiceInfo& remote_info, | 140 const service_manager::ServiceInfo& remote_info, |
| 149 service_manager::InterfaceRegistry* registry) { | 141 service_manager::InterfaceRegistry* registry) { |
| 150 // Register services used in both classic ash and mash. | 142 // Register services used in both classic ash and mash. |
| 151 mojo_interface_factory::RegisterInterfaces( | 143 mojo_interface_factory::RegisterInterfaces( |
| 152 registry, base::ThreadTaskRunnerHandle::Get()); | 144 registry, base::ThreadTaskRunnerHandle::Get()); |
| 153 return true; | 145 return true; |
| 154 } | 146 } |
| 155 | 147 |
| 156 } // namespace mus | 148 } // namespace mus |
| 157 } // namespace ash | 149 } // namespace ash |
| OLD | NEW |