OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef ScreenWakeLock_h |
| 6 #define ScreenWakeLock_h |
| 7 |
| 8 #include "core/frame/LocalFrameLifecycleObserver.h" |
| 9 #include "core/page/PageLifecycleObserver.h" |
| 10 #include "modules/ModulesExport.h" |
| 11 #include "wtf/Noncopyable.h" |
| 12 |
| 13 namespace blink { |
| 14 |
| 15 class LocalFrame; |
| 16 class Screen; |
| 17 class WebWakeLockClient; |
| 18 |
| 19 class MODULES_EXPORT ScreenWakeLock final : public NoBaseWillBeGarbageCollected<
ScreenWakeLock>, public WillBeHeapSupplement<LocalFrame>, public PageLifecycleOb
server, public LocalFrameLifecycleObserver { |
| 20 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(ScreenWakeLock); |
| 21 WTF_MAKE_NONCOPYABLE(ScreenWakeLock); |
| 22 public: |
| 23 static bool keepAwake(Screen&); |
| 24 static void setKeepAwake(Screen&, bool); |
| 25 |
| 26 bool keepAwake() const { return m_keepAwake; } |
| 27 void setKeepAwake(bool); |
| 28 |
| 29 static const char* supplementName(); |
| 30 static ScreenWakeLock* from(LocalFrame*); |
| 31 static void provideTo(LocalFrame&, WebWakeLockClient*); |
| 32 |
| 33 // Inherited from PageLifecycleObserver. |
| 34 void pageVisibilityChanged() override; |
| 35 void didCommitLoad(LocalFrame*) override; |
| 36 |
| 37 // Inherited from LocalFrameLifecycleObserver. |
| 38 void willDetachFrameHost() override; |
| 39 |
| 40 DECLARE_VIRTUAL_TRACE(); |
| 41 |
| 42 private: |
| 43 ScreenWakeLock(LocalFrame&, WebWakeLockClient*); |
| 44 |
| 45 static ScreenWakeLock* fromScreen(Screen&); |
| 46 void notifyClient(); |
| 47 |
| 48 WebWakeLockClient* m_client; |
| 49 bool m_keepAwake; |
| 50 }; |
| 51 |
| 52 } // namespace blink |
| 53 |
| 54 #endif // ScreenWakeLock_h |
OLD | NEW |