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

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: 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..4dfcd0a0851efe3ea862a4a3cf88078b8c73d96b
--- /dev/null
+++ b/Source/modules/battery/BatteryManager.h
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2012 Samsung Electronics
+ * Copyright (C) 2014 Intel Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
abarth-chromium 2014/02/27 05:42:09 Please use this license for new files: http://dev
+
+#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 {
+public:
+ virtual ~BatteryManager();
+ static PassRefPtr<BatteryManager> create(Navigator*);
+ static PassRefPtr<BatteryManager> create(Frame*);
abarth-chromium 2014/02/27 05:42:09 Why are there two create functions? It seems like
+
+ // EventTarget implementation.
+ virtual const WTF::AtomicString& interfaceName() const { return EventTargetNames::BatteryManager; }
+ virtual ExecutionContext* executionContext() const OVERRIDE FINAL { return ActiveDOMObject::executionContext(); }
+
+ 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>, PassRefPtr<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*);
+
+ // EventTarget implementation.
+ virtual void refEventTarget() { ref(); }
+ virtual void derefEventTarget() { deref(); }
+
+ EventTargetData m_eventTargetData;
+ RefPtr<BatteryStatus> m_batteryStatus;
+};
+
+}
+
+#endif // BatteryManager_h
+

Powered by Google App Engine
This is Rietveld 408576698