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

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

Issue 2174263002: Defer loads in new pages/frames if ScopedPageLoadDeferral is active (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Simplify Created 4 years, 5 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/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

Powered by Google App Engine
This is Rietveld 408576698