Bug 716140 - Handle discarding specially so it gets notified synchronously. r=seth
--- a/image/src/RasterImage.cpp
+++ b/image/src/RasterImage.cpp
@@ -2499,17 +2499,17 @@ RasterImage::Discard(bool force)
mScaleResult.status = SCALE_INVALID;
mScaleResult.frame = nullptr;
// Flag that we no longer have decoded frames for this image
mDecoded = false;
// Notify that we discarded
if (mStatusTracker)
- mStatusTracker->GetDecoderObserver()->OnDiscard();
+ mStatusTracker->OnDiscard();
if (force)
DiscardTracker::Remove(&mDiscardTrackerNode);
// Log
PR_LOG(GetCompressedImageAccountingLog(), PR_LOG_DEBUG,
("CompressedImageAccounting: discarded uncompressed image "
"data from RasterImage %p (%s) - %d frames (cached count: %d); "
--- a/image/src/imgStatusTracker.cpp
+++ b/image/src/imgStatusTracker.cpp
@@ -845,16 +845,28 @@ imgStatusTracker::OnStopRequest(bool aLa
}
if (NS_FAILED(aStatus) && !preexistingError) {
FireFailureNotification();
}
}
void
+imgStatusTracker::OnDiscard()
+{
+ RecordDiscard();
+
+ /* notify the kids */
+ nsTObserverArray<imgRequestProxy*>::ForwardIterator iter(mConsumers);
+ while (iter.HasMore()) {
+ SendDiscard(iter.GetNext());
+ }
+}
+
+void
imgStatusTracker::OnDataAvailable()
{
// Notify any imgRequestProxys that are observing us that we have an Image.
nsTObserverArray<imgRequestProxy*>::ForwardIterator iter(mConsumers);
while (iter.HasMore()) {
iter.GetNext()->SetHasImage();
}
}
--- a/image/src/imgStatusTracker.h
+++ b/image/src/imgStatusTracker.h
@@ -155,16 +155,17 @@ public:
void RecordStartRequest();
void SendStartRequest(imgRequestProxy* aProxy);
void RecordStopRequest(bool aLastPart, nsresult aStatus);
void SendStopRequest(imgRequestProxy* aProxy, bool aLastPart, nsresult aStatus);
void OnStartRequest();
void OnDataAvailable();
void OnStopRequest(bool aLastPart, nsresult aStatus);
+ void OnDiscard();
/* non-virtual imgIOnloadBlocker methods */
// NB: If UnblockOnload is sent, and then we are asked to replay the
// notifications, we will not send a BlockOnload/UnblockOnload pair. This
// is different from all the other notifications.
void RecordBlockOnload();
void SendBlockOnload(imgRequestProxy* aProxy);
void RecordUnblockOnload();