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

Unified Diff: base/power_monitor/power_monitor_source.cc

Issue 179923006: Attempting to resolve a race condition with PowerMonitor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Win64 fixes Created 6 years, 9 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 | « base/power_monitor/power_monitor_source.h ('k') | base/power_monitor/power_monitor_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/power_monitor/power_monitor_source.cc
diff --git a/base/power_monitor/power_monitor_source.cc b/base/power_monitor/power_monitor_source.cc
index 6868cb19e338e17b7d5c960b606b8f22845893da..33f3d23d9a295244fc08160b84c2a61aaa01c08f 100644
--- a/base/power_monitor/power_monitor_source.cc
+++ b/base/power_monitor/power_monitor_source.cc
@@ -22,11 +22,11 @@ bool PowerMonitorSource::IsOnBatteryPower() {
}
void PowerMonitorSource::ProcessPowerEvent(PowerEvent event_id) {
- PowerMonitor* monitor = PowerMonitor::Get();
- if (!monitor)
+ AutoLock lock(*PowerMonitor::GetLock());
+ if (!PowerMonitor::IsInitializedLocked())
return;
- PowerMonitorSource* source = monitor->Source();
+ PowerMonitorSource* source = PowerMonitor::GetSource();
// Suppress duplicate notifications. Some platforms may
// send multiple notifications of the same event.
@@ -45,19 +45,19 @@ void PowerMonitorSource::ProcessPowerEvent(PowerEvent event_id) {
}
if (changed)
- monitor->NotifyPowerStateChange(new_on_battery_power);
+ PowerMonitor::NotifyPowerStateChange(new_on_battery_power);
}
break;
case RESUME_EVENT:
if (source->suspended_) {
source->suspended_ = false;
- monitor->NotifyResume();
+ PowerMonitor::NotifyResume();
}
break;
case SUSPEND_EVENT:
if (!source->suspended_) {
source->suspended_ = true;
- monitor->NotifySuspend();
+ PowerMonitor::NotifySuspend();
}
break;
}
« no previous file with comments | « base/power_monitor/power_monitor_source.h ('k') | base/power_monitor/power_monitor_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698