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

Unified Diff: third_party/WebKit/Source/core/fetch/ResourceFetcher.cpp

Issue 2343623002: Add a warning whenever link preloads are not used (Closed)
Patch Set: Created 4 years, 3 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
Index: third_party/WebKit/Source/core/fetch/ResourceFetcher.cpp
diff --git a/third_party/WebKit/Source/core/fetch/ResourceFetcher.cpp b/third_party/WebKit/Source/core/fetch/ResourceFetcher.cpp
index 5ff0d0d3861a31c60532f733a76016d704734229..97affdc890cde47ef8a99006e61753eed7484276 100644
--- a/third_party/WebKit/Source/core/fetch/ResourceFetcher.cpp
+++ b/third_party/WebKit/Source/core/fetch/ResourceFetcher.cpp
@@ -906,6 +906,17 @@ void ResourceFetcher::clearPreloads(ClearPreloadsPolicy policy)
m_preloads.clear();
}
+void ResourceFetcher::warnUnusedPreloads()
+{
+ if (!m_preloads)
+ return;
+ for (auto resource : *m_preloads) {
Charlie Harrison 2016/09/14 12:34:58 const auto& ?
Yoav Weiss 2016/09/14 13:28:31 Yeah. I'll also modify all the other iterations of
+ if (resource && resource->isLinkPreload() && resource->getPreloadResult() == Resource::PreloadNotReferenced) {
+ context().addConsoleMessage("The resource " + resource->url().getString() + " was preloaded but not used within a few seconds from the window's load event. Please make sure it wasn't preloaded for nothing.", WarningMessageLevel);
Charlie Harrison 2016/09/14 12:34:58 Do you think you should include the fact that it w
Yoav Weiss 2016/09/14 13:28:31 nothing is obvious :) I'll add it to the comment
+ }
+ }
+}
+
ArchiveResource* ResourceFetcher::createArchive(Resource* resource)
{
// Only the top-frame can load MHTML.

Powered by Google App Engine
This is Rietveld 408576698