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

Side by Side Diff: services/ui/service.cc

Issue 2274353003: Add PlatformScreenDelegate and start implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More fixes for comments. 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 | « services/ui/service.h ('k') | services/ui/ws/BUILD.gn » ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "services/ui/service.h" 5 #include "services/ui/service.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 }; 74 };
75 75
76 struct Service::UserState { 76 struct Service::UserState {
77 std::unique_ptr<ws::AccessibilityManager> accessibility; 77 std::unique_ptr<ws::AccessibilityManager> accessibility;
78 std::unique_ptr<ws::WindowTreeHostFactory> window_tree_host_factory; 78 std::unique_ptr<ws::WindowTreeHostFactory> window_tree_host_factory;
79 }; 79 };
80 80
81 Service::Service() 81 Service::Service()
82 : test_config_(false), 82 : test_config_(false),
83 platform_screen_(display::PlatformScreen::Create()), 83 platform_screen_(display::PlatformScreen::Create()),
84 ime_registrar_(&ime_server_), 84 ime_registrar_(&ime_server_) {}
85 weak_ptr_factory_(this) {}
86 85
87 Service::~Service() { 86 Service::~Service() {
88 // Destroy |window_server_| first, since it depends on |event_source_|. 87 // Destroy |window_server_| first, since it depends on |event_source_|.
89 // WindowServer (or more correctly its Displays) may have state that needs to 88 // WindowServer (or more correctly its Displays) may have state that needs to
90 // be destroyed before GpuState as well. 89 // be destroyed before GpuState as well.
91 window_server_.reset(); 90 window_server_.reset();
92 } 91 }
93 92
94 void Service::InitializeResources(shell::Connector* connector) { 93 void Service::InitializeResources(shell::Connector* connector) {
95 if (ui::ResourceBundle::HasSharedInstance()) 94 if (ui::ResourceBundle::HasSharedInstance())
(...skipping 30 matching lines...) Expand all
126 return it->second.get(); 125 return it->second.get();
127 user_id_to_user_state_[user_id] = base::WrapUnique(new UserState); 126 user_id_to_user_state_[user_id] = base::WrapUnique(new UserState);
128 return user_id_to_user_state_[user_id].get(); 127 return user_id_to_user_state_[user_id].get();
129 } 128 }
130 129
131 void Service::AddUserIfNecessary(const shell::Identity& remote_identity) { 130 void Service::AddUserIfNecessary(const shell::Identity& remote_identity) {
132 window_server_->user_id_tracker()->AddUserId(remote_identity.user_id()); 131 window_server_->user_id_tracker()->AddUserId(remote_identity.user_id());
133 } 132 }
134 133
135 void Service::OnStart(const shell::Identity& identity) { 134 void Service::OnStart(const shell::Identity& identity) {
136 platform_display_init_params_.surfaces_state = new SurfacesState;
137
138 base::PlatformThread::SetName("mus"); 135 base::PlatformThread::SetName("mus");
139 tracing_.Initialize(connector(), identity.name()); 136 tracing_.Initialize(connector(), identity.name());
140 TRACE_EVENT0("mus", "Service::Initialize started"); 137 TRACE_EVENT0("mus", "Service::Initialize started");
141 138
142 test_config_ = base::CommandLine::ForCurrentProcess()->HasSwitch( 139 test_config_ = base::CommandLine::ForCurrentProcess()->HasSwitch(
143 switches::kUseTestConfig); 140 switches::kUseTestConfig);
144 #if defined(USE_X11) 141 #if defined(USE_X11)
145 XInitThreads(); 142 XInitThreads();
146 if (test_config_) 143 if (test_config_)
147 ui::test::SetUseOverrideRedirectWindowByDefault(true); 144 ui::test::SetUseOverrideRedirectWindowByDefault(true);
(...skipping 29 matching lines...) Expand all
177 #endif 174 #endif
178 175
179 // This needs to happen after DeviceDataManager has been constructed. That 176 // This needs to happen after DeviceDataManager has been constructed. That
180 // happens either during OzonePlatform or PlatformEventSource initialization, 177 // happens either during OzonePlatform or PlatformEventSource initialization,
181 // so keep this line below both of those. 178 // so keep this line below both of those.
182 input_device_server_.RegisterAsObserver(); 179 input_device_server_.RegisterAsObserver();
183 180
184 gpu_proxy_.reset(new GpuServiceProxy()); 181 gpu_proxy_.reset(new GpuServiceProxy());
185 182
186 // Gpu must be running before the PlatformScreen can be initialized. 183 // Gpu must be running before the PlatformScreen can be initialized.
187 platform_screen_->Init(); 184 window_server_.reset(new ws::WindowServer(this));
188 window_server_.reset(
189 new ws::WindowServer(this, platform_display_init_params_.surfaces_state));
190 185
191 // DeviceDataManager must be initialized before TouchController. On non-Linux 186 // DeviceDataManager must be initialized before TouchController. On non-Linux
192 // platforms there is no DeviceDataManager so don't create touch controller. 187 // platforms there is no DeviceDataManager so don't create touch controller.
193 if (ui::DeviceDataManager::HasInstance()) 188 if (ui::DeviceDataManager::HasInstance())
194 touch_controller_.reset( 189 touch_controller_.reset(
195 new ws::TouchController(window_server_->display_manager())); 190 new ws::TouchController(window_server_->display_manager()));
196 } 191 }
197 192
198 bool Service::OnConnect(const shell::Identity& remote_identity, 193 bool Service::OnConnect(const shell::Identity& remote_identity,
199 shell::InterfaceRegistry* registry) { 194 shell::InterfaceRegistry* registry) {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 void Service::OnNoMoreDisplays() { 232 void Service::OnNoMoreDisplays() {
238 // We may get here from the destructor, in which case there is no messageloop. 233 // We may get here from the destructor, in which case there is no messageloop.
239 if (base::MessageLoop::current()) 234 if (base::MessageLoop::current())
240 base::MessageLoop::current()->QuitWhenIdle(); 235 base::MessageLoop::current()->QuitWhenIdle();
241 } 236 }
242 237
243 bool Service::IsTestConfig() const { 238 bool Service::IsTestConfig() const {
244 return test_config_; 239 return test_config_;
245 } 240 }
246 241
242 void Service::UpdateTouchTransforms() {
243 if (touch_controller_)
244 touch_controller_->UpdateTouchTransforms();
245 }
246
247 void Service::CreateDefaultDisplays() { 247 void Service::CreateDefaultDisplays() {
248 // An asynchronous callback will create the Displays once the physical 248 // The display manager will create Displays once hardware or virtual displays
249 // displays are ready. 249 // are ready.
250 platform_screen_->ConfigurePhysicalDisplay(base::Bind( 250 platform_screen_->Init(window_server_->display_manager());
251 &Service::OnCreatedPhysicalDisplay, weak_ptr_factory_.GetWeakPtr()));
252 } 251 }
253 252
254 void Service::Create(const shell::Identity& remote_identity, 253 void Service::Create(const shell::Identity& remote_identity,
255 mojom::AccessibilityManagerRequest request) { 254 mojom::AccessibilityManagerRequest request) {
256 UserState* user_state = GetUserState(remote_identity); 255 UserState* user_state = GetUserState(remote_identity);
257 if (!user_state->accessibility) { 256 if (!user_state->accessibility) {
258 const ws::UserId& user_id = remote_identity.user_id(); 257 const ws::UserId& user_id = remote_identity.user_id();
259 user_state->accessibility.reset( 258 user_state->accessibility.reset(
260 new ws::AccessibilityManager(window_server_.get(), user_id)); 259 new ws::AccessibilityManager(window_server_.get(), user_id));
261 } 260 }
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 AddUserIfNecessary(remote_identity); 332 AddUserIfNecessary(remote_identity);
334 new ws::WindowTreeFactory(window_server_.get(), remote_identity.user_id(), 333 new ws::WindowTreeFactory(window_server_.get(), remote_identity.user_id(),
335 remote_identity.name(), std::move(request)); 334 remote_identity.name(), std::move(request));
336 } 335 }
337 336
338 void Service::Create(const shell::Identity& remote_identity, 337 void Service::Create(const shell::Identity& remote_identity,
339 mojom::WindowTreeHostFactoryRequest request) { 338 mojom::WindowTreeHostFactoryRequest request) {
340 UserState* user_state = GetUserState(remote_identity); 339 UserState* user_state = GetUserState(remote_identity);
341 if (!user_state->window_tree_host_factory) { 340 if (!user_state->window_tree_host_factory) {
342 user_state->window_tree_host_factory.reset(new ws::WindowTreeHostFactory( 341 user_state->window_tree_host_factory.reset(new ws::WindowTreeHostFactory(
343 window_server_.get(), remote_identity.user_id(), 342 window_server_.get(), remote_identity.user_id()));
344 platform_display_init_params_));
345 } 343 }
346 user_state->window_tree_host_factory->AddBinding(std::move(request)); 344 user_state->window_tree_host_factory->AddBinding(std::move(request));
347 } 345 }
348 346
349 void Service::Create(const shell::Identity& remote_identity, 347 void Service::Create(const shell::Identity& remote_identity,
350 mojom::WindowServerTestRequest request) { 348 mojom::WindowServerTestRequest request) {
351 if (!test_config_) 349 if (!test_config_)
352 return; 350 return;
353 new ws::WindowServerTestImpl(window_server_.get(), std::move(request)); 351 new ws::WindowServerTestImpl(window_server_.get(), std::move(request));
354 } 352 }
355 353
356 void Service::OnCreatedPhysicalDisplay(int64_t id, const gfx::Rect& bounds) {
357 platform_display_init_params_.display_bounds = bounds;
358 platform_display_init_params_.display_id = id;
359 platform_display_init_params_.platform_screen = platform_screen_.get();
360
361 // Display manages its own lifetime.
362 ws::Display* host_impl =
363 new ws::Display(window_server_.get(), platform_display_init_params_);
364 host_impl->Init(nullptr);
365
366 if (touch_controller_)
367 touch_controller_->UpdateTouchTransforms();
368 }
369 354
370 } // namespace ui 355 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/service.h ('k') | services/ui/ws/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698