From a03358d4e3058ee4451ffa1452326a6d5cd4adc3 Mon Sep 17 00:00:00 2001 From: Josh Matthews Date: Thu, 11 Oct 2012 21:34:24 -0400 Subject: [PATCH] Bug 505385 - Part 14: Update image request status on decoding errors. r=joe --- image/src/imgStatusTracker.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/image/src/imgStatusTracker.cpp b/image/src/imgStatusTracker.cpp index be8bf689badf..7f390cb30931 100644 --- a/image/src/imgStatusTracker.cpp +++ b/image/src/imgStatusTracker.cpp @@ -636,7 +636,7 @@ imgStatusTracker::RecordStopDecode(nsresult aStatus) "RecordStopDecode called before we have an Image"); mState |= stateDecodeStopped; - if (NS_SUCCEEDED(aStatus)) + if (NS_SUCCEEDED(aStatus) && mImageStatus != imgIRequest::STATUS_ERROR) mImageStatus |= imgIRequest::STATUS_DECODE_COMPLETE; // If we weren't successful, clear all success status bits and set error. else @@ -751,8 +751,10 @@ imgStatusTracker::RecordStopRequest(bool aLastPart, nsresult aStatus) mState |= stateRequestStopped; // If we were successful in loading, note that the image is complete. - if (NS_SUCCEEDED(aStatus)) + if (NS_SUCCEEDED(aStatus) && mImageStatus != imgIRequest::STATUS_ERROR) mImageStatus |= imgIRequest::STATUS_LOAD_COMPLETE; + else + mImageStatus = imgIRequest::STATUS_ERROR; } void @@ -772,6 +774,18 @@ imgStatusTracker::OnStopRequest(bool aLastPart, nsresult aStatus) while (srIter.HasMore()) { SendStopRequest(srIter.GetNext(), aLastPart, aStatus); } + + if (NS_FAILED(aStatus)) { + // Some kind of problem has happened with image decoding. + // Report the URI to net:failed-to-process-uri-conent observers. + + nsCOMPtr os = mozilla::services::GetObserverService(); + if (os) { + nsCOMPtr uri; + mTracker->GetRequest()->GetURI(getter_AddRefs(uri)); + os->NotifyObservers(uri, "net:failed-to-process-uri-content", nullptr); + } + } } void