Index: third_party/WebKit/Source/core/page/ScopedPageLoadDeferrer.cpp |
diff --git a/third_party/WebKit/Source/core/page/ScopedPageLoadDeferrer.cpp b/third_party/WebKit/Source/core/page/ScopedPageLoadDeferrer.cpp |
index c247c9985db4a237789d2a3c3af7ac0954228755..be85168aa42537058c73dbf285db5754b4cd3d53 100644 |
--- a/third_party/WebKit/Source/core/page/ScopedPageLoadDeferrer.cpp |
+++ b/third_party/WebKit/Source/core/page/ScopedPageLoadDeferrer.cpp |
@@ -21,22 +21,32 @@ |
#include "core/page/ScopedPageLoadDeferrer.h" |
#include "core/dom/Document.h" |
-#include "core/frame/LocalFrame.h" |
#include "core/loader/FrameLoader.h" |
#include "core/page/Page.h" |
+#include "platform/heap/Handle.h" |
#include "public/platform/Platform.h" |
#include "public/platform/WebScheduler.h" |
-#include "wtf/HashSet.h" |
+#include "wtf/StdLibExtras.h" |
+#include "wtf/Vector.h" |
namespace blink { |
-ScopedPageLoadDeferrer::ScopedPageLoadDeferrer(Page* exclusion) |
+namespace { |
+ |
+unsigned s_deferralCount = 0; |
+ |
+void setDefersLoading(bool isDeferred) |
+{ |
+ for (const auto& page : Page::ordinaryPages()) |
+ page->setDefersLoading(isDeferred); |
+} |
+ |
+} // namespace |
+ |
+ScopedPageLoadDeferrer::ScopedPageLoadDeferrer() |
{ |
- for (Page* page : Page::ordinaryPages()) { |
- if (page == exclusion || page->defersLoading()) |
- continue; |
- m_deferredPages.append(page); |
- } |
+ if (++s_deferralCount > 1) |
+ return; |
setDefersLoading(true); |
Platform::current()->currentThread()->scheduler()->suspendTimerQueue(); |
@@ -44,15 +54,16 @@ ScopedPageLoadDeferrer::ScopedPageLoadDeferrer(Page* exclusion) |
ScopedPageLoadDeferrer::~ScopedPageLoadDeferrer() |
{ |
+ if (--s_deferralCount > 0) |
+ return; |
+ |
setDefersLoading(false); |
Platform::current()->currentThread()->scheduler()->resumeTimerQueue(); |
} |
-void ScopedPageLoadDeferrer::setDefersLoading(bool isDeferred) |
+bool ScopedPageLoadDeferrer::isActive() |
{ |
- |
- for (const auto& page : m_deferredPages) |
- page->setDefersLoading(isDeferred); |
+ return s_deferralCount > 0; |
} |
} // namespace blink |