OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ui/events/devices/device_data_manager.h" | 5 #include "ui/events/devices/device_data_manager.h" |
6 | 6 |
7 #include "base/at_exit.h" | 7 #include "base/at_exit.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "ui/events/devices/input_device_event_observer.h" | 10 #include "ui/events/devices/input_device_event_observer.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 | 21 |
22 } // namespace | 22 } // namespace |
23 | 23 |
24 // static | 24 // static |
25 DeviceDataManager* DeviceDataManager::instance_ = NULL; | 25 DeviceDataManager* DeviceDataManager::instance_ = NULL; |
26 | 26 |
27 DeviceDataManager::DeviceDataManager() { | 27 DeviceDataManager::DeviceDataManager() { |
28 CHECK(!instance_) << "Can not create multiple instances of DeviceDataManager"; | 28 CHECK(!instance_) << "Can not create multiple instances of DeviceDataManager"; |
29 instance_ = this; | 29 instance_ = this; |
30 | 30 |
| 31 scoped_ptr<DeviceDataManager> owned_instance(instance_); |
31 base::AtExitManager::RegisterTask( | 32 base::AtExitManager::RegisterTask( |
32 base::Bind(&base::DeletePointer<DeviceDataManager>, this)); | 33 base::Bind(&base::DeletePointer<DeviceDataManager>, |
| 34 base::Passed(&owned_instance))); |
33 | 35 |
34 ClearTouchDeviceAssociations(); | 36 ClearTouchDeviceAssociations(); |
35 } | 37 } |
36 | 38 |
37 DeviceDataManager::~DeviceDataManager() { | 39 DeviceDataManager::~DeviceDataManager() { |
38 CHECK_EQ(this, instance_); | 40 CHECK_EQ(this, instance_); |
39 instance_ = NULL; | 41 instance_ = NULL; |
40 } | 42 } |
41 | 43 |
42 // static | 44 // static |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 | 180 |
179 void DeviceDataManager::AddObserver(InputDeviceEventObserver* observer) { | 181 void DeviceDataManager::AddObserver(InputDeviceEventObserver* observer) { |
180 observers_.AddObserver(observer); | 182 observers_.AddObserver(observer); |
181 } | 183 } |
182 | 184 |
183 void DeviceDataManager::RemoveObserver(InputDeviceEventObserver* observer) { | 185 void DeviceDataManager::RemoveObserver(InputDeviceEventObserver* observer) { |
184 observers_.RemoveObserver(observer); | 186 observers_.RemoveObserver(observer); |
185 } | 187 } |
186 | 188 |
187 } // namespace ui | 189 } // namespace ui |
OLD | NEW |