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

Side by Side Diff: third_party/WebKit/Source/core/html/AutoplayExperimentHelper.cpp

Issue 2191533003: Refactor Timer classes in preparation for landing FrameTimers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More build fixes Created 4 years, 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "core/html/AutoplayExperimentHelper.h" 5 #include "core/html/AutoplayExperimentHelper.h"
6 6
7 #include "core/dom/Document.h" 7 #include "core/dom/Document.h"
8 #include "core/frame/Settings.h" 8 #include "core/frame/Settings.h"
9 #include "core/html/HTMLMediaElement.h" 9 #include "core/html/HTMLMediaElement.h"
10 #include "core/page/Page.h" 10 #include "core/page/Page.h"
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 } 209 }
210 210
211 void AutoplayExperimentHelper::triggerAutoplayViewportCheckForTesting() 211 void AutoplayExperimentHelper::triggerAutoplayViewportCheckForTesting()
212 { 212 {
213 // Make sure that the last update appears to be sufficiently far in the 213 // Make sure that the last update appears to be sufficiently far in the
214 // past to appear that scrolling has stopped by now in viewportTimerFired. 214 // past to appear that scrolling has stopped by now in viewportTimerFired.
215 m_lastLocationUpdateTime = monotonicallyIncreasingTime() - kViewportTimerPol lDelay - 1; 215 m_lastLocationUpdateTime = monotonicallyIncreasingTime() - kViewportTimerPol lDelay - 1;
216 viewportTimerFired(nullptr); 216 viewportTimerFired(nullptr);
217 } 217 }
218 218
219 void AutoplayExperimentHelper::viewportTimerFired(Timer<AutoplayExperimentHelper >*) 219 void AutoplayExperimentHelper::viewportTimerFired(TimerBase*)
220 { 220 {
221 double now = monotonicallyIncreasingTime(); 221 double now = monotonicallyIncreasingTime();
222 double delta = now - m_lastLocationUpdateTime; 222 double delta = now - m_lastLocationUpdateTime;
223 if (delta < kViewportTimerPollDelay) { 223 if (delta < kViewportTimerPollDelay) {
224 // If we are not visible, then skip the timer. It will be started 224 // If we are not visible, then skip the timer. It will be started
225 // again if we become visible again. 225 // again if we become visible again.
226 if (m_wasInViewport) 226 if (m_wasInViewport)
227 m_viewportTimer.startOneShot(kViewportTimerPollDelay - delta, BLINK_ FROM_HERE); 227 m_viewportTimer.startOneShot(kViewportTimerPollDelay - delta, BLINK_ FROM_HERE);
228 228
229 return; 229 return;
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 { 531 {
532 return client().isHTMLVideoElement() && (enabled(IfViewport) || enabled(IfPa rtialViewport)); 532 return client().isHTMLVideoElement() && (enabled(IfViewport) || enabled(IfPa rtialViewport));
533 } 533 }
534 534
535 bool AutoplayExperimentHelper::isExperimentEnabled() 535 bool AutoplayExperimentHelper::isExperimentEnabled()
536 { 536 {
537 return m_mode != Mode::ExperimentOff; 537 return m_mode != Mode::ExperimentOff;
538 } 538 }
539 539
540 } // namespace blink 540 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/AutoplayExperimentHelper.h ('k') | third_party/WebKit/Source/core/html/HTMLMediaElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698