| 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) {
|
|
|