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

Side by Side Diff: services/ui/input_devices/input_device_server.cc

Issue 2795883002: Eliminate OnConnect usage (Closed)
Patch Set: . Created 3 years, 8 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/input_devices/input_device_server.h ('k') | services/ui/service.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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/input_devices/input_device_server.h" 5 #include "services/ui/input_devices/input_device_server.h"
6 6
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "services/service_manager/public/cpp/interface_registry.h" 10 #include "services/service_manager/public/cpp/binder_registry.h"
11 #include "ui/events/devices/input_device.h" 11 #include "ui/events/devices/input_device.h"
12 #include "ui/events/devices/touchscreen_device.h" 12 #include "ui/events/devices/touchscreen_device.h"
13 13
14 namespace ui { 14 namespace ui {
15 15
16 InputDeviceServer::InputDeviceServer() {} 16 InputDeviceServer::InputDeviceServer() {}
17 17
18 InputDeviceServer::~InputDeviceServer() { 18 InputDeviceServer::~InputDeviceServer() {
19 if (manager_ && ui::DeviceDataManager::HasInstance()) { 19 if (manager_ && ui::DeviceDataManager::HasInstance()) {
20 manager_->RemoveObserver(this); 20 manager_->RemoveObserver(this);
21 manager_ = nullptr; 21 manager_ = nullptr;
22 } 22 }
23 } 23 }
24 24
25 void InputDeviceServer::RegisterAsObserver() { 25 void InputDeviceServer::RegisterAsObserver() {
26 if (!manager_ && ui::DeviceDataManager::HasInstance()) { 26 if (!manager_ && ui::DeviceDataManager::HasInstance()) {
27 manager_ = ui::DeviceDataManager::GetInstance(); 27 manager_ = ui::DeviceDataManager::GetInstance();
28 manager_->AddObserver(this); 28 manager_->AddObserver(this);
29 } 29 }
30 } 30 }
31 31
32 bool InputDeviceServer::IsRegisteredAsObserver() const { 32 bool InputDeviceServer::IsRegisteredAsObserver() const {
33 return manager_ != nullptr; 33 return manager_ != nullptr;
34 } 34 }
35 35
36 void InputDeviceServer::AddInterface( 36 void InputDeviceServer::AddInterface(
37 service_manager::InterfaceRegistry* registry) { 37 service_manager::BinderRegistry* registry) {
38 DCHECK(IsRegisteredAsObserver()); 38 DCHECK(IsRegisteredAsObserver());
39 registry->AddInterface<mojom::InputDeviceServer>(this); 39 registry->AddInterface<mojom::InputDeviceServer>(this);
40 } 40 }
41 41
42 void InputDeviceServer::AddObserver( 42 void InputDeviceServer::AddObserver(
43 mojom::InputDeviceObserverMojoPtr observer) { 43 mojom::InputDeviceObserverMojoPtr observer) {
44 // We only want to send this message once, so we need to check to make sure 44 // We only want to send this message once, so we need to check to make sure
45 // device lists are actually complete before sending it to a new observer. 45 // device lists are actually complete before sending it to a new observer.
46 if (manager_->AreDeviceListsComplete()) 46 if (manager_->AreDeviceListsComplete())
47 SendDeviceListsComplete(observer.get()); 47 SendDeviceListsComplete(observer.get());
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 manager_->GetKeyboardDevices(), manager_->GetTouchscreenDevices(), 108 manager_->GetKeyboardDevices(), manager_->GetTouchscreenDevices(),
109 manager_->GetMouseDevices(), manager_->GetTouchpadDevices()); 109 manager_->GetMouseDevices(), manager_->GetTouchpadDevices());
110 } 110 }
111 111
112 void InputDeviceServer::Create(const service_manager::Identity& remote_identity, 112 void InputDeviceServer::Create(const service_manager::Identity& remote_identity,
113 mojom::InputDeviceServerRequest request) { 113 mojom::InputDeviceServerRequest request) {
114 bindings_.AddBinding(this, std::move(request)); 114 bindings_.AddBinding(this, std::move(request));
115 } 115 }
116 116
117 } // namespace ui 117 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/input_devices/input_device_server.h ('k') | services/ui/service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698