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..573a8f95b8cc71687dad8ca97ed44c7c0c02757d |
--- /dev/null |
+++ b/Source/modules/battery/BatteryManager.h |
@@ -0,0 +1,59 @@ |
+// 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/ContextLifecycleObserver.h" |
+#include "core/dom/Document.h" |
+#include "core/events/EventTarget.h" |
+#include "modules/battery/BatteryStatus.h" |
+ |
+namespace WebCore { |
+ |
+class Navigator; |
+ |
+class BatteryManager : public ContextLifecycleObserver, public RefCounted<BatteryManager>, public EventTarget { |
Inactive
2014/03/06 13:45:39
I believe you can subclass EventTargetWithInlineDa
|
+public: |
Inactive
2014/03/06 13:45:39
REFCOUNTED_EVENT_TARGET(BatteryManager);
|
+ virtual ~BatteryManager(); |
+ static PassRefPtr<BatteryManager> create(ExecutionContext*); |
+ |
+ // EventTarget implementation. |
+ virtual const WTF::AtomicString& interfaceName() const { return EventTargetNames::BatteryManager; } |
+ virtual ExecutionContext* executionContext() const OVERRIDE FINAL { return ContextLifecycleObserver::executionContext(); } |
Inactive
2014/03/06 13:45:39
Don't need the FINAL here if you mark the class as
|
+ |
+ 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; |
Inactive
2014/03/06 13:45:39
Not needed if you use the macro I suggested.
|
+ using RefCounted<BatteryManager>::deref; |
Inactive
2014/03/06 13:45:39
Not needed if you use the macro I suggested.
|
+ |
+protected: |
+ virtual EventTargetData* eventTargetData() { return &m_eventTargetData; } |
Inactive
2014/03/06 13:45:39
Not needed if you subclass EventTargetWithInlineDa
|
+ virtual EventTargetData& ensureEventTargetData() { return m_eventTargetData; } |
Inactive
2014/03/06 13:45:39
Not needed if you subclass EventTargetWithInlineDa
|
+ |
+private: |
+ explicit BatteryManager(ExecutionContext*); |
+ |
+ // EventTarget implementation. |
Inactive
2014/03/06 13:45:39
Those 2 methods are not needed if you use the macr
|
+ virtual void refEventTarget() { ref(); } |
+ virtual void derefEventTarget() { deref(); } |
+ |
+ EventTargetData m_eventTargetData; |
Inactive
2014/03/06 13:45:39
Not needed if you subclass EventTargetWithInlineDa
|
+ OwnPtr<BatteryStatus> m_batteryStatus; |
+}; |
+ |
+} |
+ |
+#endif // BatteryManager_h |
+ |