--- a/image/imgLoader.cpp
+++ b/image/imgLoader.cpp
@@ -640,18 +640,19 @@ ValidateSecurityInfo(imgRequest* request
if (referrerPolicy != request->GetReferrerPolicy()) {
return false;
}
// If the entry's CORS mode doesn't match, or the CORS mode matches but the
// document principal isn't the same, we can't use this request.
if (request->GetCORSMode() != corsmode) {
return false;
- } else if (request->GetCORSMode() != imgIRequest::CORS_NONE ||
- forcePrincipalCheck) {
+ }
+ if (request->GetCORSMode() != imgIRequest::CORS_NONE ||
+ forcePrincipalCheck) {
nsCOMPtr<nsIPrincipal> otherprincipal = request->GetLoadingPrincipal();
// If we previously had a principal, but we don't now, we can't use this
// request.
if (otherprincipal && !loadingPrincipal) {
return false;
}
@@ -1333,19 +1334,19 @@ imgLoader::ClearCache(bool chrome)
bool privateLoader = this == gPrivateBrowsingLoader;
for (auto* cp : ContentParent::AllProcesses(ContentParent::eLive)) {
Unused << cp->SendClearImageCache(privateLoader, chrome);
}
}
if (chrome) {
return ClearChromeImageCache();
- } else {
- return ClearImageCache();
}
+ return ClearImageCache();
+
}
NS_IMETHODIMP
imgLoader::FindEntryProperties(nsIURI* uri,
nsIDOMDocument* aDOMDoc,
nsIProperties** _retval)
{
*_retval = nullptr;
@@ -1628,90 +1629,89 @@ imgLoader::ValidateRequestWithNewChannel
proxy->SetNotificationsDeferred(true);
// Attach the proxy without notifying
request->GetValidator()->AddProxy(proxy);
}
return NS_SUCCEEDED(rv);
- } else {
- // We will rely on Necko to cache this request when it's possible, and to
- // tell imgCacheValidator::OnStartRequest whether the request came from its
- // cache.
- nsCOMPtr<nsIChannel> newChannel;
- bool forcePrincipalCheck;
- rv = NewImageChannel(getter_AddRefs(newChannel),
- &forcePrincipalCheck,
- aURI,
- aInitialDocumentURI,
- aCORSMode,
- aReferrerURI,
- aReferrerPolicy,
- aLoadGroup,
- mAcceptHeader,
- aLoadFlags,
- aLoadPolicyType,
- aLoadingPrincipal,
- aCX,
- mRespectPrivacy);
- if (NS_FAILED(rv)) {
- return false;
- }
-
- RefPtr<imgRequestProxy> req;
- rv = CreateNewProxyForRequest(request, aLoadGroup, aObserver,
- aLoadFlags, getter_AddRefs(req));
- if (NS_FAILED(rv)) {
- return false;
- }
-
- // Make sure that OnStatus/OnProgress calls have the right request set...
- RefPtr<nsProgressNotificationProxy> progressproxy =
- new nsProgressNotificationProxy(newChannel, req);
- if (!progressproxy) {
- return false;
- }
-
- RefPtr<imgCacheValidator> hvc =
- new imgCacheValidator(progressproxy, this, request, aCX,
- forcePrincipalCheck);
-
- // Casting needed here to get past multiple inheritance.
- nsCOMPtr<nsIStreamListener> listener =
- do_QueryInterface(static_cast<nsIThreadRetargetableStreamListener*>(hvc));
- NS_ENSURE_TRUE(listener, false);
-
- // We must set the notification callbacks before setting up the
- // CORS listener, because that's also interested inthe
- // notification callbacks.
- newChannel->SetNotificationCallbacks(hvc);
-
- request->SetValidator(hvc);
-
- // We will send notifications from imgCacheValidator::OnStartRequest().
- // In the mean time, we must defer notifications because we are added to
- // the imgRequest's proxy list, and we can get extra notifications
- // resulting from methods such as StartDecoding(). See bug 579122.
- req->SetNotificationsDeferred(true);
-
- // Add the proxy without notifying
- hvc->AddProxy(req);
-
- mozilla::net::PredictorLearn(aURI, aInitialDocumentURI,
- nsINetworkPredictor::LEARN_LOAD_SUBRESOURCE, aLoadGroup);
-
- rv = newChannel->AsyncOpen2(listener);
- if (NS_WARN_IF(NS_FAILED(rv))) {
- return false;
- }
-
- req.forget(aProxyRequest);
- return true;
+ }
+ // We will rely on Necko to cache this request when it's possible, and to
+ // tell imgCacheValidator::OnStartRequest whether the request came from its
+ // cache.
+ nsCOMPtr<nsIChannel> newChannel;
+ bool forcePrincipalCheck;
+ rv = NewImageChannel(getter_AddRefs(newChannel),
+ &forcePrincipalCheck,
+ aURI,
+ aInitialDocumentURI,
+ aCORSMode,
+ aReferrerURI,
+ aReferrerPolicy,
+ aLoadGroup,
+ mAcceptHeader,
+ aLoadFlags,
+ aLoadPolicyType,
+ aLoadingPrincipal,
+ aCX,
+ mRespectPrivacy);
+ if (NS_FAILED(rv)) {
+ return false;
+ }
+
+ RefPtr<imgRequestProxy> req;
+ rv = CreateNewProxyForRequest(request, aLoadGroup, aObserver,
+ aLoadFlags, getter_AddRefs(req));
+ if (NS_FAILED(rv)) {
+ return false;
+ }
+
+ // Make sure that OnStatus/OnProgress calls have the right request set...
+ RefPtr<nsProgressNotificationProxy> progressproxy =
+ new nsProgressNotificationProxy(newChannel, req);
+ if (!progressproxy) {
+ return false;
}
+
+ RefPtr<imgCacheValidator> hvc =
+ new imgCacheValidator(progressproxy, this, request, aCX,
+ forcePrincipalCheck);
+
+ // Casting needed here to get past multiple inheritance.
+ nsCOMPtr<nsIStreamListener> listener =
+ do_QueryInterface(static_cast<nsIThreadRetargetableStreamListener*>(hvc));
+ NS_ENSURE_TRUE(listener, false);
+
+ // We must set the notification callbacks before setting up the
+ // CORS listener, because that's also interested inthe
+ // notification callbacks.
+ newChannel->SetNotificationCallbacks(hvc);
+
+ request->SetValidator(hvc);
+
+ // We will send notifications from imgCacheValidator::OnStartRequest().
+ // In the mean time, we must defer notifications because we are added to
+ // the imgRequest's proxy list, and we can get extra notifications
+ // resulting from methods such as StartDecoding(). See bug 579122.
+ req->SetNotificationsDeferred(true);
+
+ // Add the proxy without notifying
+ hvc->AddProxy(req);
+
+ mozilla::net::PredictorLearn(aURI, aInitialDocumentURI,
+ nsINetworkPredictor::LEARN_LOAD_SUBRESOURCE, aLoadGroup);
+
+ rv = newChannel->AsyncOpen2(listener);
+ if (NS_WARN_IF(NS_FAILED(rv))) {
+ return false;
+ }
+
+ req.forget(aProxyRequest);
+ return true;
}
bool
imgLoader::ValidateEntry(imgCacheEntry* aEntry,
nsIURI* aURI,
nsIURI* aInitialDocumentURI,
nsIURI* aReferrerURI,
ReferrerPolicy aReferrerPolicy,
@@ -1871,20 +1871,18 @@ imgLoader::RemoveFromCache(const ImageCa
entry->SetEvicted(true);
RefPtr<imgRequest> request = entry->GetRequest();
request->SetIsInCache(false);
AddToUncachedImages(request);
return true;
-
- } else {
- return false;
}
+ return false;
}
bool
imgLoader::RemoveFromCache(imgCacheEntry* entry)
{
LOG_STATIC_FUNC(gImgLog, "imgLoader::RemoveFromCache entry");
RefPtr<imgRequest> request = entry->GetRequest();