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

Unified Diff: ui/events/devices/device_data_manager.cc

Issue 1182303005: Fixed the Touchscreen.TouchEventsEnabled histogram to record the correct values on X11 and Ozone ba… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed asvitkine@'s comments from patch set 11. Created 5 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: ui/events/devices/device_data_manager.cc
diff --git a/ui/events/devices/device_data_manager.cc b/ui/events/devices/device_data_manager.cc
index e725736df3923ad538e69795a0d10fd586c5e87b..107c1fa7fabaace87d78c25e5299ad633cd1310d 100644
--- a/ui/events/devices/device_data_manager.cc
+++ b/ui/events/devices/device_data_manager.cc
@@ -35,7 +35,9 @@ DeviceDataManager::~DeviceDataManager() {
DeviceDataManager* DeviceDataManager::instance() { return instance_; }
void DeviceDataManager::set_instance(DeviceDataManager* instance) {
- CHECK(!instance_) << "Can not set multiple instances of DeviceDataManager";
+ DCHECK(!instance || !instance_)
+ << "Can not set multiple instances of DeviceDataManager. Must explicitly "
+ "set to nullptr first.";
sadrul 2015/07/10 17:35:48 This should be more like: DCHECK(instance) << "
bruthig 2015/07/10 20:04:58 Done.
instance_ = instance;
}
@@ -46,6 +48,7 @@ void DeviceDataManager::CreateInstance() {
set_instance(new DeviceDataManager());
+ // TODO(bruthig): Replace the DeleteInstance callbacks with explicit calls.
base::AtExitManager::RegisterTask(base::Bind(DeleteInstance));
}
@@ -132,9 +135,7 @@ void DeviceDataManager::OnTouchscreenDevicesUpdated(
return;
}
touchscreen_devices_ = devices;
- FOR_EACH_OBSERVER(InputDeviceEventObserver,
- observers_,
- OnTouchscreenDeviceConfigurationChanged());
+ NotifyObserversTouchscreenDeviceConfigurationChanged();
}
void DeviceDataManager::OnKeyboardDevicesUpdated(
@@ -147,9 +148,7 @@ void DeviceDataManager::OnKeyboardDevicesUpdated(
return;
}
keyboard_devices_ = devices;
- FOR_EACH_OBSERVER(InputDeviceEventObserver,
- observers_,
- OnKeyboardDeviceConfigurationChanged());
+ NotifyObserversKeyboardDeviceConfigurationChanged();
}
void DeviceDataManager::OnMouseDevicesUpdated(
@@ -162,9 +161,7 @@ void DeviceDataManager::OnMouseDevicesUpdated(
return;
}
mouse_devices_ = devices;
- FOR_EACH_OBSERVER(InputDeviceEventObserver,
- observers_,
- OnMouseDeviceConfigurationChanged());
+ NotifyObserversMouseDeviceConfigurationChanged();
}
void DeviceDataManager::OnTouchpadDevicesUpdated(
@@ -177,17 +174,39 @@ void DeviceDataManager::OnTouchpadDevicesUpdated(
return;
}
touchpad_devices_ = devices;
- FOR_EACH_OBSERVER(InputDeviceEventObserver,
- observers_,
- OnTouchpadDeviceConfigurationChanged());
+ NotifyObserversTouchpadDeviceConfigurationChanged();
}
void DeviceDataManager::OnDeviceListsComplete() {
if (!device_lists_complete_) {
device_lists_complete_ = true;
+ NotifyObserversDeviceListsComplete();
+ }
+}
+
+void DeviceDataManager::NotifyObserversTouchscreenDeviceConfigurationChanged() {
+ FOR_EACH_OBSERVER(InputDeviceEventObserver, observers_,
+ OnTouchscreenDeviceConfigurationChanged());
+}
+
+void DeviceDataManager::NotifyObserversKeyboardDeviceConfigurationChanged() {
+ FOR_EACH_OBSERVER(InputDeviceEventObserver, observers_,
+ OnKeyboardDeviceConfigurationChanged());
+}
+
+void DeviceDataManager::NotifyObserversMouseDeviceConfigurationChanged() {
+ FOR_EACH_OBSERVER(InputDeviceEventObserver, observers_,
+ OnMouseDeviceConfigurationChanged());
+}
+
+void DeviceDataManager::NotifyObserversTouchpadDeviceConfigurationChanged() {
+ FOR_EACH_OBSERVER(InputDeviceEventObserver, observers_,
+ OnTouchpadDeviceConfigurationChanged());
+}
+
+void DeviceDataManager::NotifyObserversDeviceListsComplete() {
FOR_EACH_OBSERVER(InputDeviceEventObserver, observers_,
OnDeviceListsComplete());
- }
}
sadrul 2015/07/10 17:35:48 This can possibly be templatized. Not sure if that
bruthig 2015/07/10 20:04:58 Done.
void DeviceDataManager::AddObserver(InputDeviceEventObserver* observer) {

Powered by Google App Engine
This is Rietveld 408576698