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

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: actually include crasher fix Created 4 years, 7 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 dff65e3e298a299c93a3726db1ac60920224bcfb..3dcea668a0752766d238bd8220f76ba26c7e2dd6 100644
--- a/third_party/WebKit/Source/core/html/parser/HTMLResourcePreloader.cpp
+++ b/third_party/WebKit/Source/core/html/parser/HTMLResourcePreloader.cpp
@@ -26,6 +26,7 @@
#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/loader/DocumentLoader.h"
@@ -49,6 +50,13 @@ DEFINE_TRACE(HTMLResourcePreloader)
visitor->trace(m_document);
}
+int HTMLResourcePreloader::countPreloads()
+{
+ if (m_document->loader())
+ return m_document->loader()->fetcher()->countPreloads();
+ return 0;
+}
+
static void preconnectHost(PreloadRequest* request, const NetworkHintsInterface& networkHintsInterface)
{
ASSERT(request);
@@ -79,7 +87,15 @@ void HTMLResourcePreloader::preload(PassOwnPtr<PreloadRequest> preload, const Ne
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) {
+ OwnPtr<CSSPreloaderResourceClient> client = adoptPtr(new CSSPreloaderResourceClient(resource, this));
+ resource->addClient(client.get(), true /* passive */);
+ m_cssPreloaders.add(std::move(client));
+ }
}
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698