Chromium Code Reviews| Index: Source/modules/battery/BatteryManager.h |
| diff --git a/Source/modules/battery/BatteryManager.h b/Source/modules/battery/BatteryManager.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..3aa08c6244e8ab2d506b7395733efc02d6bbaa03 |
| --- /dev/null |
| +++ b/Source/modules/battery/BatteryManager.h |
| @@ -0,0 +1,67 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef BatteryManager_h |
| +#define BatteryManager_h |
| + |
| +#include "core/dom/ActiveDOMObject.h" |
| +#include "core/events/EventTarget.h" |
| +#include "core/frame/Frame.h" |
| +#include "modules/battery/BatteryStatus.h" |
| + |
| +namespace WebCore { |
| + |
| +class Navigator; |
| +class ScriptExecutionContext; |
| + |
| +class BatteryManager : public ActiveDOMObject, public RefCounted<BatteryManager>, public EventTarget { |
|
abarth-chromium
2014/02/28 06:45:14
Please remove the ActiveDOMObject base class. It'
|
| +public: |
| + virtual ~BatteryManager(); |
| + static PassRefPtr<BatteryManager> create(Frame*); |
|
abarth-chromium
2014/02/28 06:45:14
This should probably be constructed from a Documen
|
| + |
| + // EventTarget implementation. |
| + virtual const WTF::AtomicString& interfaceName() const { return EventTargetNames::BatteryManager; } |
| + virtual ExecutionContext* executionContext() const OVERRIDE FINAL { return ActiveDOMObject::executionContext(); } |
|
abarth-chromium
2014/02/28 06:45:14
The reason you should use a Document as the contex
|
| + |
| + bool charging(); |
| + double chargingTime(); |
| + double dischargingTime(); |
| + double level(); |
| + |
| + DEFINE_ATTRIBUTE_EVENT_LISTENER(chargingchange); |
| + DEFINE_ATTRIBUTE_EVENT_LISTENER(chargingtimechange); |
| + DEFINE_ATTRIBUTE_EVENT_LISTENER(dischargingtimechange); |
| + DEFINE_ATTRIBUTE_EVENT_LISTENER(levelchange); |
| + |
| + void didChangeBatteryStatus(PassRefPtr<Event>, PassOwnPtr<BatteryStatus>); |
| + |
| + using RefCounted<BatteryManager>::ref; |
| + using RefCounted<BatteryManager>::deref; |
| + |
| + // ActiveDOMObject implementation. |
| + virtual bool canSuspend() const { return true; } |
| + virtual void suspend() OVERRIDE; |
| + virtual void resume() OVERRIDE; |
| + virtual void stop() OVERRIDE; |
| + |
| +protected: |
| + virtual EventTargetData* eventTargetData() { return &m_eventTargetData; } |
| + virtual EventTargetData& ensureEventTargetData() { return m_eventTargetData; } |
| + |
| +private: |
| + explicit BatteryManager(Navigator*); |
| + explicit BatteryManager(Frame*); |
|
abarth-chromium
2014/02/28 06:45:14
You've still got two constructors. You only need
|
| + |
| + // EventTarget implementation. |
| + virtual void refEventTarget() { ref(); } |
| + virtual void derefEventTarget() { deref(); } |
| + |
| + EventTargetData m_eventTargetData; |
| + OwnPtr<BatteryStatus> m_batteryStatus; |
| +}; |
| + |
| +} |
| + |
| +#endif // BatteryManager_h |
| + |