OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef BASE_POWER_MONITOR_POWER_MONITOR_SOURCE_H_ | |
6 #define BASE_POWER_MONITOR_POWER_MONITOR_SOURCE_H_ | |
7 | |
8 #include "base/base_export.h" | |
9 #include "base/basictypes.h" | |
10 #include "base/memory/ref_counted.h" | |
11 #include "base/observer_list_threadsafe.h" | |
12 | |
13 namespace base { | |
14 | |
15 class PowerMonitor; | |
16 | |
17 // Communicates power state changes to the power monitor. | |
18 class BASE_EXPORT PowerMonitorSource { | |
19 public: | |
20 PowerMonitorSource(); | |
21 virtual ~PowerMonitorSource(); | |
22 | |
23 // Normalized list of power events. | |
24 enum PowerEvent { | |
25 POWER_STATE_EVENT, // The Power status of the system has changed. | |
26 SUSPEND_EVENT, // The system is being suspended. | |
27 RESUME_EVENT // The system is being resumed. | |
28 }; | |
29 | |
30 // Is the computer currently on battery power. Can be called on any thread. | |
31 bool BatteryPower() const { | |
32 // Using a lock here is not necessary for just a bool. | |
33 return battery_in_use_; | |
34 } | |
35 | |
36 protected: | |
37 friend class PowerMonitor; | |
vandebo (ex-Chrome)
2013/07/02 22:53:12
What is this friend statement needed for?
bajones
2013/07/03 20:32:27
Old code. Deleted.
| |
38 | |
39 // Friend function that is allowed to access the protected ProcessPowerEvent. | |
40 friend void ProcessPowerEventHelper(PowerEvent); | |
41 | |
42 void ProcessPowerEvent(PowerEvent event_id); | |
43 // Platform-specific method to check whether the system is currently | |
44 // running on battery power. Returns true if running on batteries, | |
45 // false otherwise. | |
46 virtual bool IsBatteryPower(); | |
47 | |
48 bool battery_in_use_; | |
49 bool suspended_; | |
50 | |
51 DISALLOW_COPY_AND_ASSIGN(PowerMonitorSource); | |
52 }; | |
53 | |
54 } // namespace base | |
55 | |
56 #endif // BASE_POWER_MONITOR_POWER_MONITOR_SOURCE_H_ | |
OLD | NEW |