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

Unified Diff: third_party/WebKit/Source/core/dom/DocumentLifecycle.cpp

Issue 1364063007: Throttle rendering pipeline for invisible frames (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix typo in comment. Created 5 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/dom/DocumentLifecycle.cpp
diff --git a/third_party/WebKit/Source/core/dom/DocumentLifecycle.cpp b/third_party/WebKit/Source/core/dom/DocumentLifecycle.cpp
index efc1b4b99a161bf0e73e1faf24b2430f7a210383..bb39efdae2d6593659b5ff44066ce543c4e09237 100644
--- a/third_party/WebKit/Source/core/dom/DocumentLifecycle.cpp
+++ b/third_party/WebKit/Source/core/dom/DocumentLifecycle.cpp
@@ -38,6 +38,10 @@ namespace blink {
static DocumentLifecycle::DeprecatedTransition* s_deprecatedTransitionStack = 0;
+// TODO(skyostil): Come up with a better way to store cross-frame lifecycle
+// related data to avoid this being a global setting.
+static unsigned s_preventThrottlingCount = 0;
+
DocumentLifecycle::Scope::Scope(DocumentLifecycle& lifecycle, State finalState)
: m_lifecycle(lifecycle)
, m_finalState(finalState)
@@ -62,6 +66,17 @@ DocumentLifecycle::DeprecatedTransition::~DeprecatedTransition()
s_deprecatedTransitionStack = m_previous;
}
+DocumentLifecycle::PreventThrottlingScope::PreventThrottlingScope(DocumentLifecycle& lifecycle)
+ : m_lifecycle(lifecycle)
+{
+ m_lifecycle.incrementPreventThrottlingCount();
esprehn 2015/10/16 21:40:45 if you're going to put these out of line you don't
Sami 2015/10/19 10:51:06 Ah, of course. Done.
+}
+
+DocumentLifecycle::PreventThrottlingScope::~PreventThrottlingScope()
+{
+ m_lifecycle.decrementPreventThrottlingCount();
+}
+
DocumentLifecycle::DocumentLifecycle()
: m_state(Uninitialized)
, m_detachCount(0)
@@ -291,6 +306,22 @@ void DocumentLifecycle::ensureStateAtMost(State state)
m_state = state;
}
+void DocumentLifecycle::incrementPreventThrottlingCount()
+{
+ s_preventThrottlingCount++;
+}
+
+void DocumentLifecycle::decrementPreventThrottlingCount()
+{
+ ASSERT(s_preventThrottlingCount > 0);
+ s_preventThrottlingCount--;
+}
+
+bool DocumentLifecycle::throttlingAllowed() const
+{
+ return !s_preventThrottlingCount;
+}
+
#if ENABLE(ASSERT)
#define DEBUG_STRING_CASE(StateName) \
case StateName: return #StateName

Powered by Google App Engine
This is Rietveld 408576698