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

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: Uber-refactor Created 7 years, 6 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.
vandebo (ex-Chrome) 2013/06/26 21:40:33 nit: comment indent; and below.
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 void ProcessPowerEvent(PowerEvent event_id);
vandebo (ex-Chrome) 2013/06/26 21:40:33 Since PowerMonitor::Source() is public, this has t
bajones 2013/06/26 22:37:22 I'm happy to do this, but I'd like to understand w
vandebo (ex-Chrome) 2013/06/26 22:50:12 One bug/flaw in previous versions of SystemMonitr/
37
38 protected:
39 friend class PowerMonitor;
40
41 void SetMonitor(PowerMonitor* monitor);
vandebo (ex-Chrome) 2013/06/26 21:40:33 Do you need this method, or can it just use PowerM
42
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 PowerMonitor* monitor_;
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