Chromium Code Reviews| 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> |
| 11 | 11 |
| 12 #include "base/base_export.h" | 12 #include "base/base_export.h" |
| 13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
| 14 #include "base/file_path.h" | 14 #include "base/file_path.h" |
| 15 #include "base/string16.h" | 15 #include "base/string16.h" |
| 16 #include "base/synchronization/lock.h" | |
| 16 #include "build/build_config.h" | 17 #include "build/build_config.h" |
| 17 | 18 |
| 18 // Windows HiRes timers drain the battery faster so we need to know the battery | 19 // Windows HiRes timers drain the battery faster so we need to know the battery |
| 19 // status. This isn't true for other platforms. | 20 // status. This isn't true for other platforms. |
| 20 #if defined(OS_WIN) | 21 #if defined(OS_WIN) |
| 21 #define ENABLE_BATTERY_MONITORING 1 | 22 #define ENABLE_BATTERY_MONITORING 1 |
| 22 #else | 23 #else |
| 23 #undef ENABLE_BATTERY_MONITORING | 24 #undef ENABLE_BATTERY_MONITORING |
| 24 #endif // !OS_WIN | 25 #endif // !OS_WIN |
| 25 | 26 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 97 // Returns information for attached removable storage. | 98 // Returns information for attached removable storage. |
| 98 std::vector<RemovableStorageInfo> GetAttachedRemovableStorage() const; | 99 std::vector<RemovableStorageInfo> GetAttachedRemovableStorage() const; |
| 99 | 100 |
| 100 // | 101 // |
| 101 // Power-related APIs | 102 // Power-related APIs |
| 102 // | 103 // |
| 103 | 104 |
| 104 // Is the computer currently on battery power. | 105 // Is the computer currently on battery power. |
| 105 // Can be called on any thread. | 106 // Can be called on any thread. |
| 106 bool BatteryPower() const { | 107 bool BatteryPower() const { |
| 107 // Using a lock here is not necessary for just a bool. | 108 // Using a lock here is not necessary for just a bool. |
|
Philippe
2012/12/14 13:53:03
This is wrong on ARM multi cores.
vandebo (ex-Chrome)
2013/01/04 19:46:54
Feel free to fix.
| |
| 108 return battery_in_use_; | 109 return battery_in_use_; |
| 109 } | 110 } |
| 110 | 111 |
| 111 // Callbacks will be called on the thread which creates the SystemMonitor. | 112 // Callbacks will be called on the thread which creates the SystemMonitor. |
| 112 // During the callback, Add/RemoveObserver will block until the callbacks | 113 // During the callback, Add/RemoveObserver will block until the callbacks |
| 113 // are finished. Observers should implement quick callback functions; if | 114 // are finished. Observers should implement quick callback functions; if |
| 114 // lengthy operations are needed, the observer should take care to invoke | 115 // lengthy operations are needed, the observer should take care to invoke |
| 115 // the operation on an appropriate thread. | 116 // the operation on an appropriate thread. |
| 116 class BASE_EXPORT PowerObserver { | 117 class BASE_EXPORT PowerObserver { |
| 117 public: | 118 public: |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 212 | 213 |
| 213 #if defined(ENABLE_BATTERY_MONITORING) | 214 #if defined(ENABLE_BATTERY_MONITORING) |
| 214 base::OneShotTimer<SystemMonitor> delayed_battery_check_; | 215 base::OneShotTimer<SystemMonitor> delayed_battery_check_; |
| 215 #endif | 216 #endif |
| 216 | 217 |
| 217 #if defined(OS_IOS) | 218 #if defined(OS_IOS) |
| 218 // Holds pointers to system event notification observers. | 219 // Holds pointers to system event notification observers. |
| 219 std::vector<id> notification_observers_; | 220 std::vector<id> notification_observers_; |
| 220 #endif | 221 #endif |
| 221 | 222 |
| 223 // For manipulating removable_storage_map_ structure. | |
| 224 mutable base::Lock removable_storage_lock_; | |
| 222 // Map of all the attached removable storage devices. | 225 // Map of all the attached removable storage devices. |
| 223 RemovableStorageMap removable_storage_map_; | 226 RemovableStorageMap removable_storage_map_; |
| 224 | 227 |
| 225 DISALLOW_COPY_AND_ASSIGN(SystemMonitor); | 228 DISALLOW_COPY_AND_ASSIGN(SystemMonitor); |
| 226 }; | 229 }; |
| 227 | 230 |
| 228 } // namespace base | 231 } // namespace base |
| 229 | 232 |
| 230 #endif // BASE_SYSTEM_MONITOR_SYSTEM_MONITOR_H_ | 233 #endif // BASE_SYSTEM_MONITOR_SYSTEM_MONITOR_H_ |
| OLD | NEW |