Chromium Code Reviews| Index: Source/core/loader/LinkLoader.cpp |
| diff --git a/Source/core/loader/LinkLoader.cpp b/Source/core/loader/LinkLoader.cpp |
| index d7156b9dc29836fce698f50953e188e1b466d959..7a044d3b38cbc436483c63a070e366a2228bb7b8 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. |
| + return Resource::Raw; |
|
Mike West
2015/04/07 06:26:28
Where is this used? Could we use request contexts
Yoav Weiss
2015/04/07 07:26:14
It's used by ResourceFetcher to determine context
Mike West
2015/04/07 12:23:01
Hrm. Ok. That seems strange. I wouldn't block you
|
| +} |
| + |
| +void LinkLoader::preloadIfNeeded(const LinkRelAttribute& relAttribute, const KURL& href, Document& document, const String& as) |
| +{ |
|
Mike West
2015/04/07 06:26:28
ASSERT that the runtime flag is enabled?
Yoav Weiss
2015/04/07 07:26:14
There's one a few lines below. I'll bump it up for
Mike West
2015/04/07 12:23:01
You're right, sorry. My eyes are obviously broken.
|
| + if (relAttribute.isLinkPreload() && href.isValid()) { |
| + FetchRequest linkRequest(ResourceRequest(document.completeURL(href)), FetchInitiatorTypeNames::link); |
| + Resource::Type type = getTypeFromAsAttribute(as); |
| + ASSERT(RuntimeEnabledFeatures::linkPreloadEnabled()); |
| + 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()) |