| 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/ActiveScriptWrappable.h" | 8 #include "bindings/core/v8/ActiveScriptWrappable.h" |
| 9 #include "bindings/core/v8/ScriptPromise.h" | 9 #include "bindings/core/v8/ScriptPromise.h" |
| 10 #include "bindings/core/v8/ScriptPromiseProperty.h" | 10 #include "bindings/core/v8/ScriptPromiseProperty.h" |
| 11 #include "core/dom/ActiveDOMObject.h" | |
| 12 #include "core/dom/ContextLifecycleObserver.h" | 11 #include "core/dom/ContextLifecycleObserver.h" |
| 12 #include "core/dom/SuspendableObject.h" |
| 13 #include "core/frame/PlatformEventController.h" | 13 #include "core/frame/PlatformEventController.h" |
| 14 #include "modules/EventTargetModules.h" | 14 #include "modules/EventTargetModules.h" |
| 15 #include "modules/battery/battery_status.h" | 15 #include "modules/battery/battery_status.h" |
| 16 #include "platform/heap/Handle.h" | 16 #include "platform/heap/Handle.h" |
| 17 | 17 |
| 18 namespace blink { | 18 namespace blink { |
| 19 | 19 |
| 20 class BatteryManager final : public EventTargetWithInlineData, | 20 class BatteryManager final : public EventTargetWithInlineData, |
| 21 public ActiveScriptWrappable, | 21 public ActiveScriptWrappable, |
| 22 public ActiveDOMObject, | 22 public SuspendableObject, |
| 23 public PlatformEventController { | 23 public PlatformEventController { |
| 24 DEFINE_WRAPPERTYPEINFO(); | 24 DEFINE_WRAPPERTYPEINFO(); |
| 25 USING_GARBAGE_COLLECTED_MIXIN(BatteryManager); | 25 USING_GARBAGE_COLLECTED_MIXIN(BatteryManager); |
| 26 | 26 |
| 27 public: | 27 public: |
| 28 static BatteryManager* create(ExecutionContext*); | 28 static BatteryManager* create(ExecutionContext*); |
| 29 ~BatteryManager() override; | 29 ~BatteryManager() override; |
| 30 | 30 |
| 31 // Returns a promise object that will be resolved with this BatteryManager. | 31 // Returns a promise object that will be resolved with this BatteryManager. |
| 32 ScriptPromise startRequest(ScriptState*); | 32 ScriptPromise startRequest(ScriptState*); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 48 DEFINE_ATTRIBUTE_EVENT_LISTENER(chargingtimechange); | 48 DEFINE_ATTRIBUTE_EVENT_LISTENER(chargingtimechange); |
| 49 DEFINE_ATTRIBUTE_EVENT_LISTENER(dischargingtimechange); | 49 DEFINE_ATTRIBUTE_EVENT_LISTENER(dischargingtimechange); |
| 50 DEFINE_ATTRIBUTE_EVENT_LISTENER(levelchange); | 50 DEFINE_ATTRIBUTE_EVENT_LISTENER(levelchange); |
| 51 | 51 |
| 52 // Inherited from PlatformEventController. | 52 // Inherited from PlatformEventController. |
| 53 void didUpdateData() override; | 53 void didUpdateData() override; |
| 54 void registerWithDispatcher() override; | 54 void registerWithDispatcher() override; |
| 55 void unregisterWithDispatcher() override; | 55 void unregisterWithDispatcher() override; |
| 56 bool hasLastData() override; | 56 bool hasLastData() override; |
| 57 | 57 |
| 58 // ActiveDOMObject implementation. | 58 // SuspendableObject implementation. |
| 59 void suspend() override; | 59 void suspend() override; |
| 60 void resume() override; | 60 void resume() override; |
| 61 void contextDestroyed() override; | 61 void contextDestroyed() override; |
| 62 | 62 |
| 63 // ScriptWrappable implementation. | 63 // ScriptWrappable implementation. |
| 64 bool hasPendingActivity() const final; | 64 bool hasPendingActivity() const final; |
| 65 | 65 |
| 66 DECLARE_VIRTUAL_TRACE(); | 66 DECLARE_VIRTUAL_TRACE(); |
| 67 | 67 |
| 68 private: | 68 private: |
| 69 explicit BatteryManager(ExecutionContext*); | 69 explicit BatteryManager(ExecutionContext*); |
| 70 | 70 |
| 71 using BatteryProperty = ScriptPromiseProperty<Member<BatteryManager>, | 71 using BatteryProperty = ScriptPromiseProperty<Member<BatteryManager>, |
| 72 Member<BatteryManager>, | 72 Member<BatteryManager>, |
| 73 Member<DOMException>>; | 73 Member<DOMException>>; |
| 74 Member<BatteryProperty> m_batteryProperty; | 74 Member<BatteryProperty> m_batteryProperty; |
| 75 BatteryStatus m_batteryStatus; | 75 BatteryStatus m_batteryStatus; |
| 76 }; | 76 }; |
| 77 | 77 |
| 78 } // namespace blink | 78 } // namespace blink |
| 79 | 79 |
| 80 #endif // BatteryManager_h | 80 #endif // BatteryManager_h |
| OLD | NEW |