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

Unified Diff: third_party/WebKit/Source/platform/loader/fetch/ResourceFetcher.cpp

Issue 2753053004: Improve preload related priorities (Closed)
Patch Set: Created 3 years, 9 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/platform/loader/fetch/ResourceFetcher.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/platform/loader/fetch/ResourceFetcher.cpp
diff --git a/third_party/WebKit/Source/platform/loader/fetch/ResourceFetcher.cpp b/third_party/WebKit/Source/platform/loader/fetch/ResourceFetcher.cpp
index a5eae6c5bf861db7dc1fd4028a4489e01506f60b..c47a3571ebac2ffc83cd56b8cb2eae189932848b 100644
--- a/third_party/WebKit/Source/platform/loader/fetch/ResourceFetcher.cpp
+++ b/third_party/WebKit/Source/platform/loader/fetch/ResourceFetcher.cpp
@@ -157,7 +157,8 @@ ResourceLoadPriority ResourceFetcher::computeLoadPriority(
const ResourceRequest& resourceRequest,
ResourcePriority::VisibilityStatus visibility,
FetchRequest::DeferOption deferOption,
- bool speculativePreload) {
+ bool isSpeculativePreload,
+ bool isLinkPreload) {
ResourceLoadPriority priority = typeToPriority(type);
// Visible resources (images in practice) get a boost to High priority.
@@ -169,9 +170,14 @@ ResourceLoadPriority ResourceFetcher::computeLoadPriority(
// note that this is based on when the preload scanner discovers a resource
// for the most part so the main parser may not have reached the image element
// yet.
- if (type == Resource::Image)
+ if (type == Resource::Image && !isLinkPreload)
m_imageFetched = true;
+ // A preloaded font should not take precedence over critical CSS or
+ // parser-blocking scripts.
+ if (type == Resource::Font && isLinkPreload)
+ priority = ResourceLoadPriorityHigh;
+
if (FetchRequest::IdleLoad == deferOption) {
priority = ResourceLoadPriorityVeryLow;
} else if (type == Resource::Script) {
@@ -182,7 +188,7 @@ ResourceLoadPriority ResourceFetcher::computeLoadPriority(
// Preload late in document: Medium
if (FetchRequest::LazyLoad == deferOption) {
priority = ResourceLoadPriorityLow;
- } else if (speculativePreload && m_imageFetched) {
+ } else if (isSpeculativePreload && m_imageFetched) {
// Speculative preload is used as a signal for scripts at the bottom of
// the document.
priority = ResourceLoadPriorityMedium;
@@ -480,7 +486,8 @@ ResourceFetcher::PrepareRequestResult ResourceFetcher::prepareRequest(
resourceRequest.setPriority(computeLoadPriority(
factory.type(), request.resourceRequest(), ResourcePriority::NotVisible,
- request.defer(), request.isSpeculativePreload()));
+ request.defer(), request.isSpeculativePreload(),
+ request.isLinkPreload()));
initializeResourceRequest(resourceRequest, factory.type(), request.defer());
network_instrumentation::resourcePrioritySet(identifier,
resourceRequest.priority());
« no previous file with comments | « third_party/WebKit/Source/platform/loader/fetch/ResourceFetcher.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698