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()) |