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

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 logging.h include to device_data_manager_test_api_stub.cc. 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
« no previous file with comments | « ui/events/devices/device_data_manager.h ('k') | ui/events/devices/x11/device_data_manager_x11.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..8df3f37d0c42e650186c9e1023532b6eefeda2e4 100644
--- a/ui/events/devices/device_data_manager.cc
+++ b/ui/events/devices/device_data_manager.cc
@@ -11,6 +11,13 @@
#include "ui/gfx/display.h"
#include "ui/gfx/geometry/point3_f.h"
+// This macro provides the implementation for the observer notification methods.
+#define NOTIFY_OBSERVERS(method_name, observer_method) \
+ void DeviceDataManager::method_name() { \
+ FOR_EACH_OBSERVER(InputDeviceEventObserver, observers_, \
+ observer_method()); \
+ }
+
namespace ui {
namespace {
@@ -35,7 +42,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)
+ << "Must reset the DeviceDataManager using DeleteInstance().";
+ DCHECK(!instance_) "Can not set multiple instances of DeviceDataManager.";
instance_ = instance;
}
@@ -46,6 +55,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 +142,7 @@ void DeviceDataManager::OnTouchscreenDevicesUpdated(
return;
}
touchscreen_devices_ = devices;
- FOR_EACH_OBSERVER(InputDeviceEventObserver,
- observers_,
- OnTouchscreenDeviceConfigurationChanged());
+ NotifyObserversTouchscreenDeviceConfigurationChanged();
}
void DeviceDataManager::OnKeyboardDevicesUpdated(
@@ -147,9 +155,7 @@ void DeviceDataManager::OnKeyboardDevicesUpdated(
return;
}
keyboard_devices_ = devices;
- FOR_EACH_OBSERVER(InputDeviceEventObserver,
- observers_,
- OnKeyboardDeviceConfigurationChanged());
+ NotifyObserversKeyboardDeviceConfigurationChanged();
}
void DeviceDataManager::OnMouseDevicesUpdated(
@@ -162,9 +168,7 @@ void DeviceDataManager::OnMouseDevicesUpdated(
return;
}
mouse_devices_ = devices;
- FOR_EACH_OBSERVER(InputDeviceEventObserver,
- observers_,
- OnMouseDeviceConfigurationChanged());
+ NotifyObserversMouseDeviceConfigurationChanged();
}
void DeviceDataManager::OnTouchpadDevicesUpdated(
@@ -177,19 +181,30 @@ 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;
- FOR_EACH_OBSERVER(InputDeviceEventObserver, observers_,
- OnDeviceListsComplete());
+ NotifyObserversDeviceListsComplete();
}
}
+NOTIFY_OBSERVERS(NotifyObserversTouchscreenDeviceConfigurationChanged,
+ OnTouchscreenDeviceConfigurationChanged);
+
+NOTIFY_OBSERVERS(NotifyObserversKeyboardDeviceConfigurationChanged,
+ OnKeyboardDeviceConfigurationChanged);
+
+NOTIFY_OBSERVERS(NotifyObserversMouseDeviceConfigurationChanged,
+ OnMouseDeviceConfigurationChanged);
+
+NOTIFY_OBSERVERS(NotifyObserversTouchpadDeviceConfigurationChanged,
+ OnTouchpadDeviceConfigurationChanged);
+
+NOTIFY_OBSERVERS(NotifyObserversDeviceListsComplete, OnDeviceListsComplete);
+
void DeviceDataManager::AddObserver(InputDeviceEventObserver* observer) {
observers_.AddObserver(observer);
}
« no previous file with comments | « ui/events/devices/device_data_manager.h ('k') | ui/events/devices/x11/device_data_manager_x11.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698