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 |