Bug 803125 - Notify status tracker when image request is destroyed. r=joe
authorJosh Matthews <josh@joshmatthews.net>
Sat, 17 Nov 2012 13:33:20 +0000
changeset 113622 278bf5deb265a8d50fef9f5df53a239ab6e2ded8
parent 113621 fd7927a8baf87cb1d8c0b223c42e8fd01bb5ed9d
child 113623 fc4e7e3a74074768888a7b98bf4b5811919e17ed
push id23880
push userryanvm@gmail.com
push dateSun, 18 Nov 2012 13:36:46 +0000
treeherdermozilla-central@174440fca7da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjoe
bugs803125
milestone19.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 803125 - Notify status tracker when image request is destroyed. r=joe
image/src/imgRequest.cpp
image/src/imgStatusTracker.cpp
image/src/imgStatusTracker.h
--- a/image/src/imgRequest.cpp
+++ b/image/src/imgRequest.cpp
@@ -103,16 +103,19 @@ imgRequest::imgRequest(imgLoader* aLoade
   // Register our pref observers if we haven't yet.
   if (MOZ_UNLIKELY(!gInitializedPrefCaches)) {
     InitPrefCaches();
   }
 }
 
 imgRequest::~imgRequest()
 {
+  // The status tracker can outlive this request, and needs to know it's dying.
+  GetStatusTracker().ClearRequest();
+
   if (mURI) {
     nsAutoCString spec;
     mURI->GetSpec(spec);
     LOG_FUNC_WITH_PARAM(GetImgLog(), "imgRequest::~imgRequest()", "keyuri", spec.get());
   } else
     LOG_FUNC(GetImgLog(), "imgRequest::~imgRequest()");
 }
 
--- a/image/src/imgStatusTracker.cpp
+++ b/image/src/imgStatusTracker.cpp
@@ -761,8 +761,14 @@ imgStatusTracker::MaybeUnblockOnload()
 
   RecordUnblockOnload();
 
   nsTObserverArray<imgRequestProxy*>::ForwardIterator iter(mConsumers);
   while (iter.HasMore()) {
     SendUnblockOnload(iter.GetNext());
   }
 }
+
+void
+imgStatusTracker::ClearRequest()
+{
+  mRequest = nullptr;
+}
--- a/image/src/imgStatusTracker.h
+++ b/image/src/imgStatusTracker.h
@@ -181,16 +181,19 @@ public:
   // is different from all the other notifications.
   void RecordBlockOnload();
   void SendBlockOnload(imgRequestProxy* aProxy);
   void RecordUnblockOnload();
   void SendUnblockOnload(imgRequestProxy* aProxy);
 
   void MaybeUnblockOnload();
 
+  // Null out any reference to an associated image request
+  void ClearRequest();
+
   // Weak pointer getters - no AddRefs.
   inline mozilla::image::Image* GetImage() const { return mImage; };
   inline imgRequest* GetRequest() const { return mRequest; };
 
   inline imgIDecoderObserver* GetDecoderObserver() { return mTrackerObserver.get(); }
 
 private:
   friend class imgStatusNotifyRunnable;