| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "battery_status_dispatcher.h" | 5 #include "battery_status_dispatcher.h" |
| 6 | 6 |
| 7 #include "content/common/battery_status_messages.h" | 7 #include "content/common/battery_status_messages.h" |
| 8 #include "content/renderer/render_thread_impl.h" | 8 #include "content/renderer/render_thread_impl.h" |
| 9 #include "third_party/WebKit/public/platform/WebBatteryStatusListener.h" | 9 #include "third_party/WebKit/public/platform/WebBatteryStatusListener.h" |
| 10 | 10 |
| 11 namespace content { | 11 namespace content { |
| 12 | 12 |
| 13 BatteryStatusDispatcher::BatteryStatusDispatcher(RenderThread* thread) | 13 BatteryStatusDispatcher::BatteryStatusDispatcher(RenderThread* thread) |
| 14 : PlatformEventObserver<blink::WebBatteryStatusListener>(thread) { | 14 : PlatformEventObserver<blink::WebBatteryStatusListener>(thread) { |
| 15 } | 15 } |
| 16 | 16 |
| 17 BatteryStatusDispatcher::~BatteryStatusDispatcher() { | 17 BatteryStatusDispatcher::~BatteryStatusDispatcher() { |
| 18 StopIfObserving(); |
| 18 } | 19 } |
| 19 | 20 |
| 20 bool BatteryStatusDispatcher::OnControlMessageReceived( | 21 bool BatteryStatusDispatcher::OnControlMessageReceived( |
| 21 const IPC::Message& message) { | 22 const IPC::Message& message) { |
| 22 bool handled = true; | 23 bool handled = true; |
| 23 IPC_BEGIN_MESSAGE_MAP(BatteryStatusDispatcher, message) | 24 IPC_BEGIN_MESSAGE_MAP(BatteryStatusDispatcher, message) |
| 24 IPC_MESSAGE_HANDLER(BatteryStatusMsg_DidChange, OnDidChange) | 25 IPC_MESSAGE_HANDLER(BatteryStatusMsg_DidChange, OnDidChange) |
| 25 IPC_MESSAGE_UNHANDLED(handled = false) | 26 IPC_MESSAGE_UNHANDLED(handled = false) |
| 26 IPC_END_MESSAGE_MAP() | 27 IPC_END_MESSAGE_MAP() |
| 27 return handled; | 28 return handled; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 39 const blink::WebBatteryStatus& status) { | 40 const blink::WebBatteryStatus& status) { |
| 40 if (listener()) | 41 if (listener()) |
| 41 listener()->updateBatteryStatus(status); | 42 listener()->updateBatteryStatus(status); |
| 42 } | 43 } |
| 43 | 44 |
| 44 void BatteryStatusDispatcher::SendFakeDataForTesting(void* fake_data) { | 45 void BatteryStatusDispatcher::SendFakeDataForTesting(void* fake_data) { |
| 45 OnDidChange(*static_cast<blink::WebBatteryStatus*>(fake_data)); | 46 OnDidChange(*static_cast<blink::WebBatteryStatus*>(fake_data)); |
| 46 } | 47 } |
| 47 | 48 |
| 48 } // namespace content | 49 } // namespace content |
| OLD | NEW |