Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(88)

Side by Side Diff: base/power_monitor/power_monitor_source.h

Issue 17074009: Created multi-process-friendly PowerMonitor interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Windows fixes, Power messages posted to main GPU thread now Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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;
38 friend class PowerMonitorTest;
39
40 // Friend function that is allowed to access the protected ProcessPowerEvent.
41 friend void ProcessPowerEventHelper(PowerEvent);
42
43 void ProcessPowerEvent(PowerEvent event_id);
44 // Platform-specific method to check whether the system is currently
45 // running on battery power. Returns true if running on batteries,
46 // false otherwise.
47 virtual bool IsBatteryPower();
48
49 bool battery_in_use_;
50 bool suspended_;
51
52 DISALLOW_COPY_AND_ASSIGN(PowerMonitorSource);
53 };
54
55 } // namespace base
56
57 #endif // BASE_POWER_MONITOR_POWER_MONITOR_SOURCE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698