Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(104)

Side by Side Diff: ash/mus/window_manager_application.cc

Issue 2644093002: aura: Some change to how the client-lib is set up. (Closed)
Patch Set: . Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/mus/window_manager_application.h ('k') | chrome/browser/chrome_content_browser_client.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/system/chromeos/power/power_status.h"
12 #include "ash/common/wm_shell.h" 12 #include "ash/common/wm_shell.h"
13 #include "ash/mus/network_connect_delegate_mus.h" 13 #include "ash/mus/network_connect_delegate_mus.h"
14 #include "ash/mus/window_manager.h" 14 #include "ash/mus/window_manager.h"
15 #include "base/bind.h" 15 #include "base/bind.h"
16 #include "base/memory/ptr_util.h" 16 #include "base/memory/ptr_util.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 "device/bluetooth/bluetooth_adapter_factory.h" 23 #include "device/bluetooth/bluetooth_adapter_factory.h"
24 #include "device/bluetooth/dbus/bluez_dbus_manager.h" 24 #include "device/bluetooth/dbus/bluez_dbus_manager.h"
25 #include "services/service_manager/public/cpp/connection.h" 25 #include "services/service_manager/public/cpp/connection.h"
26 #include "services/service_manager/public/cpp/connector.h" 26 #include "services/service_manager/public/cpp/connector.h"
27 #include "services/service_manager/public/cpp/service_context.h" 27 #include "services/service_manager/public/cpp/service_context.h"
28 #include "services/tracing/public/cpp/provider.h" 28 #include "services/tracing/public/cpp/provider.h"
29 #include "services/ui/common/accelerator_util.h" 29 #include "services/ui/common/accelerator_util.h"
30 #include "services/ui/public/cpp/gpu/gpu.h"
31 #include "ui/aura/env.h" 30 #include "ui/aura/env.h"
32 #include "ui/aura/mus/mus_context_factory.h"
33 #include "ui/aura/mus/window_tree_client.h" 31 #include "ui/aura/mus/window_tree_client.h"
34 #include "ui/events/event.h" 32 #include "ui/events/event.h"
35 #include "ui/message_center/message_center.h" 33 #include "ui/message_center/message_center.h"
36 #include "ui/views/mus/aura_init.h" 34 #include "ui/views/mus/aura_init.h"
37 35
38 namespace ash { 36 namespace ash {
39 namespace mus { 37 namespace mus {
40 38
41 WindowManagerApplication::WindowManagerApplication() {} 39 WindowManagerApplication::WindowManagerApplication() {}
42 40
43 WindowManagerApplication::~WindowManagerApplication() { 41 WindowManagerApplication::~WindowManagerApplication() {
44 // Destroy the WindowManager while still valid. This way we ensure 42 // Destroy the WindowManager while still valid. This way we ensure
45 // OnWillDestroyRootWindowController() is called (if it hasn't been already). 43 // OnWillDestroyRootWindowController() is called (if it hasn't been already).
46 window_manager_.reset(); 44 window_manager_.reset();
47 45
48 if (blocking_pool_) { 46 if (blocking_pool_) {
49 // Like BrowserThreadImpl, the goal is to make it impossible for ash to 47 // Like BrowserThreadImpl, the goal is to make it impossible for ash to
50 // 'infinite loop' during shutdown, but to reasonably expect that all 48 // 'infinite loop' during shutdown, but to reasonably expect that all
51 // BLOCKING_SHUTDOWN tasks queued during shutdown get run. There's nothing 49 // BLOCKING_SHUTDOWN tasks queued during shutdown get run. There's nothing
52 // particularly scientific about the number chosen. 50 // particularly scientific about the number chosen.
53 const int kMaxNewShutdownBlockingTasks = 1000; 51 const int kMaxNewShutdownBlockingTasks = 1000;
54 blocking_pool_->Shutdown(kMaxNewShutdownBlockingTasks); 52 blocking_pool_->Shutdown(kMaxNewShutdownBlockingTasks);
55 } 53 }
56 54
57 gpu_.reset();
58 statistics_provider_.reset(); 55 statistics_provider_.reset();
59 ShutdownComponents(); 56 ShutdownComponents();
60 } 57 }
61 58
62 void WindowManagerApplication::InitWindowManager( 59 void WindowManagerApplication::InitWindowManager(
63 std::unique_ptr<aura::WindowTreeClient> window_tree_client, 60 std::unique_ptr<aura::WindowTreeClient> window_tree_client,
64 const scoped_refptr<base::SequencedWorkerPool>& blocking_pool) { 61 const scoped_refptr<base::SequencedWorkerPool>& blocking_pool) {
65 // Tests may have already set the WindowTreeClient. 62 // Tests may have already set the WindowTreeClient.
66 if (!aura::Env::GetInstance()->HasWindowTreeClient()) 63 if (!aura::Env::GetInstance()->HasWindowTreeClient())
67 aura::Env::GetInstance()->SetWindowTreeClient(window_tree_client.get()); 64 aura::Env::GetInstance()->SetWindowTreeClient(window_tree_client.get());
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 bluez::BluezDBusManager::Shutdown(); 104 bluez::BluezDBusManager::Shutdown();
108 chromeos::DBusThreadManager::Shutdown(); 105 chromeos::DBusThreadManager::Shutdown();
109 message_center::MessageCenter::Shutdown(); 106 message_center::MessageCenter::Shutdown();
110 } 107 }
111 108
112 void WindowManagerApplication::OnStart() { 109 void WindowManagerApplication::OnStart() {
113 aura_init_ = base::MakeUnique<views::AuraInit>( 110 aura_init_ = base::MakeUnique<views::AuraInit>(
114 context()->connector(), context()->identity(), "ash_mus_resources.pak", 111 context()->connector(), context()->identity(), "ash_mus_resources.pak",
115 "ash_mus_resources_200.pak", nullptr, 112 "ash_mus_resources_200.pak", nullptr,
116 views::AuraInit::Mode::AURA_MUS_WINDOW_MANAGER); 113 views::AuraInit::Mode::AURA_MUS_WINDOW_MANAGER);
117 gpu_ = ui::Gpu::Create(context()->connector());
118 compositor_context_factory_ =
119 base::MakeUnique<aura::MusContextFactory>(gpu_.get());
120 aura::Env::GetInstance()->set_context_factory(
121 compositor_context_factory_.get());
122 window_manager_.reset(new WindowManager(context()->connector())); 114 window_manager_.reset(new WindowManager(context()->connector()));
123 115
124 MaterialDesignController::Initialize(); 116 MaterialDesignController::Initialize();
125 117
126 tracing_.Initialize(context()->connector(), context()->identity().name()); 118 tracing_.Initialize(context()->connector(), context()->identity().name());
127 119
128 std::unique_ptr<aura::WindowTreeClient> window_tree_client = 120 std::unique_ptr<aura::WindowTreeClient> window_tree_client =
129 base::MakeUnique<aura::WindowTreeClient>( 121 base::MakeUnique<aura::WindowTreeClient>(
130 context()->connector(), window_manager_.get(), window_manager_.get()); 122 context()->connector(), window_manager_.get(), window_manager_.get());
131 window_tree_client->ConnectAsWindowManager(); 123 window_tree_client->ConnectAsWindowManager();
132 124
133 const size_t kMaxNumberThreads = 3u; // Matches that of content. 125 const size_t kMaxNumberThreads = 3u; // Matches that of content.
134 const char kThreadNamePrefix[] = "MashBlocking"; 126 const char kThreadNamePrefix[] = "MashBlocking";
135 blocking_pool_ = new base::SequencedWorkerPool( 127 blocking_pool_ = new base::SequencedWorkerPool(
136 kMaxNumberThreads, kThreadNamePrefix, base::TaskPriority::USER_VISIBLE); 128 kMaxNumberThreads, kThreadNamePrefix, base::TaskPriority::USER_VISIBLE);
137 InitWindowManager(std::move(window_tree_client), blocking_pool_); 129 InitWindowManager(std::move(window_tree_client), blocking_pool_);
138 } 130 }
139 131
140 bool WindowManagerApplication::OnConnect( 132 bool WindowManagerApplication::OnConnect(
141 const service_manager::ServiceInfo& remote_info, 133 const service_manager::ServiceInfo& remote_info,
142 service_manager::InterfaceRegistry* registry) { 134 service_manager::InterfaceRegistry* registry) {
143 // Register services used in both classic ash and mash. 135 // Register services used in both classic ash and mash.
144 mojo_interface_factory::RegisterInterfaces( 136 mojo_interface_factory::RegisterInterfaces(
145 registry, base::ThreadTaskRunnerHandle::Get()); 137 registry, base::ThreadTaskRunnerHandle::Get());
146 return true; 138 return true;
147 } 139 }
148 140
149 } // namespace mus 141 } // namespace mus
150 } // namespace ash 142 } // namespace ash
OLDNEW
« no previous file with comments | « ash/mus/window_manager_application.h ('k') | chrome/browser/chrome_content_browser_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698