Chromium Code Reviews| 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 #ifndef BatteryDispatcher_h | 5 #ifndef BatteryDispatcher_h |
| 6 #define BatteryDispatcher_h | 6 #define BatteryDispatcher_h |
| 7 | 7 |
| 8 #include "core/frame/PlatformEventDispatcher.h" | 8 #include "core/frame/PlatformEventDispatcher.h" |
| 9 #include "modules/ModulesExport.h" | |
| 9 #include "modules/battery/BatteryManager.h" | 10 #include "modules/battery/BatteryManager.h" |
| 10 #include "modules/battery/BatteryStatus.h" | 11 #include "platform/battery/battery_dispatcher_proxy.h" |
| 11 #include "public/platform/WebBatteryStatusListener.h" | 12 #include "wtf/OwnPtr.h" |
| 12 | 13 |
| 13 namespace blink { | 14 namespace blink { |
| 14 | 15 |
| 15 class WebBatteryStatus; | 16 class BatteryDispatcherProxy; |
|
kinuko
2016/02/18 00:50:53
nit: now we include the header for Listener class
Yuki
2016/02/18 06:05:14
Done.
| |
| 16 | 17 |
| 17 class BatteryDispatcher final : public GarbageCollectedFinalized<BatteryDispatch er>, public PlatformEventDispatcher, public WebBatteryStatusListener { | 18 class MODULES_EXPORT BatteryDispatcher final : public GarbageCollectedFinalized< BatteryDispatcher>, public PlatformEventDispatcher, public BatteryDispatcherProx y::Listener { |
| 18 USING_GARBAGE_COLLECTED_MIXIN(BatteryDispatcher); | 19 USING_GARBAGE_COLLECTED_MIXIN(BatteryDispatcher); |
| 19 public: | 20 public: |
| 20 static BatteryDispatcher& instance(); | 21 static BatteryDispatcher& instance(); |
| 21 ~BatteryDispatcher() override; | 22 ~BatteryDispatcher() override; |
| 22 | 23 |
| 23 BatteryStatus* latestData(); | 24 const BatteryStatus* latestData() const |
| 25 { | |
| 26 return m_hasLatestData ? &m_batteryStatus : nullptr; | |
| 27 } | |
| 24 | 28 |
| 25 // Inherited from WebBatteryStatusListener. | 29 // Inherited from BatteryDispatcherProxy::Listener. |
| 26 void updateBatteryStatus(const WebBatteryStatus&) override; | 30 void OnUpdateBatteryStatus(const BatteryStatus&) override; |
| 27 | |
| 28 DECLARE_VIRTUAL_TRACE(); | |
| 29 | 31 |
| 30 private: | 32 private: |
| 31 BatteryDispatcher(); | 33 BatteryDispatcher(); |
| 32 | 34 |
| 33 // Inherited from PlatformEventDispatcher. | 35 // Inherited from PlatformEventDispatcher. |
| 34 void startListening() override; | 36 void startListening() override; |
| 35 void stopListening() override; | 37 void stopListening() override; |
| 36 | 38 |
| 37 Member<BatteryStatus> m_batteryStatus; | 39 BatteryStatus m_batteryStatus; |
| 40 bool m_hasLatestData; | |
| 41 OwnPtr<BatteryDispatcherProxy> m_batteryDispatcherProxy; | |
| 38 }; | 42 }; |
| 39 | 43 |
| 40 } // namespace blink | 44 } // namespace blink |
| 41 | 45 |
| 42 #endif // BatteryDispatcher_h | 46 #endif // BatteryDispatcher_h |
| OLD | NEW |