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

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: Added Touchscreen.TouchEventsEnabled histogram to public histograms.xml. Created 5 years, 6 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 44ca1fa7beccc0cef3c4beb8c83f7e5b9802aeb4..7aea4e1004ca03a67ccafe64c2b37ba6523e959f 100644
--- a/ui/events/devices/device_data_manager.cc
+++ b/ui/events/devices/device_data_manager.cc
@@ -25,29 +25,35 @@ bool InputDeviceEquals(const ui::InputDevice& a, const ui::InputDevice& b) {
DeviceDataManager* DeviceDataManager::instance_ = NULL;
DeviceDataManager::DeviceDataManager() {
- CHECK(!instance_) << "Can not create multiple instances of DeviceDataManager";
- instance_ = this;
-
- base::AtExitManager::RegisterTask(
- base::Bind(&base::DeletePointer<DeviceDataManager>, this));
-
ClearTouchDeviceAssociations();
}
DeviceDataManager::~DeviceDataManager() {
- CHECK_EQ(this, instance_);
- instance_ = NULL;
}
// static
DeviceDataManager* DeviceDataManager::instance() { return instance_; }
+void DeviceDataManager::set_instance(DeviceDataManager* instance) {
+ instance_ = instance;
+}
+
// static
void DeviceDataManager::CreateInstance() {
if (instance())
return;
- new DeviceDataManager();
+ CHECK(!instance_) << "Can not create multiple instances of DeviceDataManager";
+ instance_ = new DeviceDataManager();
+
+ base::AtExitManager::RegisterTask(base::Bind(DeleteInstance));
+}
+
+void DeviceDataManager::DeleteInstance() {
+ if (instance_) {
+ delete instance_;
+ instance_ = NULL;
+ }
}
// static
@@ -126,9 +132,7 @@ void DeviceDataManager::OnTouchscreenDevicesUpdated(
return;
}
touchscreen_devices_ = devices;
- FOR_EACH_OBSERVER(InputDeviceEventObserver,
- observers_,
- OnTouchscreenDeviceConfigurationChanged());
+ NotifyObserversTouchscreenDeviceConfigurationChanged();
}
void DeviceDataManager::OnKeyboardDevicesUpdated(
@@ -141,9 +145,7 @@ void DeviceDataManager::OnKeyboardDevicesUpdated(
return;
}
keyboard_devices_ = devices;
- FOR_EACH_OBSERVER(InputDeviceEventObserver,
- observers_,
- OnKeyboardDeviceConfigurationChanged());
+ NotifyObserversKeyboardDeviceConfigurationChanged();
}
void DeviceDataManager::OnMouseDevicesUpdated(
@@ -156,9 +158,7 @@ void DeviceDataManager::OnMouseDevicesUpdated(
return;
}
mouse_devices_ = devices;
- FOR_EACH_OBSERVER(InputDeviceEventObserver,
- observers_,
- OnMouseDeviceConfigurationChanged());
+ NotifyObserversMouseDeviceConfigurationChanged();
}
void DeviceDataManager::OnTouchpadDevicesUpdated(
@@ -171,17 +171,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());
- }
}
void DeviceDataManager::AddObserver(InputDeviceEventObserver* observer) {

Powered by Google App Engine
This is Rietveld 408576698