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

Unified Diff: third_party/WebKit/Source/core/html/parser/HTMLResourcePreloader.cpp

Issue 1976463003: Preload scan external CSS for @import (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: preload @import 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/html/parser/HTMLResourcePreloader.cpp
diff --git a/third_party/WebKit/Source/core/html/parser/HTMLResourcePreloader.cpp b/third_party/WebKit/Source/core/html/parser/HTMLResourcePreloader.cpp
index 1b6b6692b68e02a2ccc20f5d2c95994136b22fde..6f3f5dfe78c820765d5df0abe6e7405a27544fd8 100644
--- a/third_party/WebKit/Source/core/html/parser/HTMLResourcePreloader.cpp
+++ b/third_party/WebKit/Source/core/html/parser/HTMLResourcePreloader.cpp
@@ -26,8 +26,10 @@
#include "core/html/parser/HTMLResourcePreloader.h"
#include "core/dom/Document.h"
+#include "core/fetch/CSSStyleSheetResource.h"
#include "core/fetch/FetchInitiatorInfo.h"
#include "core/fetch/ResourceFetcher.h"
+#include "core/frame/Settings.h"
#include "core/loader/DocumentLoader.h"
#include "platform/Histogram.h"
#include "public/platform/Platform.h"
@@ -48,6 +50,14 @@ HTMLResourcePreloader* HTMLResourcePreloader::create(Document& document)
DEFINE_TRACE(HTMLResourcePreloader)
{
visitor->trace(m_document);
+ visitor->trace(m_cssPreloaders);
+}
+
+int HTMLResourcePreloader::countPreloads()
+{
+ if (m_document->loader())
+ return m_document->loader()->fetcher()->countPreloads();
+ return 0;
}
static void preconnectHost(PreloadRequest* request, const NetworkHintsInterface& networkHintsInterface)
@@ -80,7 +90,19 @@ void HTMLResourcePreloader::preload(std::unique_ptr<PreloadRequest> preload, con
int duration = static_cast<int>(1000 * (monotonicallyIncreasingTime() - preload->discoveryTime()));
DEFINE_STATIC_LOCAL(CustomCountHistogram, preloadDelayHistogram, ("WebCore.PreloadDelayMs", 0, 2000, 20));
preloadDelayHistogram.count(duration);
- m_document->loader()->startPreload(preload->resourceType(), request);
+
+ Resource* resource = m_document->loader()->startPreload(preload->resourceType(), request);
+ // Note that if the cssExternalScanner{Preload,NoPreload} settings flags are
+ // not set, this resource client does nothing.
+ if (resource && preload->resourceType() == Resource::CSSStyleSheet) {
+ Settings* settings = m_document->settings();
+ if (!settings)
+ return;
+ if (!settings->cssExternalScannerNoPreload() && !settings->cssExternalScannerPreload()) {
+ return;
+ }
+ m_cssPreloaders.add(new CSSPreloaderResourceClient(resource, this));
+ }
}
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698