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 82affddbdba85691cec0fcc02b2921766fdbda1c..23de161b05c7225af72b1efb3dcd45c8545c879f 100644 |
--- a/content/browser/power_monitor_message_broadcaster.cc |
+++ b/content/browser/power_monitor_message_broadcaster.cc |
@@ -13,11 +13,15 @@ |
PowerMonitorMessageBroadcaster::PowerMonitorMessageBroadcaster( |
IPC::Sender* sender) |
: sender_(sender) { |
- base::PowerMonitor::AddObserver(this); |
+ base::PowerMonitor* power_monitor = base::PowerMonitor::Get(); |
+ if (power_monitor) |
+ power_monitor->AddObserver(this); |
} |
PowerMonitorMessageBroadcaster::~PowerMonitorMessageBroadcaster() { |
- base::PowerMonitor::RemoveObserver(this); |
+ base::PowerMonitor* power_monitor = base::PowerMonitor::Get(); |
+ if (power_monitor) |
+ power_monitor->RemoveObserver(this); |
} |
void PowerMonitorMessageBroadcaster::OnPowerStateChange(bool on_battery_power) { |