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

Unified Diff: base/power_monitor/power_monitor.h

Issue 179923006: Attempting to resolve a race condition with PowerMonitor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | base/power_monitor/power_monitor.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/power_monitor/power_monitor.h
diff --git a/base/power_monitor/power_monitor.h b/base/power_monitor/power_monitor.h
index 4acb3bf122dba93633a1201631063810ef3e9d5d..d00b7211398e207bbaeaa4a0299fdfe2d1d261cd 100644
--- a/base/power_monitor/power_monitor.h
+++ b/base/power_monitor/power_monitor.h
@@ -19,27 +19,31 @@ class PowerMonitorSource;
// the change event.
class BASE_EXPORT PowerMonitor {
public:
- // Takes ownership of |source|.
- explicit PowerMonitor(scoped_ptr<PowerMonitorSource> source);
+ static PowerMonitor* Create(scoped_ptr<PowerMonitorSource> source);
Ken Russell (switch to Gerrit) 2014/02/28 02:02:42 I find the pattern here confusing where PowerMonit
jam 2014/02/28 17:05:18 +1
~PowerMonitor();
// Get the process-wide PowerMonitor (if not present, returns NULL).
static PowerMonitor* Get();
- // Add and remove an observer.
- // Can be called from any thread.
- // Must not be called from within a notification callback.
- void AddObserver(PowerObserver* observer);
- void RemoveObserver(PowerObserver* observer);
+ static bool AddObserverThreadSafe(PowerObserver* observer);
+ static bool RemoveObserverThreadSafe(PowerObserver* observer);
// Is the computer currently on battery power.
bool IsOnBatteryPower();
private:
+ // Takes ownership of |source|.
+ explicit PowerMonitor(scoped_ptr<PowerMonitorSource> source);
friend class PowerMonitorSource;
PowerMonitorSource* Source();
+ // Add and remove an observer.
+ // Can be called from any thread.
+ // Must not be called from within a notification callback.
+ void AddObserver(PowerObserver* observer);
+ void RemoveObserver(PowerObserver* observer);
+
void NotifyPowerStateChange(bool battery_in_use);
void NotifySuspend();
void NotifyResume();
« no previous file with comments | « no previous file | base/power_monitor/power_monitor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698