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 // Start the System Monitor within a process. This method | 23 // To start the System Monitor within an application |
24 // is provided so that the battery check can be deferred. | 24 // use this call. |
25 // The MessageLoop must be started before calling this | |
26 // method. | |
27 static void Start(); | 25 static void Start(); |
28 | 26 |
29 // | 27 // |
30 // Power-related APIs | 28 // Power-related APIs |
31 // | 29 // |
32 | 30 |
33 // Is the computer currently on battery power. | 31 // Is the computer currently on battery power. |
34 // Can be called on any thread. | 32 // Can be called on any thread. |
35 bool BatteryPower() { | 33 bool BatteryPower() { |
36 // Using a lock here is not necessary for just a bool. | 34 // Using a lock here is not necessary for just a bool. |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 | 105 |
108 base::OneShotTimer<SystemMonitor> delayed_battery_check_; | 106 base::OneShotTimer<SystemMonitor> delayed_battery_check_; |
109 | 107 |
110 DISALLOW_COPY_AND_ASSIGN(SystemMonitor); | 108 DISALLOW_COPY_AND_ASSIGN(SystemMonitor); |
111 }; | 109 }; |
112 | 110 |
113 } | 111 } |
114 | 112 |
115 #endif // BASE_SYSTEM_MONITOR_H_ | 113 #endif // BASE_SYSTEM_MONITOR_H_ |
116 | 114 |
OLD | NEW |