Bug 716140 - Handle discarding specially so it gets notified synchronously. r=seth
authorJoe Drew <joe@drew.ca>
Thu, 07 Feb 2013 17:22:38 -0500
changeset 132060 761015312a0babc85f0502ff456f39cb960ad27f
parent 132059 4bad4198e33c0f4499e5e6a1e689b1c1b485d43b
child 132061 7d0a6850c8875b94d2c2303a2266972242c1776e
push idunknown
push userunknown
push dateunknown
reviewersseth
bugs716140
milestone22.0a1
Bug 716140 - Handle discarding specially so it gets notified synchronously. r=seth
image/src/RasterImage.cpp
image/src/imgStatusTracker.cpp
image/src/imgStatusTracker.h
--- 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();