 Chromium Code Reviews
 Chromium Code Reviews Issue 1084923002:
  Wake Lock API implementation (Blink part)  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/blink.git@master
    
  
    Issue 1084923002:
  Wake Lock API implementation (Blink part)  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/blink.git@master| 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 WakeLock_h | |
| 6 #define WakeLock_h | |
| 7 | |
| 8 #include "core/dom/DocumentLifecycleObserver.h" | |
| 9 #include "core/dom/DocumentSupplementable.h" | |
| 10 #include "core/dom/WakeLockController.h" | |
| 11 #include "core/page/PageVisibilityState.h" | |
| 12 #include "platform/heap/Handle.h" | |
| 13 | |
| 14 namespace blink { | |
| 15 | |
| 16 class Document; | |
| 17 | |
| 18 class WakeLock final | |
| 19 : public NoBaseWillBeGarbageCollectedFinalized<WakeLock> | |
| 20 , 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
 | |
| 21 , public DocumentLifecycleObserver { | |
| 22 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(WakeLock); | |
| 23 public: | |
| 24 static const char* supplementName(); | |
| 25 static WakeLock& from(Document&); | |
| 26 | |
| 27 static bool keepScreenAwake(Document&); | |
| 28 static void setKeepScreenAwake(Document&, bool); | |
| 29 | |
| 30 // DocumentLifecycleObserver implementation | |
| 31 virtual void documentWasDetached() override; | |
| 32 | |
| 33 DECLARE_VIRTUAL_TRACE(); | |
| 34 | |
| 35 private: | |
| 36 class WakeLockDocumentVisibilityObserver; | |
| 37 | |
| 38 explicit WakeLock(Document&); | |
| 39 | |
| 40 void didChangeVisibilityState(PageVisibilityState); | |
| 41 void setKeepScreenAwake(bool); | |
| 42 void notifyController() const; | |
| 43 | |
| 44 RawPtrWillBeMember<WakeLockController> m_controller; | |
| 45 | |
| 46 // We need visibility observer as a member rather than as a base becasue | |
| 47 // when Oilpan is disabled, we need to be able to delete it before | |
| 48 // Document's destructor runs, as it asserts empty visibility observer list. | |
| 49 // This instance is owned by Document's base DocumentSupplementable, so | |
| 50 // 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
 | |
| 51 OwnPtrWillBeMember<WakeLockDocumentVisibilityObserver> m_observer; | |
| 52 | |
| 53 PageVisibilityState m_pageVisibilityState; | |
| 54 bool m_keepScreenAwake; | |
| 55 }; | |
| 56 | |
| 57 } // namespace blink | |
| 58 | |
| 59 #endif // WakeLock_h | |
| OLD | NEW |