Bug 1285121 - cancel callbacks before rejecting the promise. r=kaku
authorJW Wang <jwwang@mozilla.com>
Thu, 07 Jul 2016 14:30:54 +0800
changeset 330522 c2c393c85d041b196936a0dd53aff0db1c58d516
parent 330521 8e994cb3fb30be363fe83ecfb09b86165035c919
child 330523 db59de0a50806a79d204037029077eed79023174
push id9858
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 14:37:10 +0000
treeherdermozilla-aurora@203106ef6cb6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskaku
bugs1285121
milestone50.0a1
Bug 1285121 - cancel callbacks before rejecting the promise. r=kaku MozReview-Commit-ID: 1Ly4ZW1d6KL
dom/media/AccurateSeekTask.cpp
--- a/dom/media/AccurateSeekTask.cpp
+++ b/dom/media/AccurateSeekTask.cpp
@@ -319,16 +319,17 @@ AccurateSeekTask::OnAudioDecoded(MediaDa
 
   AdjustFastSeekIfNeeded(audio);
 
   if (mTarget.IsFast()) {
     // Non-precise seek; we can stop the seek at the first sample.
     mSeekedAudioData = audio;
     mDoneAudioSeeking = true;
   } else if (NS_FAILED(DropAudioUpToSeekTarget(audio))) {
+    CancelCallbacks();
     RejectIfExist(__func__);
     return;
   }
 
   if (!mDoneAudioSeeking) {
     RequestAudioData();
     return;
   }
@@ -346,16 +347,17 @@ AccurateSeekTask::OnNotDecoded(MediaData
 
   // Ignore pending requests from video-only seek.
   if (aType == MediaData::AUDIO_DATA && mTarget.IsVideoOnly()) {
     return;
   }
 
   if (aReason == MediaDecoderReader::DECODE_ERROR) {
     // If this is a decode error, delegate to the generic error path.
+    CancelCallbacks();
     RejectIfExist(__func__);
     return;
   }
 
   // If the decoder is waiting for data, we tell it to call us back when the
   // data arrives.
   if (aReason == MediaDecoderReader::WAITING_FOR_DATA) {
     mReader->WaitForData(aType);
@@ -410,16 +412,17 @@ AccurateSeekTask::OnVideoDecoded(MediaDa
 
   AdjustFastSeekIfNeeded(video);
 
   if (mTarget.IsFast()) {
     // Non-precise seek. We can stop the seek at the first sample.
     mSeekedVideoData = video;
     mDoneVideoSeeking = true;
   } else if (NS_FAILED(DropVideoUpToSeekTarget(video.get()))) {
+    CancelCallbacks();
     RejectIfExist(__func__);
     return;
   }
 
   if (!mDoneVideoSeeking) {
     RequestVideoData();
     return;
   }
@@ -470,14 +473,14 @@ AccurateSeekTask::SetCallbacks()
     }
   });
 }
 
 void
 AccurateSeekTask::CancelCallbacks()
 {
   AssertOwnerThread();
-  mAudioCallback.Disconnect();
-  mVideoCallback.Disconnect();
-  mAudioWaitCallback.Disconnect();
-  mVideoWaitCallback.Disconnect();
+  mAudioCallback.DisconnectIfExists();
+  mVideoCallback.DisconnectIfExists();
+  mAudioWaitCallback.DisconnectIfExists();
+  mVideoWaitCallback.DisconnectIfExists();
 }
 } // namespace mozilla