OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef BASE_SYSTEM_MONITOR_SYSTEM_MONITOR_H_ | 5 #ifndef BASE_SYSTEM_MONITOR_SYSTEM_MONITOR_H_ |
6 #define BASE_SYSTEM_MONITOR_SYSTEM_MONITOR_H_ | 6 #define BASE_SYSTEM_MONITOR_SYSTEM_MONITOR_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 // This is only implemented on Windows currently. | 149 // This is only implemented on Windows currently. |
150 virtual void OnDevicesChanged(DeviceType device_type) {} | 150 virtual void OnDevicesChanged(DeviceType device_type) {} |
151 | 151 |
152 // When a media device is attached or detached, one of these two events | 152 // When a media device is attached or detached, one of these two events |
153 // is triggered. | 153 // is triggered. |
154 virtual void OnMediaDeviceAttached(const std::string& id, | 154 virtual void OnMediaDeviceAttached(const std::string& id, |
155 const string16& name, | 155 const string16& name, |
156 MediaDeviceType type, | 156 MediaDeviceType type, |
157 const FilePath::StringType& location) {} | 157 const FilePath::StringType& location) {} |
158 | 158 |
159 virtual void OnMediaDeviceDetached(const std::string& id) {} | 159 virtual void OnMediaDeviceDetached(const std::string& id, |
| 160 const FilePath::StringType& location) {} |
160 | 161 |
161 protected: | 162 protected: |
162 virtual ~DevicesChangedObserver() {} | 163 virtual ~DevicesChangedObserver() {} |
163 }; | 164 }; |
164 | 165 |
165 // Add a new observer. | 166 // Add a new observer. |
166 // Can be called from any thread. | 167 // Can be called from any thread. |
167 // Must not be called from within a notification callback. | 168 // Must not be called from within a notification callback. |
168 void AddPowerObserver(PowerObserver* obs); | 169 void AddPowerObserver(PowerObserver* obs); |
169 void AddDevicesChangedObserver(DevicesChangedObserver* obs); | 170 void AddDevicesChangedObserver(DevicesChangedObserver* obs); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 | 209 |
209 // Checks the battery status and notifies observers if the battery | 210 // Checks the battery status and notifies observers if the battery |
210 // status has changed. | 211 // status has changed. |
211 void BatteryCheck(); | 212 void BatteryCheck(); |
212 | 213 |
213 // Functions to trigger notifications. | 214 // Functions to trigger notifications. |
214 void NotifyDevicesChanged(DeviceType device_type); | 215 void NotifyDevicesChanged(DeviceType device_type); |
215 void NotifyMediaDeviceAttached(const std::string& id, | 216 void NotifyMediaDeviceAttached(const std::string& id, |
216 const string16& name, | 217 const string16& name, |
217 MediaDeviceType type, | 218 MediaDeviceType type, |
218 const FilePath::StringType& data); | 219 const FilePath::StringType& location); |
219 void NotifyMediaDeviceDetached(const std::string& id); | 220 void NotifyMediaDeviceDetached(const std::string& id, |
| 221 const FilePath::StringType& location); |
220 void NotifyPowerStateChange(); | 222 void NotifyPowerStateChange(); |
221 void NotifySuspend(); | 223 void NotifySuspend(); |
222 void NotifyResume(); | 224 void NotifyResume(); |
223 | 225 |
224 scoped_refptr<ObserverListThreadSafe<PowerObserver> > power_observer_list_; | 226 scoped_refptr<ObserverListThreadSafe<PowerObserver> > power_observer_list_; |
225 scoped_refptr<ObserverListThreadSafe<DevicesChangedObserver> > | 227 scoped_refptr<ObserverListThreadSafe<DevicesChangedObserver> > |
226 devices_changed_observer_list_; | 228 devices_changed_observer_list_; |
227 bool battery_in_use_; | 229 bool battery_in_use_; |
228 bool suspended_; | 230 bool suspended_; |
229 | 231 |
230 #if defined(ENABLE_BATTERY_MONITORING) | 232 #if defined(ENABLE_BATTERY_MONITORING) |
231 base::OneShotTimer<SystemMonitor> delayed_battery_check_; | 233 base::OneShotTimer<SystemMonitor> delayed_battery_check_; |
232 #endif | 234 #endif |
233 | 235 |
234 #if defined(OS_IOS) | 236 #if defined(OS_IOS) |
235 // Holds pointers to system event notification observers. | 237 // Holds pointers to system event notification observers. |
236 std::vector<id> notification_observers_; | 238 std::vector<id> notification_observers_; |
237 #endif | 239 #endif |
238 | 240 |
239 // Map of all the attached media devices. | 241 // Map of all the attached media devices. |
240 MediaDeviceMap media_device_map_; | 242 MediaDeviceMap media_device_map_; |
241 | 243 |
242 DISALLOW_COPY_AND_ASSIGN(SystemMonitor); | 244 DISALLOW_COPY_AND_ASSIGN(SystemMonitor); |
243 }; | 245 }; |
244 | 246 |
245 } // namespace base | 247 } // namespace base |
246 | 248 |
247 #endif // BASE_SYSTEM_MONITOR_SYSTEM_MONITOR_H_ | 249 #endif // BASE_SYSTEM_MONITOR_SYSTEM_MONITOR_H_ |
OLD | NEW |