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

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

Issue 182613002: Add support to Battery Status API in blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add to RunTimeEnabledFeatures Created 6 years, 9 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
OLDNEW
(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/ActiveDOMObject.h"
9 #include "core/events/EventTarget.h"
10 #include "core/frame/Frame.h"
11 #include "modules/battery/BatteryStatus.h"
12
13 namespace WebCore {
14
15 class Navigator;
16 class ScriptExecutionContext;
17
18 class BatteryManager : public ActiveDOMObject, public RefCounted<BatteryManager> , public EventTarget {
abarth-chromium 2014/02/28 06:45:14 Please remove the ActiveDOMObject base class. It'
19 public:
20 virtual ~BatteryManager();
21 static PassRefPtr<BatteryManager> create(Frame*);
abarth-chromium 2014/02/28 06:45:14 This should probably be constructed from a Documen
22
23 // EventTarget implementation.
24 virtual const WTF::AtomicString& interfaceName() const { return EventTargetN ames::BatteryManager; }
25 virtual ExecutionContext* executionContext() const OVERRIDE FINAL { return A ctiveDOMObject::executionContext(); }
abarth-chromium 2014/02/28 06:45:14 The reason you should use a Document as the contex
26
27 bool charging();
28 double chargingTime();
29 double dischargingTime();
30 double level();
31
32 DEFINE_ATTRIBUTE_EVENT_LISTENER(chargingchange);
33 DEFINE_ATTRIBUTE_EVENT_LISTENER(chargingtimechange);
34 DEFINE_ATTRIBUTE_EVENT_LISTENER(dischargingtimechange);
35 DEFINE_ATTRIBUTE_EVENT_LISTENER(levelchange);
36
37 void didChangeBatteryStatus(PassRefPtr<Event>, PassOwnPtr<BatteryStatus>);
38
39 using RefCounted<BatteryManager>::ref;
40 using RefCounted<BatteryManager>::deref;
41
42 // ActiveDOMObject implementation.
43 virtual bool canSuspend() const { return true; }
44 virtual void suspend() OVERRIDE;
45 virtual void resume() OVERRIDE;
46 virtual void stop() OVERRIDE;
47
48 protected:
49 virtual EventTargetData* eventTargetData() { return &m_eventTargetData; }
50 virtual EventTargetData& ensureEventTargetData() { return m_eventTargetData; }
51
52 private:
53 explicit BatteryManager(Navigator*);
54 explicit BatteryManager(Frame*);
abarth-chromium 2014/02/28 06:45:14 You've still got two constructors. You only need
55
56 // EventTarget implementation.
57 virtual void refEventTarget() { ref(); }
58 virtual void derefEventTarget() { deref(); }
59
60 EventTargetData m_eventTargetData;
61 OwnPtr<BatteryStatus> m_batteryStatus;
62 };
63
64 }
65
66 #endif // BatteryManager_h
67
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698