| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "modules/wake_lock/ScreenWakeLock.h" | 5 #include "modules/wake_lock/ScreenWakeLock.h" |
| 6 | 6 |
| 7 #include "core/dom/Document.h" | 7 #include "core/dom/Document.h" |
| 8 #include "core/frame/LocalFrame.h" | 8 #include "core/frame/LocalFrame.h" |
| 9 #include "core/frame/Screen.h" | 9 #include "core/frame/Screen.h" |
| 10 #include "core/page/PageVisibilityState.h" | 10 #include "core/page/PageVisibilityState.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 } | 56 } |
| 57 | 57 |
| 58 void ScreenWakeLock::contextDestroyed() | 58 void ScreenWakeLock::contextDestroyed() |
| 59 { | 59 { |
| 60 setKeepAwake(false); | 60 setKeepAwake(false); |
| 61 } | 61 } |
| 62 | 62 |
| 63 DEFINE_TRACE(ScreenWakeLock) | 63 DEFINE_TRACE(ScreenWakeLock) |
| 64 { | 64 { |
| 65 Supplement<LocalFrame>::trace(visitor); | 65 Supplement<LocalFrame>::trace(visitor); |
| 66 PageLifecycleObserver::trace(visitor); | 66 PageVisibilityObserver::trace(visitor); |
| 67 ContextLifecycleObserver::trace(visitor); | 67 ContextLifecycleObserver::trace(visitor); |
| 68 } | 68 } |
| 69 | 69 |
| 70 ScreenWakeLock::ScreenWakeLock(LocalFrame& frame) | 70 ScreenWakeLock::ScreenWakeLock(LocalFrame& frame) |
| 71 : ContextLifecycleObserver(frame.document()) | 71 : ContextLifecycleObserver(frame.document()) |
| 72 , PageLifecycleObserver(frame.page()) | 72 , PageVisibilityObserver(frame.page()) |
| 73 , m_keepAwake(false) | 73 , m_keepAwake(false) |
| 74 { | 74 { |
| 75 DCHECK(!m_service.is_bound()); | 75 DCHECK(!m_service.is_bound()); |
| 76 DCHECK(frame.serviceRegistry()); | 76 DCHECK(frame.serviceRegistry()); |
| 77 frame.serviceRegistry()->connectToRemoteService(mojo::GetProxy(&m_service)); | 77 frame.serviceRegistry()->connectToRemoteService(mojo::GetProxy(&m_service)); |
| 78 } | 78 } |
| 79 | 79 |
| 80 bool ScreenWakeLock::keepAwake() const | 80 bool ScreenWakeLock::keepAwake() const |
| 81 { | 81 { |
| 82 return m_keepAwake; | 82 return m_keepAwake; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 99 if (!m_service) | 99 if (!m_service) |
| 100 return; | 100 return; |
| 101 | 101 |
| 102 if (m_keepAwake && page() && page()->isPageVisible()) | 102 if (m_keepAwake && page() && page()->isPageVisible()) |
| 103 m_service->RequestWakeLock(); | 103 m_service->RequestWakeLock(); |
| 104 else | 104 else |
| 105 m_service->CancelWakeLock(); | 105 m_service->CancelWakeLock(); |
| 106 } | 106 } |
| 107 | 107 |
| 108 } // namespace blink | 108 } // namespace blink |
| OLD | NEW |