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

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

Issue 2318223003: mash: Migrate wallpaper controllers to ash/common. (Closed)
Patch Set: Fix nit. Created 4 years, 3 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') | ash/root_window_controller.h » ('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/wm_shell.h" 10 #include "ash/common/wm_shell.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 // AcceleratorRegistrarImpl removes an observer in its destructor. Destroy 76 // AcceleratorRegistrarImpl removes an observer in its destructor. Destroy
77 // it early on. 77 // it early on.
78 std::set<AcceleratorRegistrarImpl*> accelerator_registrars( 78 std::set<AcceleratorRegistrarImpl*> accelerator_registrars(
79 accelerator_registrars_); 79 accelerator_registrars_);
80 for (AcceleratorRegistrarImpl* registrar : accelerator_registrars) 80 for (AcceleratorRegistrarImpl* registrar : accelerator_registrars)
81 registrar->Destroy(); 81 registrar->Destroy();
82 82
83 // Destroy the WindowManager while still valid. This way we ensure 83 // Destroy the WindowManager while still valid. This way we ensure
84 // OnWillDestroyRootWindowController() is called (if it hasn't been already). 84 // OnWillDestroyRootWindowController() is called (if it hasn't been already).
85 window_manager_.reset(); 85 window_manager_.reset();
86
87 if (blocking_pool_) {
88 // Like BrowserThreadImpl, the goal is to make it impossible for ash to
89 // 'infinite loop' during shutdown, but to reasonably expect that all
90 // BLOCKING_SHUTDOWN tasks queued during shutdown get run. There's nothing
91 // particularly scientific about the number chosen.
92 const int kMaxNewShutdownBlockingTasks = 1000;
93 blocking_pool_->Shutdown(kMaxNewShutdownBlockingTasks);
94 }
95
86 gpu_service_.reset(); 96 gpu_service_.reset();
87 #if defined(OS_CHROMEOS) 97 #if defined(OS_CHROMEOS)
88 statistics_provider_.reset(); 98 statistics_provider_.reset();
89 #endif 99 #endif
90 ShutdownComponents(); 100 ShutdownComponents();
91 } 101 }
92 102
93 void WindowManagerApplication::OnAcceleratorRegistrarDestroyed( 103 void WindowManagerApplication::OnAcceleratorRegistrarDestroyed(
94 AcceleratorRegistrarImpl* registrar) { 104 AcceleratorRegistrarImpl* registrar) {
95 accelerator_registrars_.erase(registrar); 105 accelerator_registrars_.erase(registrar);
96 } 106 }
97 107
98 void WindowManagerApplication::InitWindowManager( 108 void WindowManagerApplication::InitWindowManager(
99 std::unique_ptr<ui::WindowTreeClient> window_tree_client) { 109 std::unique_ptr<ui::WindowTreeClient> window_tree_client,
110 const scoped_refptr<base::SequencedWorkerPool>& blocking_pool) {
100 InitializeComponents(); 111 InitializeComponents();
101 #if defined(OS_CHROMEOS) 112 #if defined(OS_CHROMEOS)
102 // TODO(jamescook): Refactor StatisticsProvider so we can get just the data 113 // TODO(jamescook): Refactor StatisticsProvider so we can get just the data
103 // we need in ash. Right now StatisticsProviderImpl launches the crossystem 114 // we need in ash. Right now StatisticsProviderImpl launches the crossystem
104 // binary to get system data, which we don't want to do twice on startup. 115 // binary to get system data, which we don't want to do twice on startup.
105 statistics_provider_.reset( 116 statistics_provider_.reset(
106 new chromeos::system::ScopedFakeStatisticsProvider()); 117 new chromeos::system::ScopedFakeStatisticsProvider());
107 statistics_provider_->SetMachineStatistic("initial_locale", "en-US"); 118 statistics_provider_->SetMachineStatistic("initial_locale", "en-US");
108 statistics_provider_->SetMachineStatistic("keyboard_layout", ""); 119 statistics_provider_->SetMachineStatistic("keyboard_layout", "");
109 #endif 120 #endif
110 window_manager_->Init(std::move(window_tree_client)); 121 window_manager_->Init(std::move(window_tree_client), blocking_pool);
111 } 122 }
112 123
113 void WindowManagerApplication::OnStart(const shell::Identity& identity) { 124 void WindowManagerApplication::OnStart(const shell::Identity& identity) {
114 aura_init_.reset(new views::AuraInit(connector(), "ash_mus_resources.pak")); 125 aura_init_.reset(new views::AuraInit(connector(), "ash_mus_resources.pak"));
115 gpu_service_ = ui::GpuService::Create(connector()); 126 gpu_service_ = ui::GpuService::Create(connector());
116 compositor_context_factory_.reset( 127 compositor_context_factory_.reset(
117 new views::SurfaceContextFactory(gpu_service_.get())); 128 new views::SurfaceContextFactory(gpu_service_.get()));
118 aura::Env::GetInstance()->set_context_factory( 129 aura::Env::GetInstance()->set_context_factory(
119 compositor_context_factory_.get()); 130 compositor_context_factory_.get());
120 window_manager_.reset(new WindowManager(connector())); 131 window_manager_.reset(new WindowManager(connector()));
121 132
122 MaterialDesignController::Initialize(); 133 MaterialDesignController::Initialize();
123 134
124 tracing_.Initialize(connector(), identity.name()); 135 tracing_.Initialize(connector(), identity.name());
125 136
126 std::unique_ptr<ui::WindowTreeClient> window_tree_client = 137 std::unique_ptr<ui::WindowTreeClient> window_tree_client =
127 base::MakeUnique<ui::WindowTreeClient>(window_manager_.get(), 138 base::MakeUnique<ui::WindowTreeClient>(window_manager_.get(),
128 window_manager_.get()); 139 window_manager_.get());
129 window_tree_client->ConnectAsWindowManager(connector()); 140 window_tree_client->ConnectAsWindowManager(connector());
130 141
131 native_widget_factory_mus_.reset( 142 native_widget_factory_mus_.reset(
132 new NativeWidgetFactoryMus(window_manager_.get())); 143 new NativeWidgetFactoryMus(window_manager_.get()));
133 144
134 InitWindowManager(std::move(window_tree_client)); 145 const size_t kMaxNumberThreads = 3u; // Matches that of content.
146 const char kThreadNamePrefix[] = "MashBlocking";
147 blocking_pool_ = new base::SequencedWorkerPool(
148 kMaxNumberThreads, kThreadNamePrefix, base::TaskPriority::USER_VISIBLE);
149 InitWindowManager(std::move(window_tree_client), blocking_pool_);
135 } 150 }
136 151
137 bool WindowManagerApplication::OnConnect(const shell::Identity& remote_identity, 152 bool WindowManagerApplication::OnConnect(const shell::Identity& remote_identity,
138 shell::InterfaceRegistry* registry) { 153 shell::InterfaceRegistry* registry) {
139 registry->AddInterface<ash::mojom::ShelfController>(this); 154 registry->AddInterface<ash::mojom::ShelfController>(this);
140 registry->AddInterface<ui::mojom::AcceleratorRegistrar>(this); 155 registry->AddInterface<ui::mojom::AcceleratorRegistrar>(this);
141 if (remote_identity.name() == "mojo:mash_session") { 156 if (remote_identity.name() == "mojo:mash_session") {
142 connector()->ConnectToInterface(remote_identity, &session_); 157 connector()->ConnectToInterface(remote_identity, &session_);
143 session_->AddScreenlockStateListener( 158 session_->AddScreenlockStateListener(
144 screenlock_state_listener_binding_.CreateInterfacePtrAndBind()); 159 screenlock_state_listener_binding_.CreateInterfacePtrAndBind());
(...skipping 28 matching lines...) Expand all
173 base::Bind(&WindowManagerApplication::OnAcceleratorRegistrarDestroyed, 188 base::Bind(&WindowManagerApplication::OnAcceleratorRegistrarDestroyed,
174 base::Unretained(this)))); 189 base::Unretained(this))));
175 } 190 }
176 191
177 void WindowManagerApplication::ScreenlockStateChanged(bool locked) { 192 void WindowManagerApplication::ScreenlockStateChanged(bool locked) {
178 window_manager_->SetScreenLocked(locked); 193 window_manager_->SetScreenLocked(locked);
179 } 194 }
180 195
181 } // namespace mus 196 } // namespace mus
182 } // namespace ash 197 } // namespace ash
OLDNEW
« no previous file with comments | « ash/mus/window_manager_application.h ('k') | ash/root_window_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698