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 BatteryManager_h | 5 #ifndef BatteryManager_h |
6 #define BatteryManager_h | 6 #define BatteryManager_h |
7 | 7 |
8 #include "core/dom/ContextLifecycleObserver.h" | 8 #include "core/dom/ContextLifecycleObserver.h" |
9 #include "core/dom/Document.h" | 9 #include "core/dom/Document.h" |
10 #include "core/frame/DeviceEventControllerBase.h" | 10 #include "core/frame/DeviceSensorEventController.h" |
11 #include "modules/EventTargetModules.h" | 11 #include "modules/EventTargetModules.h" |
12 #include "platform/heap/Handle.h" | 12 #include "platform/heap/Handle.h" |
13 | 13 |
14 namespace WebCore { | 14 namespace WebCore { |
15 | 15 |
16 class BatteryStatus; | |
17 class Navigator; | 16 class Navigator; |
18 | 17 |
19 class BatteryManager FINAL : public RefCountedWillBeRefCountedGarbageCollected<B
atteryManager>, public ActiveDOMObject, public DeviceEventControllerBase, public
EventTargetWithInlineData { | 18 class BatteryManager FINAL : public RefCountedWillBeRefCountedGarbageCollected<B
atteryManager>, public ActiveDOMObject, public DeviceSensorEventController, publ
ic EventTargetWithInlineData { |
20 REFCOUNTED_EVENT_TARGET(BatteryManager); | 19 REFCOUNTED_EVENT_TARGET(BatteryManager); |
21 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(BatteryManager); | 20 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(BatteryManager); |
22 public: | 21 public: |
23 virtual ~BatteryManager(); | 22 virtual ~BatteryManager(); |
24 static PassRefPtrWillBeRawPtr<BatteryManager> create(ExecutionContext*); | 23 static PassRefPtrWillBeRawPtr<BatteryManager> create(ExecutionContext*); |
25 | 24 |
26 // EventTarget implementation. | 25 // EventTarget implementation. |
27 virtual const WTF::AtomicString& interfaceName() const OVERRIDE { return Eve
ntTargetNames::BatteryManager; } | 26 virtual const WTF::AtomicString& interfaceName() const OVERRIDE { return Eve
ntTargetNames::BatteryManager; } |
28 virtual ExecutionContext* executionContext() const OVERRIDE { return Context
LifecycleObserver::executionContext(); } | 27 virtual ExecutionContext* executionContext() const OVERRIDE { return Context
LifecycleObserver::executionContext(); } |
29 | 28 |
30 bool charging(); | 29 bool charging(); |
31 double chargingTime(); | 30 double chargingTime(); |
32 double dischargingTime(); | 31 double dischargingTime(); |
33 double level(); | 32 double level(); |
34 | 33 |
35 DEFINE_ATTRIBUTE_EVENT_LISTENER(chargingchange); | 34 DEFINE_ATTRIBUTE_EVENT_LISTENER(chargingchange); |
36 DEFINE_ATTRIBUTE_EVENT_LISTENER(chargingtimechange); | 35 DEFINE_ATTRIBUTE_EVENT_LISTENER(chargingtimechange); |
37 DEFINE_ATTRIBUTE_EVENT_LISTENER(dischargingtimechange); | 36 DEFINE_ATTRIBUTE_EVENT_LISTENER(dischargingtimechange); |
38 DEFINE_ATTRIBUTE_EVENT_LISTENER(levelchange); | 37 DEFINE_ATTRIBUTE_EVENT_LISTENER(levelchange); |
39 | 38 |
40 // Inherited from DeviceEventControllerBase. | 39 void didChangeBatteryStatus(PassRefPtrWillBeRawPtr<Event>); |
41 virtual void didUpdateData() OVERRIDE; | |
42 virtual void registerWithDispatcher() OVERRIDE; | |
43 virtual void unregisterWithDispatcher() OVERRIDE; | |
44 virtual bool hasLastData() OVERRIDE; | |
45 | 40 |
46 // ActiveDOMObject implementation. | 41 // ActiveDOMObject implementation. |
47 virtual bool canSuspend() const { return true; } | 42 virtual bool canSuspend() const { return true; } |
48 virtual void suspend() OVERRIDE; | 43 virtual void suspend() OVERRIDE; |
49 virtual void resume() OVERRIDE; | 44 virtual void resume() OVERRIDE; |
50 virtual void stop() OVERRIDE; | 45 virtual void stop() OVERRIDE; |
51 | 46 |
| 47 // DeviceSensorEventController |
| 48 virtual void registerWithDispatcher() OVERRIDE; |
| 49 virtual void unregisterWithDispatcher() OVERRIDE; |
| 50 virtual bool hasLastData() OVERRIDE; |
| 51 virtual PassRefPtrWillBeRawPtr<Event> getLastEvent() OVERRIDE; |
| 52 virtual bool isNullEvent(Event*) OVERRIDE; |
| 53 virtual Document* document() OVERRIDE; |
| 54 |
52 private: | 55 private: |
53 explicit BatteryManager(ExecutionContext*); | 56 explicit BatteryManager(ExecutionContext*); |
54 | |
55 RefPtr<BatteryStatus> m_batteryStatus; | |
56 }; | 57 }; |
57 | 58 |
58 } | 59 } |
59 | 60 |
60 #endif // BatteryManager_h | 61 #endif // BatteryManager_h |
61 | 62 |
OLD | NEW |