| Index: content/renderer/battery_status_dispatcher.cc
|
| diff --git a/content/renderer/battery_status_dispatcher.cc b/content/renderer/battery_status_dispatcher.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..369d021ee689ed1549064322926ca1e9e5da2c2e
|
| --- /dev/null
|
| +++ b/content/renderer/battery_status_dispatcher.cc
|
| @@ -0,0 +1,48 @@
|
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "content/renderer/battery_status_dispatcher.h"
|
| +
|
| +#include "base/pickle.h"
|
| +#include "content/common/battery_status_messages.h"
|
| +#include "content/renderer/render_view_impl.h"
|
| +#include "third_party/WebKit/Source/WebKit/chromium/public/WebBatteryStatus.h"
|
| +
|
| +namespace content {
|
| +
|
| +BatteryStatusDispatcher::BatteryStatusDispatcher(RenderViewImpl* render_view)
|
| + : RenderViewObserver(render_view),
|
| + started_(false) {
|
| +}
|
| +
|
| +BatteryStatusDispatcher::~BatteryStatusDispatcher() {
|
| + if (started_)
|
| + stopUpdating();
|
| +}
|
| +
|
| +bool BatteryStatusDispatcher::OnMessageReceived(const IPC::Message& msg) {
|
| + bool handled = true;
|
| + IPC_BEGIN_MESSAGE_MAP(BatteryStatusDispatcher, msg)
|
| + IPC_MESSAGE_HANDLER(BatteryStatusMsg_Updated, OnBatteryStatusUpdated)
|
| + IPC_MESSAGE_UNHANDLED(handled = false)
|
| + IPC_END_MESSAGE_MAP()
|
| + return handled;
|
| +}
|
| +
|
| +void BatteryStatusDispatcher::startUpdating() {
|
| + Send(new BatteryStatusHostMsg_StartUpdating(routing_id()));
|
| + started_ = true;
|
| +}
|
| +
|
| +void BatteryStatusDispatcher::stopUpdating() {
|
| + Send(new BatteryStatusHostMsg_StopUpdating(routing_id()));
|
| + started_ = false;
|
| +}
|
| +
|
| +void BatteryStatusDispatcher::OnBatteryStatusUpdated(
|
| + const WebKit::WebBatteryStatus& battery_status) {
|
| + render_view()->GetWebView()->updateBatteryStatus(battery_status);
|
| +}
|
| +
|
| +} // namespace content
|
|
|