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

Unified Diff: Source/modules/wake_lock/WakeLock.h

Issue 1084923002: Wake Lock API implementation (Blink part) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Applied review comments Created 5 years, 7 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/wake_lock/WakeLock.h
diff --git a/Source/modules/wake_lock/WakeLock.h b/Source/modules/wake_lock/WakeLock.h
new file mode 100644
index 0000000000000000000000000000000000000000..61d0e61349d946c3cb57a8804bcb5023b349e13c
--- /dev/null
+++ b/Source/modules/wake_lock/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/page/PageVisibilityState.h"
+#include "modules/wake_lock/WakeLockController.h"
+#include "platform/heap/Handle.h"
+
+namespace blink {
+
+class Document;
+
+class WakeLock final
+ : public NoBaseWillBeGarbageCollectedFinalized<WakeLock>
+ , public DocumentSupplement
+ , public DocumentLifecycleObserver {
+ WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(WakeLock);
mlamouri (slow - plz ping) 2015/05/05 13:45:44 WTF_MAKE_NONCOPYABLE?
+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.
+ OwnPtrWillBeMember<WakeLockDocumentVisibilityObserver> m_observer;
+
+ PageVisibilityState m_pageVisibilityState;
+ bool m_keepScreenAwake;
+};
+
+} // namespace blink
+
+#endif // WakeLock_h

Powered by Google App Engine
This is Rietveld 408576698