Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(856)

Side by Side Diff: Source/modules/battery/BatteryManager.h

Issue 417213002: Introduce PlatformEvent to handle Device events, Battery events and Gamepad events. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/modules/battery/BatteryDispatcher.cpp ('k') | Source/modules/battery/BatteryManager.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/ScriptPromiseResolver.h" 9 #include "bindings/core/v8/ScriptPromiseResolver.h"
10 #include "core/dom/ContextLifecycleObserver.h" 10 #include "core/dom/ContextLifecycleObserver.h"
11 #include "core/frame/DeviceEventControllerBase.h" 11 #include "core/frame/PlatformEventController.h"
12 #include "modules/EventTargetModules.h" 12 #include "modules/EventTargetModules.h"
13 #include "platform/heap/Handle.h" 13 #include "platform/heap/Handle.h"
14 14
15 namespace blink { 15 namespace blink {
16 16
17 class BatteryStatus; 17 class BatteryStatus;
18 18
19 class BatteryManager FINAL : public RefCountedWillBeRefCountedGarbageCollected<B atteryManager>, public ActiveDOMObject, public DeviceEventControllerBase, public EventTargetWithInlineData { 19 class BatteryManager FINAL : public RefCountedWillBeRefCountedGarbageCollected<B atteryManager>, public ActiveDOMObject, public PlatformEventController, public E ventTargetWithInlineData {
20 REFCOUNTED_EVENT_TARGET(BatteryManager); 20 REFCOUNTED_EVENT_TARGET(BatteryManager);
21 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(BatteryManager); 21 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(BatteryManager);
22 public: 22 public:
23 virtual ~BatteryManager(); 23 virtual ~BatteryManager();
24 static PassRefPtrWillBeRawPtr<BatteryManager> create(ExecutionContext*); 24 static PassRefPtrWillBeRawPtr<BatteryManager> create(ExecutionContext*);
25 25
26 // Returns a promise object that will be resolved with this BatteryManager. 26 // Returns a promise object that will be resolved with this BatteryManager.
27 ScriptPromise startRequest(ScriptState*); 27 ScriptPromise startRequest(ScriptState*);
28 28
29 // EventTarget implementation. 29 // EventTarget implementation.
30 virtual const WTF::AtomicString& interfaceName() const OVERRIDE { return Eve ntTargetNames::BatteryManager; } 30 virtual const WTF::AtomicString& interfaceName() const OVERRIDE { return Eve ntTargetNames::BatteryManager; }
31 virtual ExecutionContext* executionContext() const OVERRIDE { return Context LifecycleObserver::executionContext(); } 31 virtual ExecutionContext* executionContext() const OVERRIDE { return Context LifecycleObserver::executionContext(); }
32 32
33 bool charging(); 33 bool charging();
34 double chargingTime(); 34 double chargingTime();
35 double dischargingTime(); 35 double dischargingTime();
36 double level(); 36 double level();
37 37
38 DEFINE_ATTRIBUTE_EVENT_LISTENER(chargingchange); 38 DEFINE_ATTRIBUTE_EVENT_LISTENER(chargingchange);
39 DEFINE_ATTRIBUTE_EVENT_LISTENER(chargingtimechange); 39 DEFINE_ATTRIBUTE_EVENT_LISTENER(chargingtimechange);
40 DEFINE_ATTRIBUTE_EVENT_LISTENER(dischargingtimechange); 40 DEFINE_ATTRIBUTE_EVENT_LISTENER(dischargingtimechange);
41 DEFINE_ATTRIBUTE_EVENT_LISTENER(levelchange); 41 DEFINE_ATTRIBUTE_EVENT_LISTENER(levelchange);
42 42
43 // Inherited from DeviceEventControllerBase. 43 // Inherited from PlatformEventController.
44 virtual void didUpdateData() OVERRIDE; 44 virtual void didUpdateData() OVERRIDE;
45 virtual void registerWithDispatcher() OVERRIDE; 45 virtual void registerWithDispatcher() OVERRIDE;
46 virtual void unregisterWithDispatcher() OVERRIDE; 46 virtual void unregisterWithDispatcher() OVERRIDE;
47 virtual bool hasLastData() OVERRIDE; 47 virtual bool hasLastData() OVERRIDE;
48 48
49 // ActiveDOMObject implementation. 49 // ActiveDOMObject implementation.
50 virtual bool canSuspend() const { return true; } 50 virtual bool canSuspend() const { return true; }
51 virtual void suspend() OVERRIDE; 51 virtual void suspend() OVERRIDE;
52 virtual void resume() OVERRIDE; 52 virtual void resume() OVERRIDE;
53 virtual void stop() OVERRIDE; 53 virtual void stop() OVERRIDE;
(...skipping 11 matching lines...) Expand all
65 explicit BatteryManager(ExecutionContext*); 65 explicit BatteryManager(ExecutionContext*);
66 66
67 RefPtr<ScriptPromiseResolver> m_resolver; 67 RefPtr<ScriptPromiseResolver> m_resolver;
68 RefPtrWillBeMember<BatteryStatus> m_batteryStatus; 68 RefPtrWillBeMember<BatteryStatus> m_batteryStatus;
69 State m_state; 69 State m_state;
70 }; 70 };
71 71
72 } 72 }
73 73
74 #endif // BatteryManager_h 74 #endif // BatteryManager_h
OLDNEW
« no previous file with comments | « Source/modules/battery/BatteryDispatcher.cpp ('k') | Source/modules/battery/BatteryManager.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698