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> |
| 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); |
| 104 #endif |
| 105 |
98 // Returns information for attached removable storage. | 106 // Returns information for attached removable storage. |
99 std::vector<RemovableStorageInfo> GetAttachedRemovableStorage() const; | 107 std::vector<RemovableStorageInfo> GetAttachedRemovableStorage() const; |
100 | 108 |
101 // | 109 // |
102 // Power-related APIs | 110 // Power-related APIs |
103 // | 111 // |
104 | 112 |
105 // Is the computer currently on battery power. | 113 // Is the computer currently on battery power. |
106 // Can be called on any thread. | 114 // Can be called on any thread. |
107 bool BatteryPower() const { | 115 bool BatteryPower() const { |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 mutable base::Lock removable_storage_lock_; | 236 mutable base::Lock removable_storage_lock_; |
229 // Map of all the attached removable storage devices. | 237 // Map of all the attached removable storage devices. |
230 RemovableStorageMap removable_storage_map_; | 238 RemovableStorageMap removable_storage_map_; |
231 | 239 |
232 DISALLOW_COPY_AND_ASSIGN(SystemMonitor); | 240 DISALLOW_COPY_AND_ASSIGN(SystemMonitor); |
233 }; | 241 }; |
234 | 242 |
235 } // namespace base | 243 } // namespace base |
236 | 244 |
237 #endif // BASE_SYSTEM_MONITOR_SYSTEM_MONITOR_H_ | 245 #endif // BASE_SYSTEM_MONITOR_SYSTEM_MONITOR_H_ |
OLD | NEW |