From 5c46df90e160e900e0fadf01f2b0f685212a2018 Mon Sep 17 00:00:00 2001 From: Ryan VanderMeulen Date: Tue, 10 Mar 2015 16:45:01 -0400 Subject: [PATCH] Backed out changesets febbccd1cd1e and d834e57b0352 (bug 1137019) for making bug 1123563 permafail on Android 2.3. CLOSED TREE --- image/src/imgRequest.cpp | 40 +++++++++++++++++++++++++++++++++++ image/src/imgRequest.h | 13 ++++++++---- image/src/imgRequestProxy.cpp | 35 +++++++++++------------------- 3 files changed, 61 insertions(+), 27 deletions(-) diff --git a/image/src/imgRequest.cpp b/image/src/imgRequest.cpp index 8aef9b748ee..428a99366a8 100644 --- a/image/src/imgRequest.cpp +++ b/image/src/imgRequest.cpp @@ -589,6 +589,46 @@ imgRequest::CacheChanged(nsIRequest* aNewRequest) return true; } +nsresult +imgRequest::LockImage() +{ + return mImage->LockImage(); +} + +nsresult +imgRequest::UnlockImage() +{ + return mImage->UnlockImage(); +} + +nsresult +imgRequest::RequestDecode() +{ + // If we've initialized our image, we can request a decode. + if (mImage) { + return mImage->RequestDecode(); + } + + // Otherwise, flag to do it when we get the image + mDecodeRequested = true; + + return NS_OK; +} + +nsresult +imgRequest::StartDecoding() +{ + // If we've initialized our image, we can request a decode. + if (mImage) { + return mImage->StartDecoding(); + } + + // Otherwise, flag to do it when we get the image + mDecodeRequested = true; + + return NS_OK; +} + /** nsIRequestObserver methods **/ /* void onStartRequest (in nsIRequest request, in nsISupports ctxt); */ diff --git a/image/src/imgRequest.h b/image/src/imgRequest.h index 179afdd34b4..1e6fe88cf19 100644 --- a/image/src/imgRequest.h +++ b/image/src/imgRequest.h @@ -19,7 +19,6 @@ #include "nsStringGlue.h" #include "nsError.h" #include "nsIAsyncVerifyRedirectCallback.h" -#include "mozilla/Atomics.h" #include "mozilla/net/ReferrerPolicy.h" class imgCacheValidator; @@ -88,8 +87,12 @@ public: // Called or dispatched by EvictFromCache for main thread only execution. void ContinueEvict(); - // Request that we start decoding the image as soon as data becomes available. - void RequestDecode() { mDecodeRequested = true; } + // Methods that get forwarded to the Image, or deferred until it's + // instantiated. + nsresult LockImage(); + nsresult UnlockImage(); + nsresult StartDecoding(); + nsresult RequestDecode(); inline void SetInnerWindowID(uint64_t aInnerWindowId) { mInnerWindowId = aInnerWindowId; @@ -261,7 +264,9 @@ private: nsresult mImageErrorCode; - mozilla::Atomic mDecodeRequested; + // Sometimes consumers want to do things before the image is ready. Let them, + // and apply the action when the image becomes available. + bool mDecodeRequested : 1; bool mIsMultiPartChannel : 1; bool mGotData : 1; diff --git a/image/src/imgRequestProxy.cpp b/image/src/imgRequestProxy.cpp index 83a26a900bb..8cf735d2a37 100644 --- a/image/src/imgRequestProxy.cpp +++ b/image/src/imgRequestProxy.cpp @@ -224,9 +224,8 @@ nsresult imgRequestProxy::ChangeOwner(imgRequest *aNewOwner) // If we were decoded, or if we'd previously requested a decode, request a // decode on the new image - if (wasDecoded || mDecodeRequested) { - StartDecoding(); - } + if (wasDecoded || mDecodeRequested) + GetOwner()->StartDecoding(); return NS_OK; } @@ -353,38 +352,28 @@ NS_IMETHODIMP imgRequestProxy::CancelAndForgetObserver(nsresult aStatus) NS_IMETHODIMP imgRequestProxy::StartDecoding() { + if (!GetOwner()) + return NS_ERROR_FAILURE; + // Flag this, so we know to transfer the request if our owner changes mDecodeRequested = true; - nsRefPtr image = GetImage(); - if (image) { - return image->StartDecoding(); - } - - if (GetOwner()) { - GetOwner()->RequestDecode(); - } - - return NS_OK; + // Forward the request + return GetOwner()->StartDecoding(); } /* void requestDecode (); */ NS_IMETHODIMP imgRequestProxy::RequestDecode() { + if (!GetOwner()) + return NS_ERROR_FAILURE; + // Flag this, so we know to transfer the request if our owner changes mDecodeRequested = true; - nsRefPtr image = GetImage(); - if (image) { - return image->RequestDecode(); - } - - if (GetOwner()) { - GetOwner()->RequestDecode(); - } - - return NS_OK; + // Forward the request + return GetOwner()->RequestDecode(); }