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

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 useless dumpAsText from frames 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
« no previous file with comments | « Source/core/loader/LinkLoader.h ('k') | Source/core/testing/InternalSettings.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/loader/LinkLoader.cpp
diff --git a/Source/core/loader/LinkLoader.cpp b/Source/core/loader/LinkLoader.cpp
index 3a928f86edaef55ee6664c857ebe889ae7ba490d..feb23bd3d900f82ec534be2fc9cd198251cf1b41 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,28 @@ bool LinkLoader::loadLink(const LinkRelAttribute& relAttribute, const AtomicStri
prefetchDNS(href.host());
}
}
+}
+
+bool LinkLoader::loadLinkFromHeader(const String& headerValue, Document* document)
+{
+ if (!document)
+ return false;
+ LinkHeaderSet headerSet(headerValue);
+ for (auto& header : headerSet) {
+ if (!header.valid() || header.url().isEmpty() || header.rel().isEmpty())
+ return false;
+ LinkRelAttribute relAttribute(header.rel());
+ 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);
« no previous file with comments | « Source/core/loader/LinkLoader.h ('k') | Source/core/testing/InternalSettings.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698