Bug 994907 - imgDecoderObserver does reference counting on different threads, so should be using thread safe reference counting. r=seth, r=ehsan, a=abillings
authorMilan Sreckovic <milan@mozilla.com>
Tue, 06 May 2014 14:32:23 -0400
changeset 192224 adafd31af170
parent 192223 1fc8f2d7a261
child 192225 ccde75e4b1af
push id3532
push userryanvm@gmail.com
push date2014-05-08 15:27 +0000
treeherdermozilla-beta@e532119b92ab [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersseth, ehsan, abillings
bugs994907
milestone30.0
Bug 994907 - imgDecoderObserver does reference counting on different threads, so should be using thread safe reference counting. r=seth, r=ehsan, a=abillings
image/src/imgDecoderObserver.h
image/src/imgStatusTracker.cpp
--- a/image/src/imgDecoderObserver.h
+++ b/image/src/imgDecoderObserver.h
@@ -28,21 +28,20 @@ struct nsIntRect;
  * relied upon.
  *
  * Decode notifications may or may not be synchronous, depending on the
  * situation. If imgIDecoder::FLAG_SYNC_DECODE is passed to a function that
  * triggers a decode, all notifications that can be generated from the currently
  * loaded data fire before the call returns. If FLAG_SYNC_DECODE is not passed,
  * all, some, or none of the notifications may fire before the call returns.
  */
-class imgDecoderObserver : public mozilla::RefCounted<imgDecoderObserver>
+class imgDecoderObserver
 {
 public:
-  MOZ_DECLARE_REFCOUNTED_TYPENAME(imgDecoderObserver)
-  virtual ~imgDecoderObserver() = 0;
+  NS_INLINE_DECL_THREADSAFE_REFCOUNTING(imgDecoderObserver);
 
   /**
    * Load notification.
    *
    * called at the same time that nsIRequestObserver::onStartRequest would be
    * (used only for observers of imgIRequest objects, which are nsIRequests,
    * not imgIDecoder objects)
    */
@@ -121,16 +120,19 @@ public:
    * Called when we are asked to Draw an image that is not locked.
    */
   virtual void OnUnlockedDraw() = 0;
 
   /**
    * Called when an image is realized to be in error state.
    */
   virtual void OnError() = 0;
+
+protected:
+  virtual ~imgDecoderObserver() = 0;
 };
 
 // We must define a destructor because derived classes call our destructor from
 // theirs.  Pure virtual destructors only requires that child classes implement
 // a virtual destructor, not that we can't have one too!
 inline imgDecoderObserver::~imgDecoderObserver()
 {}
 
--- a/image/src/imgStatusTracker.cpp
+++ b/image/src/imgStatusTracker.cpp
@@ -24,18 +24,16 @@ class imgStatusTrackerObserver : public 
 {
 public:
   imgStatusTrackerObserver(imgStatusTracker* aTracker)
   : mTracker(aTracker->asWeakPtr())
   {
     MOZ_ASSERT(aTracker);
   }
 
-  virtual ~imgStatusTrackerObserver() {}
-
   void SetTracker(imgStatusTracker* aTracker)
   {
     MOZ_ASSERT(aTracker);
     mTracker = aTracker->asWeakPtr();
   }
 
   /** imgDecoderObserver methods **/
 
@@ -138,16 +136,19 @@ public:
   virtual void OnError() MOZ_OVERRIDE
   {
     LOG_SCOPE(GetImgLog(), "imgStatusTrackerObserver::OnError");
     nsRefPtr<imgStatusTracker> tracker = mTracker.get();
     if (!tracker) { return; }
     tracker->RecordError();
   }
 
+protected:
+  virtual ~imgStatusTrackerObserver() {}
+
 private:
   WeakPtr<imgStatusTracker> mTracker;
 };
 
 // imgStatusTracker methods
 
 imgStatusTracker::imgStatusTracker(Image* aImage)
   : mImage(aImage),