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

Unified Diff: Source/core/loader/LinkLoader.cpp

Issue 788923003: Adding Link header support for dns-prefetch (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Removed apache config Created 5 years, 10 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/loader/LinkLoader.cpp
diff --git a/Source/core/loader/LinkLoader.cpp b/Source/core/loader/LinkLoader.cpp
index 3a928f86edaef55ee6664c857ebe889ae7ba490d..78c2e5a1038fb6d8a0033ccb617d17d433761c1e 100644
--- a/Source/core/loader/LinkLoader.cpp
+++ b/Source/core/loader/LinkLoader.cpp
@@ -113,7 +113,7 @@ void LinkLoader::didSendDOMContentLoadedForPrerender()
m_client->didSendDOMContentLoadedForLinkPrerender();
}
-bool LinkLoader::loadLink(const LinkRelAttribute& relAttribute, const AtomicString& crossOriginMode, const String& type, const KURL& href, Document& document)
+static void dnsPrefetchIfNeeded(const LinkRelAttribute& relAttribute, const KURL& href, Document& document)
{
if (relAttribute.isDNSPrefetch()) {
Settings* settings = document.settings();
@@ -125,6 +125,26 @@ bool LinkLoader::loadLink(const LinkRelAttribute& relAttribute, const AtomicStri
prefetchDNS(href.host());
}
}
+}
+
+bool LinkLoader::loadLinkFromHeader(const String& headerValue, Document* document)
+{
+ if (!document)
+ return false;
+ LinkHeader header(headerValue);
+ if (!header.valid() || header.url().isEmpty() || header.rel().isEmpty())
+ return false;
+ LinkRelAttribute relAttribute(header.rel());
Mike West 2015/02/06 12:22:06 Can you add a test (or FIXME) for multiple link he
+ KURL url = document->completeURL(header.url());
+ dnsPrefetchIfNeeded(relAttribute, url, *document);
+
+ // FIXME: Add more supported headers as needed.
+ return true;
+}
+
+bool LinkLoader::loadLink(const LinkRelAttribute& relAttribute, const AtomicString& crossOriginMode, const String& type, const KURL& href, Document& document)
+{
+ dnsPrefetchIfNeeded(relAttribute, href, document);
if (relAttribute.isPreconnect() && href.isValid()) {
preconnect(href);

Powered by Google App Engine
This is Rietveld 408576698