| 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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 // This is only implemented on Windows currently. | 142 // This is only implemented on Windows currently. |
| 143 virtual void OnDevicesChanged() {} | 143 virtual void OnDevicesChanged() {} |
| 144 | 144 |
| 145 // When a media device is attached or detached, one of these two events | 145 // When a media device is attached or detached, one of these two events |
| 146 // is triggered. | 146 // is triggered. |
| 147 virtual void OnMediaDeviceAttached(const std::string& id, | 147 virtual void OnMediaDeviceAttached(const std::string& id, |
| 148 const string16& name, | 148 const string16& name, |
| 149 MediaDeviceType type, | 149 MediaDeviceType type, |
| 150 const FilePath::StringType& location) {} | 150 const FilePath::StringType& location) {} |
| 151 | 151 |
| 152 virtual void OnMediaDeviceDetached(const std::string& id) {} | 152 virtual void OnMediaDeviceDetached(const std::string& id, |
| 153 const FilePath::StringType& location) {} |
| 153 | 154 |
| 154 protected: | 155 protected: |
| 155 virtual ~DevicesChangedObserver() {} | 156 virtual ~DevicesChangedObserver() {} |
| 156 }; | 157 }; |
| 157 | 158 |
| 158 // Add a new observer. | 159 // Add a new observer. |
| 159 // Can be called from any thread. | 160 // Can be called from any thread. |
| 160 // Must not be called from within a notification callback. | 161 // Must not be called from within a notification callback. |
| 161 void AddPowerObserver(PowerObserver* obs); | 162 void AddPowerObserver(PowerObserver* obs); |
| 162 void AddDevicesChangedObserver(DevicesChangedObserver* obs); | 163 void AddDevicesChangedObserver(DevicesChangedObserver* obs); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 | 202 |
| 202 // Checks the battery status and notifies observers if the battery | 203 // Checks the battery status and notifies observers if the battery |
| 203 // status has changed. | 204 // status has changed. |
| 204 void BatteryCheck(); | 205 void BatteryCheck(); |
| 205 | 206 |
| 206 // Functions to trigger notifications. | 207 // Functions to trigger notifications. |
| 207 void NotifyDevicesChanged(); | 208 void NotifyDevicesChanged(); |
| 208 void NotifyMediaDeviceAttached(const std::string& id, | 209 void NotifyMediaDeviceAttached(const std::string& id, |
| 209 const string16& name, | 210 const string16& name, |
| 210 MediaDeviceType type, | 211 MediaDeviceType type, |
| 211 const FilePath::StringType& data); | 212 const FilePath::StringType& location); |
| 212 void NotifyMediaDeviceDetached(const std::string& id); | 213 void NotifyMediaDeviceDetached(const std::string& id, |
| 214 const FilePath::StringType& location); |
| 213 void NotifyPowerStateChange(); | 215 void NotifyPowerStateChange(); |
| 214 void NotifySuspend(); | 216 void NotifySuspend(); |
| 215 void NotifyResume(); | 217 void NotifyResume(); |
| 216 | 218 |
| 217 scoped_refptr<ObserverListThreadSafe<PowerObserver> > power_observer_list_; | 219 scoped_refptr<ObserverListThreadSafe<PowerObserver> > power_observer_list_; |
| 218 scoped_refptr<ObserverListThreadSafe<DevicesChangedObserver> > | 220 scoped_refptr<ObserverListThreadSafe<DevicesChangedObserver> > |
| 219 devices_changed_observer_list_; | 221 devices_changed_observer_list_; |
| 220 bool battery_in_use_; | 222 bool battery_in_use_; |
| 221 bool suspended_; | 223 bool suspended_; |
| 222 | 224 |
| 223 #if defined(ENABLE_BATTERY_MONITORING) | 225 #if defined(ENABLE_BATTERY_MONITORING) |
| 224 base::OneShotTimer<SystemMonitor> delayed_battery_check_; | 226 base::OneShotTimer<SystemMonitor> delayed_battery_check_; |
| 225 #endif | 227 #endif |
| 226 | 228 |
| 227 #if defined(OS_IOS) | 229 #if defined(OS_IOS) |
| 228 // Holds pointers to system event notification observers. | 230 // Holds pointers to system event notification observers. |
| 229 std::vector<id> notification_observers_; | 231 std::vector<id> notification_observers_; |
| 230 #endif | 232 #endif |
| 231 | 233 |
| 232 // Map of all the attached media devices. | 234 // Map of all the attached media devices. |
| 233 MediaDeviceMap media_device_map_; | 235 MediaDeviceMap media_device_map_; |
| 234 | 236 |
| 235 DISALLOW_COPY_AND_ASSIGN(SystemMonitor); | 237 DISALLOW_COPY_AND_ASSIGN(SystemMonitor); |
| 236 }; | 238 }; |
| 237 | 239 |
| 238 } // namespace base | 240 } // namespace base |
| 239 | 241 |
| 240 #endif // BASE_SYSTEM_MONITOR_SYSTEM_MONITOR_H_ | 242 #endif // BASE_SYSTEM_MONITOR_SYSTEM_MONITOR_H_ |
| OLD | NEW |