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

Unified Diff: third_party/WebKit/Source/core/page/Page.cpp

Issue 1477353002: Revert of Move throttling of background timers into the renderer scheduler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/page/Page.cpp
diff --git a/third_party/WebKit/Source/core/page/Page.cpp b/third_party/WebKit/Source/core/page/Page.cpp
index 3ec85f1254f91bb4ac9abccee16d1df793bf00e3..dac637d20e4d5dcfc021aebc504f1456fbc2820e 100644
--- a/third_party/WebKit/Source/core/page/Page.cpp
+++ b/third_party/WebKit/Source/core/page/Page.cpp
@@ -117,6 +117,7 @@
, m_tabKeyCyclesThroughElements(true)
, m_defersLoading(false)
, m_deviceScaleFactor(1)
+ , m_timerAlignmentInterval(DOMTimer::visiblePageAlignmentInterval())
, m_visibilityState(PageVisibilityStateVisible)
, m_isCursorVisible(true)
#if ENABLE(ASSERT)
@@ -355,15 +356,41 @@
}
}
+void Page::setTimerAlignmentInterval(double interval)
+{
+ if (interval == m_timerAlignmentInterval)
+ return;
+
+ m_timerAlignmentInterval = interval;
+ for (Frame* frame = mainFrame(); frame; frame = frame->tree().traverseNextWithWrap(false)) {
+ if (!frame->isLocalFrame())
+ continue;
+
+ if (Document* document = toLocalFrame(frame)->document()) {
+ if (DOMTimerCoordinator* timers = document->timers()) {
+ timers->didChangeTimerAlignmentInterval();
+ }
+ }
+ }
+}
+
+double Page::timerAlignmentInterval() const
+{
+ return m_timerAlignmentInterval;
+}
+
void Page::setVisibilityState(PageVisibilityState visibilityState, bool isInitialState)
{
if (m_visibilityState == visibilityState)
return;
m_visibilityState = visibilityState;
+ // TODO(alexclarke): Move throttling of timers to chromium.
if (visibilityState == PageVisibilityStateVisible) {
+ setTimerAlignmentInterval(DOMTimer::visiblePageAlignmentInterval());
memoryPurgeController().pageBecameActive();
} else {
+ setTimerAlignmentInterval(DOMTimer::hiddenPageAlignmentInterval());
if (!isInitialState)
memoryPurgeController().pageBecameInactive();
}
« no previous file with comments | « third_party/WebKit/Source/core/page/Page.h ('k') | third_party/WebKit/Source/core/testing/NullExecutionContext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698