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

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 NeedsRebaseline for 4 tests for Mac. Created 6 years, 9 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..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
+

Powered by Google App Engine
This is Rietveld 408576698