зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1743377 - Remove imgLoader::PreferLoadFromCache. r=aosmond
Instead treat these protocols as "never-expiring" protocols, and clean up revalidation code while at it. Depends on D132347 Differential Revision: https://phabricator.services.mozilla.com/D132348
This commit is contained in:
Родитель
c5f2196f46
Коммит
323ecd6f31
|
@ -10539,7 +10539,8 @@ nsContentUtils::GetSubresourceCacheValidationInfo(nsIRequest* aRequest,
|
|||
if (!aURI) {
|
||||
return false;
|
||||
}
|
||||
if (aURI->SchemeIs("data")) {
|
||||
if (aURI->SchemeIs("data") || aURI->SchemeIs("moz-page-thumb") ||
|
||||
aURI->SchemeIs("moz-extension")) {
|
||||
return true;
|
||||
}
|
||||
if (dom::IsChromeURI(aURI)) {
|
||||
|
|
|
@ -666,34 +666,29 @@ static void NewRequestAndEntry(bool aForcePrincipalCheckForCacheEntry,
|
|||
|
||||
static bool ShouldRevalidateEntry(imgCacheEntry* aEntry, nsLoadFlags aFlags,
|
||||
bool aHasExpired) {
|
||||
bool bValidateEntry = false;
|
||||
|
||||
if (aFlags & nsIRequest::LOAD_BYPASS_CACHE) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (aFlags & nsIRequest::VALIDATE_ALWAYS) {
|
||||
bValidateEntry = true;
|
||||
} else if (aEntry->GetMustValidate()) {
|
||||
bValidateEntry = true;
|
||||
} else if (aHasExpired) {
|
||||
return true;
|
||||
}
|
||||
if (aEntry->GetMustValidate()) {
|
||||
return true;
|
||||
}
|
||||
if (aHasExpired) {
|
||||
// The cache entry has expired... Determine whether the stale cache
|
||||
// entry can be used without validation...
|
||||
if (aFlags &
|
||||
(nsIRequest::VALIDATE_NEVER | nsIRequest::VALIDATE_ONCE_PER_SESSION)) {
|
||||
// VALIDATE_NEVER and VALIDATE_ONCE_PER_SESSION allow stale cache
|
||||
// entries to be used unless they have been explicitly marked to
|
||||
// indicate that revalidation is necessary.
|
||||
bValidateEntry = false;
|
||||
|
||||
} else if (!(aFlags & nsIRequest::LOAD_FROM_CACHE)) {
|
||||
// LOAD_FROM_CACHE allows a stale cache entry to be used... Otherwise,
|
||||
// the entry must be revalidated.
|
||||
bValidateEntry = true;
|
||||
if (aFlags & (nsIRequest::LOAD_FROM_CACHE | nsIRequest::VALIDATE_NEVER |
|
||||
nsIRequest::VALIDATE_ONCE_PER_SESSION)) {
|
||||
// LOAD_FROM_CACHE, VALIDATE_NEVER and VALIDATE_ONCE_PER_SESSION allow
|
||||
// stale cache entries to be used unless they have been explicitly marked
|
||||
// to indicate that revalidation is necessary.
|
||||
return false;
|
||||
}
|
||||
// Entry is expired, revalidate.
|
||||
return true;
|
||||
}
|
||||
|
||||
return bValidateEntry;
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Call content policies on cached images that went through a redirect */
|
||||
|
@ -2209,15 +2204,6 @@ void imgLoader::RemoveFromUncachedImages(imgRequest* aRequest) {
|
|||
mUncachedImages.Remove(aRequest);
|
||||
}
|
||||
|
||||
bool imgLoader::PreferLoadFromCache(nsIURI* aURI) const {
|
||||
// If we are trying to load an image from a protocol that doesn't support
|
||||
// caching (e.g. thumbnails via the moz-page-thumb:// protocol, or icons via
|
||||
// the moz-extension:// protocol), load it directly from the cache to prevent
|
||||
// re-decoding the image. See Bug 1373258.
|
||||
// TODO: Bug 1406134
|
||||
return aURI->SchemeIs("moz-page-thumb") || aURI->SchemeIs("moz-extension");
|
||||
}
|
||||
|
||||
#define LOAD_FLAGS_CACHE_MASK \
|
||||
(nsIRequest::LOAD_BYPASS_CACHE | nsIRequest::LOAD_FROM_CACHE)
|
||||
|
||||
|
@ -2339,9 +2325,6 @@ nsresult imgLoader::LoadImage(
|
|||
// Get the default load flags from the loadgroup (if possible)...
|
||||
if (aLoadGroup) {
|
||||
aLoadGroup->GetLoadFlags(&requestFlags);
|
||||
if (PreferLoadFromCache(aURI)) {
|
||||
requestFlags |= nsIRequest::LOAD_FROM_CACHE;
|
||||
}
|
||||
}
|
||||
//
|
||||
// Merge the default load flags with those passed in via aLoadFlags.
|
||||
|
@ -2682,10 +2665,6 @@ nsresult imgLoader::LoadImageWithChannel(nsIChannel* channel,
|
|||
nsLoadFlags requestFlags = nsIRequest::LOAD_NORMAL;
|
||||
channel->GetLoadFlags(&requestFlags);
|
||||
|
||||
if (PreferLoadFromCache(uri)) {
|
||||
requestFlags |= nsIRequest::LOAD_FROM_CACHE;
|
||||
}
|
||||
|
||||
RefPtr<imgCacheEntry> entry;
|
||||
|
||||
if (requestFlags & nsIRequest::LOAD_BYPASS_CACHE) {
|
||||
|
|
|
@ -349,8 +349,6 @@ class imgLoader final : public imgILoader,
|
|||
private: // methods
|
||||
static already_AddRefed<imgLoader> CreateImageLoader();
|
||||
|
||||
bool PreferLoadFromCache(nsIURI* aURI) const;
|
||||
|
||||
bool ValidateEntry(
|
||||
imgCacheEntry* aEntry, nsIURI* aURI, nsIURI* aInitialDocumentURI,
|
||||
nsIReferrerInfo* aReferrerInfo, nsILoadGroup* aLoadGroup,
|
||||
|
|
Загрузка…
Ссылка в новой задаче