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> |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 31 | 31 |
| 32 #if defined(OS_MACOSX) && !defined(OS_IOS) | 32 #if defined(OS_MACOSX) && !defined(OS_IOS) |
| 33 #include <IOKit/pwr_mgt/IOPMLib.h> | 33 #include <IOKit/pwr_mgt/IOPMLib.h> |
| 34 #include <IOKit/IOMessage.h> | 34 #include <IOKit/IOMessage.h> |
| 35 #endif // OS_MACOSX && !OS_IOS | 35 #endif // OS_MACOSX && !OS_IOS |
| 36 | 36 |
| 37 #if defined(OS_IOS) | 37 #if defined(OS_IOS) |
| 38 #include <objc/runtime.h> | 38 #include <objc/runtime.h> |
| 39 #endif // OS_IOS | 39 #endif // OS_IOS |
| 40 | 40 |
| 41 #if defined(OS_ANDROID) | |
| 42 #include <jni.h> | |
|
vandebo (ex-Chrome)
2012/10/04 17:55:56
Can you declare instead of include?
bulach
2012/10/04 18:33:33
unfortunately not.. :( there are some nasty typede
| |
| 43 #endif | |
| 44 | |
| 41 namespace base { | 45 namespace base { |
| 42 | 46 |
| 43 // Class for monitoring various system-related subsystems | 47 // Class for monitoring various system-related subsystems |
| 44 // such as power management, network status, etc. | 48 // such as power management, network status, etc. |
| 45 // TODO(mbelshe): Add support beyond just power management. | 49 // TODO(mbelshe): Add support beyond just power management. |
| 46 class BASE_EXPORT SystemMonitor { | 50 class BASE_EXPORT SystemMonitor { |
| 47 public: | 51 public: |
| 48 // Normalized list of power events. | 52 // Normalized list of power events. |
| 49 enum PowerEvent { | 53 enum PowerEvent { |
| 50 POWER_STATE_EVENT, // The Power status of the system has changed. | 54 POWER_STATE_EVENT, // The Power status of the system has changed. |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 88 // | 92 // |
| 89 // This function must be called before instantiating an instance of the class | 93 // This function must be called before instantiating an instance of the class |
| 90 // and before the Sandbox is initialized. | 94 // and before the Sandbox is initialized. |
| 91 #if !defined(OS_IOS) | 95 #if !defined(OS_IOS) |
| 92 static void AllocateSystemIOPorts(); | 96 static void AllocateSystemIOPorts(); |
| 93 #else | 97 #else |
| 94 static void AllocateSystemIOPorts() {} | 98 static void AllocateSystemIOPorts() {} |
| 95 #endif // OS_IOS | 99 #endif // OS_IOS |
| 96 #endif // OS_MACOSX | 100 #endif // OS_MACOSX |
| 97 | 101 |
| 102 #if defined(OS_ANDROID) | |
| 103 static bool RegisterSystemMonitor(JNIEnv* env); | |
|
vandebo (ex-Chrome)
2012/10/04 17:55:56
I'm not familiar with how JNI is being used in Chr
bulach
2012/10/04 18:33:33
there's never a silly question, just poorly docume
vandebo (ex-Chrome)
2012/10/04 19:19:22
If it doesn't need to be a member of the class, th
| |
| 104 void SetBatteryIsCharging(bool is_battery_charging); | |
| 105 #endif | |
| 106 | |
| 98 // Returns information for attached removable storage. | 107 // Returns information for attached removable storage. |
| 99 std::vector<RemovableStorageInfo> GetAttachedRemovableStorage() const; | 108 std::vector<RemovableStorageInfo> GetAttachedRemovableStorage() const; |
| 100 | 109 |
| 101 // | 110 // |
| 102 // Power-related APIs | 111 // Power-related APIs |
| 103 // | 112 // |
| 104 | 113 |
| 105 // Is the computer currently on battery power. | 114 // Is the computer currently on battery power. |
| 106 // Can be called on any thread. | 115 // Can be called on any thread. |
| 107 bool BatteryPower() const { | 116 bool BatteryPower() const { |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 217 | 226 |
| 218 #if defined(ENABLE_BATTERY_MONITORING) | 227 #if defined(ENABLE_BATTERY_MONITORING) |
| 219 base::OneShotTimer<SystemMonitor> delayed_battery_check_; | 228 base::OneShotTimer<SystemMonitor> delayed_battery_check_; |
| 220 #endif | 229 #endif |
| 221 | 230 |
| 222 #if defined(OS_IOS) | 231 #if defined(OS_IOS) |
| 223 // Holds pointers to system event notification observers. | 232 // Holds pointers to system event notification observers. |
| 224 std::vector<id> notification_observers_; | 233 std::vector<id> notification_observers_; |
| 225 #endif | 234 #endif |
| 226 | 235 |
| 236 #if defined(OS_ANDROID) | |
| 237 // Holds the battery state from the java side. | |
| 238 bool is_battery_charging_; | |
|
Satish
2012/10/04 14:31:45
Good idea. This could also be used on windows so b
vandebo (ex-Chrome)
2012/10/04 17:55:56
But adding SetBatteryIsCharging exposes more of th
bulach
2012/10/04 18:33:33
this was all to avoid one extra JNI hop.. since th
| |
| 239 #endif | |
| 240 | |
| 227 // For manipulating removable_storage_map_ structure. | 241 // For manipulating removable_storage_map_ structure. |
| 228 mutable base::Lock removable_storage_lock_; | 242 mutable base::Lock removable_storage_lock_; |
| 229 // Map of all the attached removable storage devices. | 243 // Map of all the attached removable storage devices. |
| 230 RemovableStorageMap removable_storage_map_; | 244 RemovableStorageMap removable_storage_map_; |
| 231 | 245 |
| 232 DISALLOW_COPY_AND_ASSIGN(SystemMonitor); | 246 DISALLOW_COPY_AND_ASSIGN(SystemMonitor); |
| 233 }; | 247 }; |
| 234 | 248 |
| 235 } // namespace base | 249 } // namespace base |
| 236 | 250 |
| 237 #endif // BASE_SYSTEM_MONITOR_SYSTEM_MONITOR_H_ | 251 #endif // BASE_SYSTEM_MONITOR_SYSTEM_MONITOR_H_ |
| OLD | NEW |