blob: 52f2657abcbf6297580342e1f1ee5db93405d193 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef BatteryManager_h
#define BatteryManager_h
#include "bindings/core/v8/ScriptPromise.h"
#include "bindings/core/v8/ScriptPromiseProperty.h"
#include "core/dom/ActiveDOMObject.h"
#include "core/dom/ContextLifecycleObserver.h"
#include "core/frame/PlatformEventController.h"
#include "modules/EventTargetModules.h"
#include "platform/battery/battery_status.h"
#include "platform/heap/Handle.h"
namespace blink {
class BatteryManager final : public RefCountedGarbageCollectedEventTargetWithInlineData<BatteryManager>, public ActiveDOMObject, public PlatformEventController {
REFCOUNTED_GARBAGE_COLLECTED_EVENT_TARGET(BatteryManager);
DEFINE_WRAPPERTYPEINFO();
WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(BatteryManager);
public:
static BatteryManager* create(ExecutionContext*);
~BatteryManager() override;
// Returns a promise object that will be resolved with this BatteryManager.
ScriptPromise startRequest(ScriptState*);
// EventTarget implementation.
const WTF::AtomicString& interfaceName() const override { return EventTargetNames::BatteryManager; }
ExecutionContext* getExecutionContext() const override { return ContextLifecycleObserver::getExecutionContext(); }
bool charging();
double chargingTime();
double dischargingTime();
double level();
DEFINE_ATTRIBUTE_EVENT_LISTENER(chargingchange);
DEFINE_ATTRIBUTE_EVENT_LISTENER(chargingtimechange);
DEFINE_ATTRIBUTE_EVENT_LISTENER(dischargingtimechange);
DEFINE_ATTRIBUTE_EVENT_LISTENER(levelchange);
// Inherited from PlatformEventController.
void didUpdateData() override;
void registerWithDispatcher() override;
void unregisterWithDispatcher() override;
bool hasLastData() override;
// ActiveDOMObject implementation.
void suspend() override;
void resume() override;
void stop() override;
bool hasPendingActivity() const override;
DECLARE_VIRTUAL_TRACE();
private:
explicit BatteryManager(ExecutionContext*);
using BatteryProperty = ScriptPromiseProperty<Member<BatteryManager>, Member<BatteryManager>, Member<DOMException>>;
Member<BatteryProperty> m_batteryProperty;
BatteryStatus m_batteryStatus;
};
} // namespace blink
#endif // BatteryManager_h
|