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 { | |
Inactive
2014/03/06 13:45:39
I believe you can subclass EventTargetWithInlineDa
| |
18 public: | |
Inactive
2014/03/06 13:45:39
REFCOUNTED_EVENT_TARGET(BatteryManager);
| |
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(); } | |
Inactive
2014/03/06 13:45:39
Don't need the FINAL here if you mark the class as
| |
25 | |
26 bool charging(); | |
27 double chargingTime(); | |
28 double dischargingTime(); | |
29 double level(); | |
30 | |
31 DEFINE_ATTRIBUTE_EVENT_LISTENER(chargingchange); | |
32 DEFINE_ATTRIBUTE_EVENT_LISTENER(chargingtimechange); | |
33 DEFINE_ATTRIBUTE_EVENT_LISTENER(dischargingtimechange); | |
34 DEFINE_ATTRIBUTE_EVENT_LISTENER(levelchange); | |
35 | |
36 void didChangeBatteryStatus(PassRefPtr<Event>, PassOwnPtr<BatteryStatus>); | |
37 | |
38 using RefCounted<BatteryManager>::ref; | |
Inactive
2014/03/06 13:45:39
Not needed if you use the macro I suggested.
| |
39 using RefCounted<BatteryManager>::deref; | |
Inactive
2014/03/06 13:45:39
Not needed if you use the macro I suggested.
| |
40 | |
41 protected: | |
42 virtual EventTargetData* eventTargetData() { return &m_eventTargetData; } | |
Inactive
2014/03/06 13:45:39
Not needed if you subclass EventTargetWithInlineDa
| |
43 virtual EventTargetData& ensureEventTargetData() { return m_eventTargetData; } | |
Inactive
2014/03/06 13:45:39
Not needed if you subclass EventTargetWithInlineDa
| |
44 | |
45 private: | |
46 explicit BatteryManager(ExecutionContext*); | |
47 | |
48 // EventTarget implementation. | |
Inactive
2014/03/06 13:45:39
Those 2 methods are not needed if you use the macr
| |
49 virtual void refEventTarget() { ref(); } | |
50 virtual void derefEventTarget() { deref(); } | |
51 | |
52 EventTargetData m_eventTargetData; | |
Inactive
2014/03/06 13:45:39
Not needed if you subclass EventTargetWithInlineDa
| |
53 OwnPtr<BatteryStatus> m_batteryStatus; | |
54 }; | |
55 | |
56 } | |
57 | |
58 #endif // BatteryManager_h | |
59 | |
OLD | NEW |