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

Unified 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, 10 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 side-by-side diff with in-line comments
Download patch
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
+

Powered by Google App Engine
This is Rietveld 408576698