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 "bindings/core/v8/ScriptPromise.h" | 8 #include "bindings/core/v8/ScriptPromise.h" |
9 #include "bindings/core/v8/ScriptPromiseProperty.h" | 9 #include "bindings/core/v8/ScriptPromiseProperty.h" |
10 #include "core/dom/ActiveDOMObject.h" | 10 #include "core/dom/ActiveDOMObject.h" |
11 #include "core/dom/ContextLifecycleObserver.h" | 11 #include "core/dom/ContextLifecycleObserver.h" |
12 #include "core/frame/PlatformEventController.h" | 12 #include "core/frame/PlatformEventController.h" |
13 #include "modules/EventTargetModules.h" | 13 #include "modules/EventTargetModules.h" |
14 #include "platform/heap/Handle.h" | 14 #include "platform/heap/Handle.h" |
15 | 15 |
16 namespace blink { | 16 namespace blink { |
17 | 17 |
18 class BatteryStatus; | 18 class BatteryStatus; |
19 | 19 |
20 class BatteryManager final : public RefCountedGarbageCollectedEventTargetWithInl
ineData<BatteryManager>, public ActiveDOMObject, public PlatformEventController
{ | 20 class BatteryManager final : public RefCountedGarbageCollectedEventTargetWithInl
ineData<BatteryManager>, public ActiveDOMObject, public PlatformEventController
{ |
21 REFCOUNTED_GARBAGE_COLLECTED_EVENT_TARGET(BatteryManager); | 21 REFCOUNTED_GARBAGE_COLLECTED_EVENT_TARGET(BatteryManager); |
22 DEFINE_WRAPPERTYPEINFO(); | 22 DEFINE_WRAPPERTYPEINFO(); |
23 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(BatteryManager); | 23 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(BatteryManager); |
24 public: | 24 public: |
25 static BatteryManager* create(ExecutionContext*); | 25 static BatteryManager* create(ExecutionContext*); |
26 virtual ~BatteryManager(); | 26 ~BatteryManager() override; |
27 | 27 |
28 // Returns a promise object that will be resolved with this BatteryManager. | 28 // Returns a promise object that will be resolved with this BatteryManager. |
29 ScriptPromise startRequest(ScriptState*); | 29 ScriptPromise startRequest(ScriptState*); |
30 | 30 |
31 // EventTarget implementation. | 31 // EventTarget implementation. |
32 virtual const WTF::AtomicString& interfaceName() const override { return Eve
ntTargetNames::BatteryManager; } | 32 const WTF::AtomicString& interfaceName() const override { return EventTarget
Names::BatteryManager; } |
33 virtual ExecutionContext* executionContext() const override { return Context
LifecycleObserver::executionContext(); } | 33 ExecutionContext* executionContext() const override { return ContextLifecycl
eObserver::executionContext(); } |
34 | 34 |
35 bool charging(); | 35 bool charging(); |
36 double chargingTime(); | 36 double chargingTime(); |
37 double dischargingTime(); | 37 double dischargingTime(); |
38 double level(); | 38 double level(); |
39 | 39 |
40 DEFINE_ATTRIBUTE_EVENT_LISTENER(chargingchange); | 40 DEFINE_ATTRIBUTE_EVENT_LISTENER(chargingchange); |
41 DEFINE_ATTRIBUTE_EVENT_LISTENER(chargingtimechange); | 41 DEFINE_ATTRIBUTE_EVENT_LISTENER(chargingtimechange); |
42 DEFINE_ATTRIBUTE_EVENT_LISTENER(dischargingtimechange); | 42 DEFINE_ATTRIBUTE_EVENT_LISTENER(dischargingtimechange); |
43 DEFINE_ATTRIBUTE_EVENT_LISTENER(levelchange); | 43 DEFINE_ATTRIBUTE_EVENT_LISTENER(levelchange); |
44 | 44 |
45 // Inherited from PlatformEventController. | 45 // Inherited from PlatformEventController. |
46 virtual void didUpdateData() override; | 46 void didUpdateData() override; |
47 virtual void registerWithDispatcher() override; | 47 void registerWithDispatcher() override; |
48 virtual void unregisterWithDispatcher() override; | 48 void unregisterWithDispatcher() override; |
49 virtual bool hasLastData() override; | 49 bool hasLastData() override; |
50 | 50 |
51 // ActiveDOMObject implementation. | 51 // ActiveDOMObject implementation. |
52 virtual void suspend() override; | 52 void suspend() override; |
53 virtual void resume() override; | 53 void resume() override; |
54 virtual void stop() override; | 54 void stop() override; |
55 virtual bool hasPendingActivity() const override; | 55 bool hasPendingActivity() const override; |
56 | 56 |
57 DECLARE_VIRTUAL_TRACE(); | 57 DECLARE_VIRTUAL_TRACE(); |
58 | 58 |
59 private: | 59 private: |
60 explicit BatteryManager(ExecutionContext*); | 60 explicit BatteryManager(ExecutionContext*); |
61 | 61 |
62 using BatteryProperty = ScriptPromiseProperty<Member<BatteryManager>, Member
<BatteryManager>, Member<DOMException>>; | 62 using BatteryProperty = ScriptPromiseProperty<Member<BatteryManager>, Member
<BatteryManager>, Member<DOMException>>; |
63 Member<BatteryProperty> m_batteryProperty; | 63 Member<BatteryProperty> m_batteryProperty; |
64 Member<BatteryStatus> m_batteryStatus; | 64 Member<BatteryStatus> m_batteryStatus; |
65 }; | 65 }; |
66 | 66 |
67 } // namespace blink | 67 } // namespace blink |
68 | 68 |
69 #endif // BatteryManager_h | 69 #endif // BatteryManager_h |
OLD | NEW |