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

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

Issue 1602203005: Add use counter for preload link headers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 11 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 | « third_party/WebKit/Source/core/frame/UseCounter.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/loader/LinkLoader.cpp
diff --git a/third_party/WebKit/Source/core/loader/LinkLoader.cpp b/third_party/WebKit/Source/core/loader/LinkLoader.cpp
index 680a5ab1b4bbac2b09319e1b7b6c9d685e896b07..f29cc5e5001c93c50a76763e732ea4d70e06ac93 100644
--- a/third_party/WebKit/Source/core/loader/LinkLoader.cpp
+++ b/third_party/WebKit/Source/core/loader/LinkLoader.cpp
@@ -216,7 +216,7 @@ void LinkLoader::createLinkPreloadResourceClient(ResourcePtr<Resource> resource)
}
}
-static ResourcePtr<Resource> preloadIfNeeded(const LinkRelAttribute& relAttribute, const KURL& href, Document& document, const String& as)
+static ResourcePtr<Resource> preloadIfNeeded(const LinkRelAttribute& relAttribute, const KURL& href, Document& document, const String& as, LinkCaller caller)
{
if (!document.loader() || !relAttribute.isLinkPreload())
return nullptr;
@@ -227,6 +227,8 @@ static ResourcePtr<Resource> preloadIfNeeded(const LinkRelAttribute& relAttribut
document.addConsoleMessage(ConsoleMessage::create(OtherMessageSource, WarningMessageLevel, String("<link rel=preload> has an invalid `href` value")));
return nullptr;
}
+ if (caller == LinkCalledFromHeader)
+ UseCounter::count(document, UseCounter::LinkHeaderPreload);
Resource::Type type = LinkLoader::getTypeFromAsAttribute(as, &document);
ResourceRequest resourceRequest(document.completeURL(href));
ResourceFetcher::determineRequestContext(resourceRequest, type, false);
@@ -260,7 +262,7 @@ bool LinkLoader::loadLinkFromHeader(const String& headerValue, Document* documen
preconnectIfNeeded(relAttribute, url, *document, header.crossOrigin(), networkHintsInterface, LinkCalledFromHeader);
} else {
if (RuntimeEnabledFeatures::linkPreloadEnabled())
- preloadIfNeeded(relAttribute, url, *document, header.as());
+ preloadIfNeeded(relAttribute, url, *document, header.as(), LinkCalledFromHeader);
}
// TODO(yoav): Add more supported headers as needed.
}
@@ -278,7 +280,7 @@ bool LinkLoader::loadLink(const LinkRelAttribute& relAttribute, CrossOriginAttri
preconnectIfNeeded(relAttribute, href, document, crossOrigin, networkHintsInterface, LinkCalledFromMarkup);
if (m_client->shouldLoadLink())
- createLinkPreloadResourceClient(preloadIfNeeded(relAttribute, href, document, as));
+ createLinkPreloadResourceClient(preloadIfNeeded(relAttribute, href, document, as, LinkCalledFromMarkup));
// FIXME(crbug.com/323096): Should take care of import.
if ((relAttribute.isLinkPrefetch() || relAttribute.isLinkSubresource()) && href.isValid() && document.frame()) {
« no previous file with comments | « third_party/WebKit/Source/core/frame/UseCounter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698