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 BatteryManager_h |
| 6 #define BatteryManager_h |
| 7 |
| 8 #include "core/dom/ContextLifecycleObserver.h" |
| 9 #include "core/dom/Document.h" |
| 10 #include "core/events/EventTarget.h" |
| 11 #include "modules/battery/BatteryStatus.h" |
| 12 |
| 13 namespace WebCore { |
| 14 |
| 15 class Navigator; |
| 16 |
| 17 class BatteryManager : public ContextLifecycleObserver, public RefCounted<Batter
yManager>, public EventTarget { |
| 18 public: |
| 19 virtual ~BatteryManager(); |
| 20 static PassRefPtr<BatteryManager> create(ExecutionContext*); |
| 21 |
| 22 // EventTarget implementation. |
| 23 virtual const WTF::AtomicString& interfaceName() const { return EventTargetN
ames::BatteryManager; } |
| 24 virtual ExecutionContext* executionContext() const OVERRIDE FINAL { return C
ontextLifecycleObserver::executionContext(); } |
| 25 |
| 26 // ContextLifecycleObserver |
| 27 virtual void contextDestroyed() OVERRIDE; |
| 28 |
| 29 bool charging(); |
| 30 double chargingTime(); |
| 31 double dischargingTime(); |
| 32 double level(); |
| 33 |
| 34 DEFINE_ATTRIBUTE_EVENT_LISTENER(chargingchange); |
| 35 DEFINE_ATTRIBUTE_EVENT_LISTENER(chargingtimechange); |
| 36 DEFINE_ATTRIBUTE_EVENT_LISTENER(dischargingtimechange); |
| 37 DEFINE_ATTRIBUTE_EVENT_LISTENER(levelchange); |
| 38 |
| 39 void didChangeBatteryStatus(PassRefPtr<Event>, PassOwnPtr<BatteryStatus>); |
| 40 |
| 41 using RefCounted<BatteryManager>::ref; |
| 42 using RefCounted<BatteryManager>::deref; |
| 43 |
| 44 protected: |
| 45 virtual EventTargetData* eventTargetData() { return &m_eventTargetData; } |
| 46 virtual EventTargetData& ensureEventTargetData() { return m_eventTargetData;
} |
| 47 |
| 48 private: |
| 49 explicit BatteryManager(ExecutionContext*); |
| 50 |
| 51 // EventTarget implementation. |
| 52 virtual void refEventTarget() { ref(); } |
| 53 virtual void derefEventTarget() { deref(); } |
| 54 |
| 55 EventTargetData m_eventTargetData; |
| 56 OwnPtr<BatteryStatus> m_batteryStatus; |
| 57 }; |
| 58 |
| 59 } |
| 60 |
| 61 #endif // BatteryManager_h |
| 62 |
OLD | NEW |