Bug 1287350. Part 2 - Call WatchManager::Shutdown() to prevent notifications from watchables. r=jya draft
authorJW Wang <jwwang@mozilla.com>
Fri, 15 Jul 2016 15:44:02 +0800
changeset 388868 888c389f0a99365da907a4dc56c8095cddfdbf55
parent 388867 bff7df290062d40c40b61a05bc054fbfa9cd3ddc
child 525612 5803fba2a1ff156630e162c4e44baccebdb7e1d2
push id23249
push userjwwang@mozilla.com
push dateMon, 18 Jul 2016 06:23:44 +0000
reviewersjya
bugs1287350
milestone50.0a1
Bug 1287350. Part 2 - Call WatchManager::Shutdown() to prevent notifications from watchables. r=jya MozReview-Commit-ID: 79GojLNE4Gn
dom/media/MediaDecoder.cpp
--- a/dom/media/MediaDecoder.cpp
+++ b/dom/media/MediaDecoder.cpp
@@ -621,16 +621,19 @@ MediaDecoder::Shutdown()
   MOZ_ASSERT(NS_IsMainThread());
 
   if (mShuttingDown) {
     return;
   }
 
   mShuttingDown = true;
 
+  // Unwatch all watch targets to prevent further notifications.
+  mWatchManager.Shutdown();
+
   mResourceCallback->Disconnect();
 
 #ifdef MOZ_EME
   mCDMProxyPromiseHolder.RejectIfExists(true, __func__);
 #endif
 
   // This changes the decoder state to SHUTDOWN and does other things
   // necessary to unblock the state machine thread if it's blocked, so
@@ -638,18 +641,16 @@ MediaDecoder::Shutdown()
   if (mDecoderStateMachine) {
     mTimedMetadataListener.Disconnect();
     mMetadataLoadedListener.Disconnect();
     mFirstFrameLoadedListener.Disconnect();
     mOnPlaybackEvent.Disconnect();
     mOnSeekingStart.Disconnect();
     mOnMediaNotSeekable.Disconnect();
 
-    mWatchManager.Unwatch(mIsAudioDataAudible, &MediaDecoder::NotifyAudibleStateChanged);
-
     mDecoderStateMachine->BeginShutdown()
       ->Then(AbstractThread::MainThread(), __func__, this,
              &MediaDecoder::FinishShutdown,
              &MediaDecoder::FinishShutdown);
   } else {
     // Ensure we always unregister asynchronously in order not to disrupt
     // the hashtable iterating in MediaShutdownManager::Shutdown().
     RefPtr<MediaDecoder> self = this;