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 |