Revert 268405 "Make sure that ScratchBuffer::Allocate() always r..."
[chromium-blink-merge.git] / content / browser / power_monitor_message_broadcaster.cc
blob23de161b05c7225af72b1efb3dcd45c8545c879f
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.
5 #include "content/browser/power_monitor_message_broadcaster.h"
7 #include "base/power_monitor/power_monitor.h"
8 #include "content/common/power_monitor_messages.h"
9 #include "ipc/ipc_sender.h"
11 namespace content {
13 PowerMonitorMessageBroadcaster::PowerMonitorMessageBroadcaster(
14 IPC::Sender* sender)
15 : sender_(sender) {
16 base::PowerMonitor* power_monitor = base::PowerMonitor::Get();
17 if (power_monitor)
18 power_monitor->AddObserver(this);
21 PowerMonitorMessageBroadcaster::~PowerMonitorMessageBroadcaster() {
22 base::PowerMonitor* power_monitor = base::PowerMonitor::Get();
23 if (power_monitor)
24 power_monitor->RemoveObserver(this);
27 void PowerMonitorMessageBroadcaster::OnPowerStateChange(bool on_battery_power) {
28 sender_->Send(new PowerMonitorMsg_PowerStateChange(on_battery_power));
31 void PowerMonitorMessageBroadcaster::OnSuspend() {
32 sender_->Send(new PowerMonitorMsg_Suspend());
35 void PowerMonitorMessageBroadcaster::OnResume() {
36 sender_->Send(new PowerMonitorMsg_Resume());
39 } // namespace content