Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 /* | |
| 2 * Copyright (C) 2012 Samsung Electronics | |
| 3 * Copyright (C) 2014 Intel Corporation | |
| 4 * | |
| 5 * This library is free software; you can redistribute it and/or | |
| 6 * modify it under the terms of the GNU Library General Public | |
| 7 * License as published by the Free Software Foundation; either | |
| 8 * version 2 of the License, or (at your option) any later version. | |
| 9 * | |
| 10 * This library is distributed in the hope that it will be useful, | |
| 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 13 * Library General Public License for more details. | |
| 14 * | |
| 15 * You should have received a copy of the GNU Library General Public License | |
| 16 * along with this library; see the file COPYING.LIB. If not, write to | |
| 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | |
| 18 * Boston, MA 02110-1301, USA. | |
| 19 */ | |
|
abarth-chromium
2014/02/27 05:42:09
Please use this license for new files:
http://dev
| |
| 20 | |
| 21 #ifndef BatteryManager_h | |
| 22 #define BatteryManager_h | |
| 23 | |
| 24 #include "core/dom/ActiveDOMObject.h" | |
| 25 #include "core/events/EventTarget.h" | |
| 26 #include "core/frame/Frame.h" | |
| 27 #include "modules/battery/BatteryStatus.h" | |
| 28 | |
| 29 namespace WebCore { | |
| 30 | |
| 31 class Navigator; | |
| 32 class ScriptExecutionContext; | |
| 33 | |
| 34 class BatteryManager : public ActiveDOMObject, public RefCounted<BatteryManager> , public EventTarget { | |
| 35 public: | |
| 36 virtual ~BatteryManager(); | |
| 37 static PassRefPtr<BatteryManager> create(Navigator*); | |
| 38 static PassRefPtr<BatteryManager> create(Frame*); | |
|
abarth-chromium
2014/02/27 05:42:09
Why are there two create functions? It seems like
| |
| 39 | |
| 40 // EventTarget implementation. | |
| 41 virtual const WTF::AtomicString& interfaceName() const { return EventTargetN ames::BatteryManager; } | |
| 42 virtual ExecutionContext* executionContext() const OVERRIDE FINAL { return A ctiveDOMObject::executionContext(); } | |
| 43 | |
| 44 bool charging(); | |
| 45 double chargingTime(); | |
| 46 double dischargingTime(); | |
| 47 double level(); | |
| 48 | |
| 49 DEFINE_ATTRIBUTE_EVENT_LISTENER(chargingchange); | |
| 50 DEFINE_ATTRIBUTE_EVENT_LISTENER(chargingtimechange); | |
| 51 DEFINE_ATTRIBUTE_EVENT_LISTENER(dischargingtimechange); | |
| 52 DEFINE_ATTRIBUTE_EVENT_LISTENER(levelchange); | |
| 53 | |
| 54 void didChangeBatteryStatus(PassRefPtr<Event>, PassRefPtr<BatteryStatus>); | |
| 55 | |
| 56 using RefCounted<BatteryManager>::ref; | |
| 57 using RefCounted<BatteryManager>::deref; | |
| 58 | |
| 59 // ActiveDOMObject implementation. | |
| 60 virtual bool canSuspend() const { return true; } | |
| 61 virtual void suspend() OVERRIDE; | |
| 62 virtual void resume() OVERRIDE; | |
| 63 virtual void stop() OVERRIDE; | |
| 64 | |
| 65 protected: | |
| 66 virtual EventTargetData* eventTargetData() { return &m_eventTargetData; } | |
| 67 virtual EventTargetData& ensureEventTargetData() { return m_eventTargetData; } | |
| 68 | |
| 69 private: | |
| 70 explicit BatteryManager(Navigator*); | |
| 71 explicit BatteryManager(Frame*); | |
| 72 | |
| 73 // EventTarget implementation. | |
| 74 virtual void refEventTarget() { ref(); } | |
| 75 virtual void derefEventTarget() { deref(); } | |
| 76 | |
| 77 EventTargetData m_eventTargetData; | |
| 78 RefPtr<BatteryStatus> m_batteryStatus; | |
| 79 }; | |
| 80 | |
| 81 } | |
| 82 | |
| 83 #endif // BatteryManager_h | |
| 84 | |
| OLD | NEW |