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

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

Issue 1060863003: Add initial link preload support (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Review comments Created 5 years, 8 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 d7156b9dc29836fce698f50953e188e1b466d959..28950e21748839503b6302807f3b56107b596a5c 100644
--- a/Source/core/loader/LinkLoader.cpp
+++ b/Source/core/loader/LinkLoader.cpp
@@ -138,6 +138,24 @@ static void preconnectIfNeeded(const LinkRelAttribute& relAttribute, const KURL&
}
}
+Resource::Type getTypeFromAsAttribute(const String& as)
+{
+ // FIXME: Add actual types here and make sure priorities work accordingly.
Mike West 2015/04/07 19:56:18 Nit: We spell this `TODO(yoav):` now...
+ return Resource::Raw;
+}
+
+void LinkLoader::preloadIfNeeded(const LinkRelAttribute& relAttribute, const KURL& href, Document& document, const String& as)
+{
+ if (relAttribute.isLinkPreload() && href.isValid()) {
Mike West 2015/04/07 19:56:18 https://w3c.github.io/preload/#fetch-settings says
+ ASSERT(RuntimeEnabledFeatures::linkPreloadEnabled());
+ FetchRequest linkRequest(ResourceRequest(document.completeURL(href)), FetchInitiatorTypeNames::link);
+ Resource::Type type = getTypeFromAsAttribute(as);
+ if (document.settings()->logPreload())
+ document.addConsoleMessage(ConsoleMessage::create(OtherMessageSource, DebugMessageLevel, String("Preload triggered for " + href.host() + href.path())));
+ setResource(document.fetcher()->fetchLinkPreloadResource(type, linkRequest));
+ }
+}
+
bool LinkLoader::loadLinkFromHeader(const String& headerValue, Document* document)
{
if (!document)
@@ -159,12 +177,15 @@ bool LinkLoader::loadLinkFromHeader(const String& headerValue, Document* documen
return true;
}
-bool LinkLoader::loadLink(const LinkRelAttribute& relAttribute, const AtomicString& crossOriginMode, const String& type, const KURL& href, Document& document)
+bool LinkLoader::loadLink(const LinkRelAttribute& relAttribute, const AtomicString& crossOriginMode, const String& type, const String& as, const KURL& href, Document& document)
{
+ // FIXME(crbug.com/463266): We're ignoring type here. Maybe we shouldn't.
dnsPrefetchIfNeeded(relAttribute, href, document);
preconnectIfNeeded(relAttribute, href, document);
+ preloadIfNeeded(relAttribute, href, document, as);
+
// FIXME(crbug.com/323096): Should take care of import.
if ((relAttribute.isLinkPrefetch() || relAttribute.isLinkSubresource() || relAttribute.isTransitionExitingStylesheet()) && href.isValid() && document.frame()) {
if (!m_client->shouldLoadLink())
« 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