Bug 1129224: Ensure the target is always unref in the target thread. r=bholley a=lmandel
authorJean-Yves Avenard <jyavenard@mozilla.com>
Wed, 04 Feb 2015 16:38:27 +1100
changeset 249763 982276da601721e6c361ef8b09c0cff202216ca5
parent 249762 636a4a911276cd861b60eb6a2db87c9cc5769f53
child 249764 26fd99166d7c3e7c4e7703cafe274aa2ecab4c37
push id4489
push userraliiev@mozilla.com
push dateMon, 23 Feb 2015 15:17:55 +0000
treeherdermozilla-beta@fd7c3dc24146 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbholley, lmandel
bugs1129224
milestone37.0a2
Bug 1129224: Ensure the target is always unref in the target thread. r=bholley a=lmandel
dom/media/MediaPromise.h
--- a/dom/media/MediaPromise.h
+++ b/dom/media/MediaPromise.h
@@ -249,16 +249,19 @@ protected:
 #endif
 
   protected:
     virtual void DoResolve(ResolveValueType aResolveValue) MOZ_OVERRIDE
     {
       Consumer::mComplete = true;
       if (Consumer::mDisconnected) {
         PROMISE_LOG("ThenValue::DoResolve disconnected - bailing out [this=%p]", this);
+        // Null these out for the same reasons described below.
+        mResponseTarget = nullptr;
+        mThisVal = nullptr;
         return;
       }
       InvokeCallbackMethod(mThisVal.get(), mResolveMethod, aResolveValue);
 
       // Null these out after invoking the callback so that any references are
       // released predictably on the target thread. Otherwise, they would be
       // released on whatever thread last drops its reference to the ThenValue,
       // which may or may not be ok.
@@ -266,16 +269,19 @@ protected:
       mThisVal = nullptr;
     }
 
     virtual void DoReject(RejectValueType aRejectValue) MOZ_OVERRIDE
     {
       Consumer::mComplete = true;
       if (Consumer::mDisconnected) {
         PROMISE_LOG("ThenValue::DoReject disconnected - bailing out [this=%p]", this);
+        // Null these out for the same reasons described below.
+        mResponseTarget = nullptr;
+        mThisVal = nullptr;
         return;
       }
       InvokeCallbackMethod(mThisVal.get(), mRejectMethod, aRejectValue);
 
       // Null these out after invoking the callback so that any references are
       // released predictably on the target thread. Otherwise, they would be
       // released on whatever thread last drops its reference to the ThenValue,
       // which may or may not be ok.