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

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: Removed preconnector. Passing preconnects through main thread. 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
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());

Powered by Google App Engine
This is Rietveld 408576698