Chromium Code Reviews| Index: Source/core/html/parser/HTMLResourcePreloader.cpp |
| diff --git a/Source/core/html/parser/HTMLResourcePreloader.cpp b/Source/core/html/parser/HTMLResourcePreloader.cpp |
| index 85d914aa64553719e8a5ca14e102a5d5566ee227..1a0314e17beffd395e40421cf2c9853e6779dfe0 100644 |
| --- a/Source/core/html/parser/HTMLResourcePreloader.cpp |
| +++ b/Source/core/html/parser/HTMLResourcePreloader.cpp |
| @@ -29,6 +29,7 @@ |
| #include "core/dom/Document.h" |
| #include "core/fetch/FetchInitiatorInfo.h" |
| #include "core/fetch/ResourceFetcher.h" |
| +#include "platform/network/NetworkHints.h" |
| #include "public/platform/Platform.h" |
| namespace blink { |
| @@ -48,8 +49,29 @@ DEFINE_TRACE(HTMLResourcePreloader) |
| visitor->trace(m_document); |
| } |
| +static void preconnectHost(PreloadRequest* request) |
| +{ |
| + ASSERT(request); |
| + ASSERT(request->isPreconnect()); |
| + KURL host(request->baseURL(), request->resourceURL()); |
| + if (!host.isValid()) |
|
Mike West
2015/06/03 09:02:27
Perhaps add `!host.protocolIsInHTTPFamily()`? We w
|
| + return; |
| + CrossOriginAttributeValue crossOrigin = CrossOriginAttributeNotSet; |
| + if (request->isCORS()) { |
| + if (request->isAllowCredentials()) |
| + crossOrigin = CrossOriginAttributeUseCredentials; |
|
Mike West
2015/06/03 09:02:27
Looking at this again, what does this actually mea
|
| + else |
| + crossOrigin = CrossOriginAttributeAnonymous; |
| + } |
| + preconnect(host, crossOrigin); |
| +} |
| + |
| void HTMLResourcePreloader::preload(PassOwnPtr<PreloadRequest> preload) |
| { |
| + if (preload->isPreconnect()) { |
| + preconnectHost(preload.get()); |
| + return; |
| + } |
| FetchRequest request = preload->resourceRequest(m_document); |
| Platform::current()->histogramCustomCounts("WebCore.PreloadDelayMs", static_cast<int>(1000 * (monotonicallyIncreasingTime() - preload->discoveryTime())), 0, 2000, 20); |
| m_document->fetcher()->preload(preload->resourceType(), request, preload->charset()); |