| 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 #ifndef BLINK_PLATFORM_BATTERY_BATTERY_DISPATCHER_PROXY_H_ | |
| 6 #define BLINK_PLATFORM_BATTERY_BATTERY_DISPATCHER_PROXY_H_ | |
| 7 | |
| 8 #include "device/battery/battery_monitor.mojom.h" | |
| 9 #include "platform/PlatformExport.h" | |
| 10 #include "wtf/Noncopyable.h" | |
| 11 | |
| 12 namespace blink { | |
| 13 | |
| 14 class BatteryStatus; | |
| 15 | |
| 16 // This class connects a BatteryDispatcherProxy::Listener to the underlying Mojo | |
| 17 // service. Note that currently the access to the Mojo service is limited in | |
| 18 // platform/. In future, we'll let classes in core/ and modules/ directly | |
| 19 // communicate with Mojo, and then, there will be no need to use this proxy | |
| 20 // class. | |
| 21 // | |
| 22 // TODO(yukishiino): Remove this class once Mojo supports WTF-types. | |
| 23 class PLATFORM_EXPORT BatteryDispatcherProxy { | |
| 24 WTF_MAKE_NONCOPYABLE(BatteryDispatcherProxy); | |
| 25 public: | |
| 26 class PLATFORM_EXPORT Listener { | |
| 27 public: | |
| 28 virtual ~Listener() = default; | |
| 29 | |
| 30 // This method is called when a new battery status is available. | |
| 31 virtual void OnUpdateBatteryStatus(const BatteryStatus&) = 0; | |
| 32 }; | |
| 33 | |
| 34 explicit BatteryDispatcherProxy(Listener*); | |
| 35 ~BatteryDispatcherProxy(); | |
| 36 | |
| 37 void StartListening(); | |
| 38 void StopListening(); | |
| 39 | |
| 40 private: | |
| 41 void QueryNextStatus(); | |
| 42 void OnDidChange(device::BatteryStatusPtr); | |
| 43 | |
| 44 device::BatteryMonitorPtr monitor_; | |
| 45 Listener* listener_; | |
| 46 | |
| 47 friend class BatteryDispatcherProxyTest; | |
| 48 }; | |
| 49 | |
| 50 } // namespace blink | |
| 51 | |
| 52 #endif // BLINK_PLATFORM_BATTERY_BATTERY_DISPATCHER_PROXY_H_ | |
| OLD | NEW |