OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "fake_battery_status_dispatcher.h" |
| 6 |
| 7 #include "base/bind.h" |
| 8 #include "base/location.h" |
| 9 #include "base/message_loop/message_loop_proxy.h" |
| 10 #include "third_party/WebKit/public/platform/WebBatteryStatusListener.h" |
| 11 |
| 12 namespace content { |
| 13 |
| 14 FakeBatteryStatusDispatcher::FakeBatteryStatusDispatcher() : listener_(0) { |
| 15 } |
| 16 |
| 17 void FakeBatteryStatusDispatcher::SetListener( |
| 18 blink::WebBatteryStatusListener* listener) { |
| 19 listener_ = listener; |
| 20 } |
| 21 |
| 22 void FakeBatteryStatusDispatcher::PostBatteryStatusChange( |
| 23 const blink::WebBatteryStatus& status) { |
| 24 if (!listener_) |
| 25 return; |
| 26 |
| 27 base::MessageLoopProxy::current()->PostTask( |
| 28 FROM_HERE, |
| 29 base::Bind(&blink::WebBatteryStatusListener::updateBatteryStatus, |
| 30 base::Unretained(listener_), |
| 31 status)); |
| 32 } |
| 33 |
| 34 } // namespace content |
OLD | NEW |