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

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

Issue 2072613002: Make ResourceLoadPriority calculation simpler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Drop a default arg Created 4 years, 6 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 554ef07d132cb9a38bbd276a051c2edb736dd222..589ea99e008648988db180e6bbd06ce8cdda23ec 100644
--- a/third_party/WebKit/Source/core/fetch/ResourceFetcher.cpp
+++ b/third_party/WebKit/Source/core/fetch/ResourceFetcher.cpp
@@ -135,14 +135,6 @@ static ResourceLoadPriority typeToPriority(Resource::Type type)
ResourceLoadPriority ResourceFetcher::loadPriority(Resource::Type type, const FetchRequest& request, ResourcePriority::VisibilityStatus visibility)
{
- // TODO(yoav): Change it here so that priority can be changed even after it was resolved.
- if (request.priority() != ResourceLoadPriorityUnresolved)
- return request.priority();
-
- // Synchronous requests should always be max priority, lest they hang the renderer.
- if (request.options().synchronousPolicy == RequestSynchronously)
- return ResourceLoadPriorityHighest;
-
ResourceLoadPriority priority = typeToPriority(type);
// Visible resources (images in practice) get a boost to High priority.
@@ -165,9 +157,11 @@ ResourceLoadPriority ResourceFetcher::loadPriority(Resource::Type type, const Fe
priority = ResourceLoadPriorityLow;
else if (request.forPreload() && m_imageFetched)
priority = ResourceLoadPriorityMedium;
+ } else if (FetchRequest::LazyLoad == request.defer()) {
+ priority = ResourceLoadPriorityVeryLow;
}
- return context().modifyPriorityForExperiments(priority);
+ return std::max(context().modifyPriorityForExperiments(priority), request.resourceRequest().priority());
kinuko 2016/06/17 05:40:47 Is the max here to cover synchronous load case?
Nate Chapin 2016/06/17 18:38:16 That's half of it. Also, it covers the case where
kinuko 2016/06/20 04:28:31 Ah I see, thanks. Would it make sense to add a bri
Nate Chapin 2016/06/20 19:44:31 Done.
}
static void populateResourceTiming(ResourceTimingInfo* info, Resource* resource)
@@ -422,8 +416,7 @@ Resource* ResourceFetcher::requestResource(FetchRequest& request, const Resource
return nullptr;
unsigned long identifier = createUniqueIdentifier();
- request.setPriority(loadPriority(factory.type(), request, ResourcePriority::NotVisible));
- request.mutableResourceRequest().setPriority(request.priority());
+ request.mutableResourceRequest().setPriority(loadPriority(factory.type(), request, ResourcePriority::NotVisible));
initializeResourceRequest(request.mutableResourceRequest(), factory.type(), request.defer());
context().willStartLoadingResource(identifier, request.mutableResourceRequest(), factory.type());
if (!request.url().isValid())
@@ -499,8 +492,8 @@ Resource* ResourceFetcher::requestResource(FetchRequest& request, const Resource
// isn't at the same priority as the in-flight request, only allow promotions.
// This can happen when a visible image's priority is increased and then another
// reference to the image is parsed (which would be at a lower priority).
- if (request.priority() > resource->resourceRequest().priority())
- resource->didChangePriority(request.priority(), 0);
+ if (request.resourceRequest().priority() > resource->resourceRequest().priority())
+ resource->didChangePriority(request.resourceRequest().priority(), 0);
}
// If only the fragment identifiers differ, it is the same resource.

Powered by Google App Engine
This is Rietveld 408576698