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

Unified Diff: Source/core/dom/WakeLock.h

Issue 1084923002: Wake Lock API implementation (Blink part) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 8 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/core/dom/WakeLock.h
diff --git a/Source/core/dom/WakeLock.h b/Source/core/dom/WakeLock.h
new file mode 100644
index 0000000000000000000000000000000000000000..fab2c3e2a0ebfcb4c8328a48aee7965ce053c656
--- /dev/null
+++ b/Source/core/dom/WakeLock.h
@@ -0,0 +1,59 @@
+// Copyright 2015 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 WakeLock_h
+#define WakeLock_h
+
+#include "core/dom/DocumentLifecycleObserver.h"
+#include "core/dom/DocumentSupplementable.h"
+#include "core/dom/WakeLockController.h"
+#include "core/page/PageVisibilityState.h"
+#include "platform/heap/Handle.h"
+
+namespace blink {
+
+class Document;
+
+class WakeLock final
+ : public NoBaseWillBeGarbageCollectedFinalized<WakeLock>
+ , public DocumentSupplement
mlamouri (slow - plz ping) 2015/04/28 08:00:25 Hmmm, why do you have a Document supplement and a
alogvinov 2015/04/28 16:34:25 WakeLock stores the state of keepScreenAwake flag.
mlamouri (slow - plz ping) 2015/04/29 10:07:08 Couldn't WakeLockDocument rely on the value stored
alogvinov 2015/04/29 16:50:59 Those properties are read-only. keepScreenAwake is
mlamouri (slow - plz ping) 2015/04/30 13:15:38 Fair point. Though, I wonder if we would be okay w
+ , public DocumentLifecycleObserver {
+ WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(WakeLock);
+public:
+ static const char* supplementName();
+ static WakeLock& from(Document&);
+
+ static bool keepScreenAwake(Document&);
+ static void setKeepScreenAwake(Document&, bool);
+
+ // DocumentLifecycleObserver implementation
+ virtual void documentWasDetached() override;
+
+ DECLARE_VIRTUAL_TRACE();
+
+private:
+ class WakeLockDocumentVisibilityObserver;
+
+ explicit WakeLock(Document&);
+
+ void didChangeVisibilityState(PageVisibilityState);
+ void setKeepScreenAwake(bool);
+ void notifyController() const;
+
+ RawPtrWillBeMember<WakeLockController> m_controller;
+
+ // We need visibility observer as a member rather than as a base becasue
+ // when Oilpan is disabled, we need to be able to delete it before
+ // Document's destructor runs, as it asserts empty visibility observer list.
+ // This instance is owned by Document's base DocumentSupplementable, so
+ // it will be destroyed only after Document's destructor has finished.
mlamouri (slow - plz ping) 2015/04/28 08:00:25 I'm not sure I follow. How is HTMLCanvasElement do
alogvinov 2015/04/28 16:34:25 HTMLCanvasElement is an HTMLElement, i.e. it is pa
mlamouri (slow - plz ping) 2015/04/29 10:07:08 Ok. I see. Maybe we should have a way to clear the
+ OwnPtrWillBeMember<WakeLockDocumentVisibilityObserver> m_observer;
+
+ PageVisibilityState m_pageVisibilityState;
+ bool m_keepScreenAwake;
+};
+
+} // namespace blink
+
+#endif // WakeLock_h

Powered by Google App Engine
This is Rietveld 408576698