Chromium Code Reviews| 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/mojo_interface_factory.h" | 9 #include "ash/common/mojo_interface_factory.h" |
| 10 #include "ash/common/system/chromeos/power/power_status.h" | 10 #include "ash/common/system/chromeos/power/power_status.h" |
| 11 #include "ash/common/wm_shell.h" | 11 #include "ash/common/wm_shell.h" |
| 12 #include "ash/mus/network_connect_delegate_mus.h" | 12 #include "ash/mus/network_connect_delegate_mus.h" |
| 13 #include "ash/mus/window_manager.h" | 13 #include "ash/mus/window_manager.h" |
| 14 #include "base/bind.h" | 14 #include "base/bind.h" |
| 15 #include "base/memory/ptr_util.h" | 15 #include "base/memory/ptr_util.h" |
| 16 #include "base/threading/sequenced_worker_pool.h" | 16 #include "base/threading/sequenced_worker_pool.h" |
| 17 #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" | 18 #include "chromeos/audio/cras_audio_handler.h" |
| 19 #include "chromeos/dbus/dbus_thread_manager.h" | 19 #include "chromeos/dbus/dbus_thread_manager.h" |
| 20 #include "chromeos/network/network_connect.h" | 20 #include "chromeos/network/network_connect.h" |
| 21 #include "chromeos/network/network_handler.h" | 21 #include "chromeos/network/network_handler.h" |
| 22 #include "chromeos/system/fake_statistics_provider.h" | 22 #include "chromeos/system/fake_statistics_provider.h" |
| 23 #include "components/discardable_memory/client/client_discardable_shared_memory_ manager.h" | |
| 23 #include "device/bluetooth/bluetooth_adapter_factory.h" | 24 #include "device/bluetooth/bluetooth_adapter_factory.h" |
| 24 #include "device/bluetooth/dbus/bluez_dbus_manager.h" | 25 #include "device/bluetooth/dbus/bluez_dbus_manager.h" |
| 25 #include "services/service_manager/public/cpp/connection.h" | 26 #include "services/service_manager/public/cpp/connection.h" |
| 26 #include "services/service_manager/public/cpp/connector.h" | 27 #include "services/service_manager/public/cpp/connector.h" |
| 27 #include "services/service_manager/public/cpp/service_context.h" | 28 #include "services/service_manager/public/cpp/service_context.h" |
| 28 #include "services/tracing/public/cpp/provider.h" | 29 #include "services/tracing/public/cpp/provider.h" |
| 29 #include "services/ui/common/accelerator_util.h" | 30 #include "services/ui/common/accelerator_util.h" |
| 31 #include "services/ui/public/interfaces/constants.mojom.h" | |
| 30 #include "ui/aura/env.h" | 32 #include "ui/aura/env.h" |
| 31 #include "ui/aura/mus/window_tree_client.h" | 33 #include "ui/aura/mus/window_tree_client.h" |
| 32 #include "ui/events/event.h" | 34 #include "ui/events/event.h" |
| 33 #include "ui/message_center/message_center.h" | 35 #include "ui/message_center/message_center.h" |
| 34 #include "ui/views/mus/aura_init.h" | 36 #include "ui/views/mus/aura_init.h" |
| 35 | 37 |
| 36 namespace ash { | 38 namespace ash { |
| 37 namespace mus { | 39 namespace mus { |
| 38 | 40 |
| 39 WindowManagerApplication::WindowManagerApplication() {} | 41 WindowManagerApplication::WindowManagerApplication() {} |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 100 chromeos::NetworkConnect::Shutdown(); | 102 chromeos::NetworkConnect::Shutdown(); |
| 101 network_connect_delegate_.reset(); | 103 network_connect_delegate_.reset(); |
| 102 chromeos::NetworkHandler::Shutdown(); | 104 chromeos::NetworkHandler::Shutdown(); |
| 103 device::BluetoothAdapterFactory::Shutdown(); | 105 device::BluetoothAdapterFactory::Shutdown(); |
| 104 bluez::BluezDBusManager::Shutdown(); | 106 bluez::BluezDBusManager::Shutdown(); |
| 105 chromeos::DBusThreadManager::Shutdown(); | 107 chromeos::DBusThreadManager::Shutdown(); |
| 106 message_center::MessageCenter::Shutdown(); | 108 message_center::MessageCenter::Shutdown(); |
| 107 } | 109 } |
| 108 | 110 |
| 109 void WindowManagerApplication::OnStart() { | 111 void WindowManagerApplication::OnStart() { |
| 112 io_thread_ = base::MakeUnique<base::Thread>("IOThread"); | |
| 113 base::Thread::Options thread_options(base::MessageLoop::TYPE_IO, 0); | |
| 114 thread_options.priority = base::ThreadPriority::NORMAL; | |
| 115 CHECK(io_thread_->StartWithOptions(thread_options)); | |
| 116 auto io_task_runner = io_thread_->task_runner(); | |
| 110 aura_init_ = base::MakeUnique<views::AuraInit>( | 117 aura_init_ = base::MakeUnique<views::AuraInit>( |
| 111 context()->connector(), context()->identity(), "ash_mus_resources.pak", | 118 context()->connector(), context()->identity(), "ash_mus_resources.pak", |
| 112 "ash_mus_resources_200.pak", nullptr, | 119 "ash_mus_resources_200.pak", io_task_runner, |
|
James Cook
2017/03/09 21:00:21
Can you add a comment somewhere (maybe in the Aura
| |
| 113 views::AuraInit::Mode::AURA_MUS_WINDOW_MANAGER); | 120 views::AuraInit::Mode::AURA_MUS_WINDOW_MANAGER); |
| 114 window_manager_.reset(new WindowManager(context()->connector())); | 121 window_manager_.reset(new WindowManager(context()->connector())); |
| 115 | 122 |
| 123 discardable_memory::mojom::DiscardableSharedMemoryManagerPtr manager_ptr; | |
|
James Cook
2017/03/09 21:00:21
This block of code seems like it should live down
Peng
2017/03/09 21:35:43
+sky, for his opinion.
| |
| 124 context()->connector()->BindInterface(ui::mojom::kServiceName, &manager_ptr); | |
| 125 discardable_shared_memory_manager_ = base::MakeUnique< | |
| 126 discardable_memory::ClientDiscardableSharedMemoryManager>( | |
| 127 std::move(manager_ptr), io_task_runner); | |
| 128 base::DiscardableMemoryAllocator::SetInstance( | |
| 129 discardable_shared_memory_manager_.get()); | |
| 130 | |
| 116 tracing_.Initialize(context()->connector(), context()->identity().name()); | 131 tracing_.Initialize(context()->connector(), context()->identity().name()); |
| 117 | 132 |
| 118 std::unique_ptr<aura::WindowTreeClient> window_tree_client = | 133 std::unique_ptr<aura::WindowTreeClient> window_tree_client = |
| 119 base::MakeUnique<aura::WindowTreeClient>( | 134 base::MakeUnique<aura::WindowTreeClient>( |
| 120 context()->connector(), window_manager_.get(), window_manager_.get()); | 135 context()->connector(), window_manager_.get(), window_manager_.get(), |
| 136 nullptr, io_task_runner); | |
| 121 window_tree_client->ConnectAsWindowManager(); | 137 window_tree_client->ConnectAsWindowManager(); |
| 122 | 138 |
| 123 const size_t kMaxNumberThreads = 3u; // Matches that of content. | 139 const size_t kMaxNumberThreads = 3u; // Matches that of content. |
| 124 const char kThreadNamePrefix[] = "MashBlocking"; | 140 const char kThreadNamePrefix[] = "MashBlocking"; |
| 125 blocking_pool_ = new base::SequencedWorkerPool( | 141 blocking_pool_ = new base::SequencedWorkerPool( |
| 126 kMaxNumberThreads, kThreadNamePrefix, base::TaskPriority::USER_VISIBLE); | 142 kMaxNumberThreads, kThreadNamePrefix, base::TaskPriority::USER_VISIBLE); |
| 127 InitWindowManager(std::move(window_tree_client), blocking_pool_); | 143 InitWindowManager(std::move(window_tree_client), blocking_pool_); |
| 128 } | 144 } |
| 129 | 145 |
| 130 bool WindowManagerApplication::OnConnect( | 146 bool WindowManagerApplication::OnConnect( |
| 131 const service_manager::ServiceInfo& remote_info, | 147 const service_manager::ServiceInfo& remote_info, |
| 132 service_manager::InterfaceRegistry* registry) { | 148 service_manager::InterfaceRegistry* registry) { |
| 133 // Register services used in both classic ash and mash. | 149 // Register services used in both classic ash and mash. |
| 134 mojo_interface_factory::RegisterInterfaces( | 150 mojo_interface_factory::RegisterInterfaces( |
| 135 registry, base::ThreadTaskRunnerHandle::Get()); | 151 registry, base::ThreadTaskRunnerHandle::Get()); |
| 136 return true; | 152 return true; |
| 137 } | 153 } |
| 138 | 154 |
| 139 } // namespace mus | 155 } // namespace mus |
| 140 } // namespace ash | 156 } // namespace ash |
| OLD | NEW |