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

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: Make the unfortunate hack slightly less ugly. 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..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
« no previous file with comments | « third_party/WebKit/Source/core/page/ScopedPageLoadDeferrer.h ('k') | third_party/WebKit/Source/web/tests/WebViewTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698