Chromium Code Reviews| 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..b428b549f237994cbc37d7e89e17743e6d99d619 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 (Page* page : Page::ordinaryPages()) { |
| - if (page == exclusion || page->defersLoading()) |
| - continue; |
| - m_deferredPages.append(page); |
| - } |
| + for (const auto& page : Page::ordinaryPages()) |
| + page->setDefersLoading(isDeferred); |
| +} |
| + |
| +} // namespace |
| + |
| +ScopedPageLoadDeferrer::ScopedPageLoadDeferrer() |
| +{ |
| + if (++s_deferralCount > 1) |
| + return; |
| setDefersLoading(true); |
| Platform::current()->currentThread()->scheduler()->suspendTimerQueue(); |
| @@ -44,15 +54,15 @@ ScopedPageLoadDeferrer::ScopedPageLoadDeferrer(Page* exclusion) |
| ScopedPageLoadDeferrer::~ScopedPageLoadDeferrer() |
| { |
| - setDefersLoading(false); |
| - Platform::current()->currentThread()->scheduler()->resumeTimerQueue(); |
| + if (--s_deferralCount == 0) { |
|
Nate Chapin
2016/07/27 17:30:47
Nit: it bothers my sense of aesthetics that the co
dcheng
2016/07/28 01:23:28
Done.
|
| + 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 |