Merge pull request #10968 from druiz17/bug/load-priority

Prioritize file:// requests over http://
This commit is contained in:
Seth Alves 2017-07-14 11:13:35 -07:00 committed by GitHub
commit 806d9f1436

View file

@ -102,6 +102,8 @@ QSharedPointer<Resource> ResourceCacheSharedItems::getHighestPendingRequest() {
QSharedPointer<Resource> highestResource; QSharedPointer<Resource> highestResource;
Lock lock(_mutex); Lock lock(_mutex);
bool currentHighestIsFile = false;
for (int i = 0; i < _pendingRequests.size();) { for (int i = 0; i < _pendingRequests.size();) {
// Clear any freed resources // Clear any freed resources
auto resource = _pendingRequests.at(i).lock(); auto resource = _pendingRequests.at(i).lock();
@ -112,10 +114,12 @@ QSharedPointer<Resource> ResourceCacheSharedItems::getHighestPendingRequest() {
// Check load priority // Check load priority
float priority = resource->getLoadPriority(); float priority = resource->getLoadPriority();
if (priority >= highestPriority) { bool isFile = resource->getURL().scheme() == URL_SCHEME_FILE;
if (priority >= highestPriority && (isFile || !currentHighestIsFile)) {
highestPriority = priority; highestPriority = priority;
highestIndex = i; highestIndex = i;
highestResource = resource; highestResource = resource;
currentHighestIsFile = isFile;
} }
i++; i++;
} }