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

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

Issue 315573002: Generalize and refactor DeviceSensorEvent* architecture to support multi-event type targets. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: add stopUpdating in destructor of BatteryManager. Created 6 years, 6 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 | Annotate | Revision Log
« 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 "core/dom/ContextLifecycleObserver.h" 8 #include "core/dom/ContextLifecycleObserver.h"
9 #include "core/dom/Document.h" 9 #include "core/dom/Document.h"
10 #include "core/frame/DeviceSensorEventController.h" 10 #include "core/frame/DeviceEventControllerBase.h"
11 #include "modules/EventTargetModules.h" 11 #include "modules/EventTargetModules.h"
12 #include "platform/heap/Handle.h" 12 #include "platform/heap/Handle.h"
13 13
14 namespace WebCore { 14 namespace WebCore {
15 15
16 class BatteryStatus;
16 class Navigator; 17 class Navigator;
17 18
18 class BatteryManager FINAL : public RefCountedWillBeRefCountedGarbageCollected<B atteryManager>, public ActiveDOMObject, public DeviceSensorEventController, publ ic EventTargetWithInlineData { 19 class BatteryManager FINAL : public RefCountedWillBeRefCountedGarbageCollected<B atteryManager>, public ActiveDOMObject, public DeviceEventControllerBase, public EventTargetWithInlineData {
19 REFCOUNTED_EVENT_TARGET(BatteryManager); 20 REFCOUNTED_EVENT_TARGET(BatteryManager);
20 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(BatteryManager); 21 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(BatteryManager);
21 public: 22 public:
22 virtual ~BatteryManager(); 23 virtual ~BatteryManager();
23 static PassRefPtrWillBeRawPtr<BatteryManager> create(ExecutionContext*); 24 static PassRefPtrWillBeRawPtr<BatteryManager> create(ExecutionContext*);
24 25
25 // EventTarget implementation. 26 // EventTarget implementation.
26 virtual const WTF::AtomicString& interfaceName() const OVERRIDE { return Eve ntTargetNames::BatteryManager; } 27 virtual const WTF::AtomicString& interfaceName() const OVERRIDE { return Eve ntTargetNames::BatteryManager; }
27 virtual ExecutionContext* executionContext() const OVERRIDE { return Context LifecycleObserver::executionContext(); } 28 virtual ExecutionContext* executionContext() const OVERRIDE { return Context LifecycleObserver::executionContext(); }
28 29
29 bool charging(); 30 bool charging();
30 double chargingTime(); 31 double chargingTime();
31 double dischargingTime(); 32 double dischargingTime();
32 double level(); 33 double level();
33 34
34 DEFINE_ATTRIBUTE_EVENT_LISTENER(chargingchange); 35 DEFINE_ATTRIBUTE_EVENT_LISTENER(chargingchange);
35 DEFINE_ATTRIBUTE_EVENT_LISTENER(chargingtimechange); 36 DEFINE_ATTRIBUTE_EVENT_LISTENER(chargingtimechange);
36 DEFINE_ATTRIBUTE_EVENT_LISTENER(dischargingtimechange); 37 DEFINE_ATTRIBUTE_EVENT_LISTENER(dischargingtimechange);
37 DEFINE_ATTRIBUTE_EVENT_LISTENER(levelchange); 38 DEFINE_ATTRIBUTE_EVENT_LISTENER(levelchange);
38 39
39 void didChangeBatteryStatus(PassRefPtrWillBeRawPtr<Event>); 40 // Inherited from DeviceEventControllerBase.
41 virtual void didUpdateData() OVERRIDE;
42 virtual void registerWithDispatcher() OVERRIDE;
43 virtual void unregisterWithDispatcher() OVERRIDE;
44 virtual bool hasLastData() OVERRIDE;
40 45
41 // ActiveDOMObject implementation. 46 // ActiveDOMObject implementation.
42 virtual bool canSuspend() const { return true; } 47 virtual bool canSuspend() const { return true; }
43 virtual void suspend() OVERRIDE; 48 virtual void suspend() OVERRIDE;
44 virtual void resume() OVERRIDE; 49 virtual void resume() OVERRIDE;
45 virtual void stop() OVERRIDE; 50 virtual void stop() OVERRIDE;
46 51
47 // DeviceSensorEventController
48 virtual void registerWithDispatcher() OVERRIDE;
49 virtual void unregisterWithDispatcher() OVERRIDE;
50 virtual bool hasLastData() OVERRIDE;
51 virtual PassRefPtrWillBeRawPtr<Event> getLastEvent() OVERRIDE;
52 virtual bool isNullEvent(Event*) OVERRIDE;
53 virtual Document* document() OVERRIDE;
54
55 private: 52 private:
56 explicit BatteryManager(ExecutionContext*); 53 explicit BatteryManager(ExecutionContext*);
54
55 RefPtr<BatteryStatus> m_batteryStatus;
57 }; 56 };
58 57
59 } 58 }
60 59
61 #endif // BatteryManager_h 60 #endif // BatteryManager_h
62 61
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