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

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

Issue 1152043005: Add <link rel=preconnect> support to the HTMLPreloadScanner (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Added HTTP family test Created 5 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
« no previous file with comments | « Source/core/html/parser/HTMLPreloadScannerTest.cpp ('k') | Source/core/html/parser/PreloadRequest.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..cc3dbcd75366c34545a48a7ff6df8331e135db44 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() || !host.protocolIsInHTTPFamily())
+ return;
+ CrossOriginAttributeValue crossOrigin = CrossOriginAttributeNotSet;
+ if (request->isCORS()) {
+ if (request->isAllowCredentials())
+ crossOrigin = CrossOriginAttributeUseCredentials;
+ 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());
« no previous file with comments | « Source/core/html/parser/HTMLPreloadScannerTest.cpp ('k') | Source/core/html/parser/PreloadRequest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698