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

Unified Diff: content/browser/power_monitor_message_broadcaster.cc

Issue 401083002: Initialize PowerMonitor on_power_battery intitial value for newly created processes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Typo Created 6 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/power_monitor_message_broadcaster.cc
diff --git a/content/browser/power_monitor_message_broadcaster.cc b/content/browser/power_monitor_message_broadcaster.cc
index 23de161b05c7225af72b1efb3dcd45c8545c879f..e862abbfe74be316fddce4b8adcfc0761d24b422 100644
--- a/content/browser/power_monitor_message_broadcaster.cc
+++ b/content/browser/power_monitor_message_broadcaster.cc
@@ -24,6 +24,13 @@ PowerMonitorMessageBroadcaster::~PowerMonitorMessageBroadcaster() {
power_monitor->RemoveObserver(this);
}
+void PowerMonitorMessageBroadcaster::Init() {
+ base::PowerMonitor* power_monitor = base::PowerMonitor::Get();
+ // Unit tests does not initialize the PowerMonitor.
+ if (power_monitor)
+ OnPowerStateChange(power_monitor->IsOnBatteryPower());
+}
+
void PowerMonitorMessageBroadcaster::OnPowerStateChange(bool on_battery_power) {
sender_->Send(new PowerMonitorMsg_PowerStateChange(on_battery_power));
}
« no previous file with comments | « content/browser/power_monitor_message_broadcaster.h ('k') | content/browser/power_monitor_message_broadcaster_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698