OLD | NEW |
1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2008 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_H_ | 5 #ifndef BASE_SYSTEM_MONITOR_H_ |
6 #define BASE_SYSTEM_MONITOR_H_ | 6 #define BASE_SYSTEM_MONITOR_H_ |
7 | 7 |
8 #include "base/observer_list_threadsafe.h" | 8 #include "base/observer_list_threadsafe.h" |
9 #include "base/singleton.h" | 9 #include "base/singleton.h" |
10 | 10 |
11 namespace base { | 11 namespace base { |
12 | 12 |
13 // Class for monitoring various system-related subsystems | 13 // Class for monitoring various system-related subsystems |
14 // such as power management, network status, etc. | 14 // such as power management, network status, etc. |
15 // TODO(mbelshe): Add support beyond just power management. | 15 // TODO(mbelshe): Add support beyond just power management. |
16 class SystemMonitor { | 16 class SystemMonitor { |
17 public: | 17 public: |
18 // Access to the Singleton | 18 // Access to the Singleton |
19 static SystemMonitor* Get() { | 19 static SystemMonitor* Get() { |
20 return Singleton<SystemMonitor>::get(); | 20 return Singleton<SystemMonitor>::get(); |
21 } | 21 } |
22 | 22 |
23 // To start the System Monitor within an application | 23 // Start the System Monitor within a process. This method |
24 // use this call. | 24 // is provided so tht the battery check can be deferred. |
| 25 // The MessageLoop must be started before calling this |
| 26 // method. |
25 static void Start(); | 27 static void Start(); |
26 | 28 |
27 // | 29 // |
28 // Power-related APIs | 30 // Power-related APIs |
29 // | 31 // |
30 | 32 |
31 // Is the computer currently on battery power. | 33 // Is the computer currently on battery power. |
32 // Can be called on any thread. | 34 // Can be called on any thread. |
33 bool BatteryPower() { | 35 bool BatteryPower() { |
34 // Using a lock here is not necessary for just a bool. | 36 // Using a lock here is not necessary for just a bool. |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 | 107 |
106 base::OneShotTimer<SystemMonitor> delayed_battery_check_; | 108 base::OneShotTimer<SystemMonitor> delayed_battery_check_; |
107 | 109 |
108 DISALLOW_COPY_AND_ASSIGN(SystemMonitor); | 110 DISALLOW_COPY_AND_ASSIGN(SystemMonitor); |
109 }; | 111 }; |
110 | 112 |
111 } | 113 } |
112 | 114 |
113 #endif // BASE_SYSTEM_MONITOR_H_ | 115 #endif // BASE_SYSTEM_MONITOR_H_ |
114 | 116 |
OLD | NEW |