Bug 1345751. P1 - remove the else branch for MediaShutdownManager ensures all media activities are finished before "xpcom-shutdown-threads" starts. r?cpearce draft
authorJW Wang <jwwang@mozilla.com>
Thu, 09 Mar 2017 14:45:09 +0800
changeset 496369 176c2021c9535b6f83ce3988285e494bbf01c97e
parent 496368 db9b5b84f9a1a29cf745623f8ce7b5f84c5216cb
child 496370 8c58dabcc0ee2e68333092f01dfccf38c26f7a41
push id48577
push userjwwang@mozilla.com
push dateFri, 10 Mar 2017 02:53:02 +0000
reviewerscpearce
bugs1345751
milestone55.0a1
Bug 1345751. P1 - remove the else branch for MediaShutdownManager ensures all media activities are finished before "xpcom-shutdown-threads" starts. r?cpearce MozReview-Commit-ID: BdNnlHEb1Nk
dom/media/FileBlockCache.cpp
--- a/dom/media/FileBlockCache.cpp
+++ b/dom/media/FileBlockCache.cpp
@@ -70,25 +70,19 @@ void FileBlockCache::Close()
   if (mThread) {
     // We must shut down the thread in another runnable. This is called
     // while we're shutting down the media cache, and nsIThread::Shutdown()
     // can cause events to run before it completes, which could end up
     // opening more streams, while the media cache is shutting down and
     // releasing memory etc! Also note we close mFD in the destructor so
     // as to not disturb any IO that's currently running.
     nsCOMPtr<nsIThread> mainThread = do_GetMainThread();
-    if (mainThread) {
-      nsCOMPtr<nsIRunnable> event = new ShutdownThreadEvent(mThread);
-      mainThread->Dispatch(event.forget(), NS_DISPATCH_NORMAL);
-    } else {
-      // we're on Mainthread already, *and* the event queues are already
-      // shut down, so no events should occur - certainly not creations of
-      // new streams.
-      mThread->Shutdown();
-    }
+    MOZ_ASSERT(mainThread);
+    nsCOMPtr<nsIRunnable> event = new ShutdownThreadEvent(mThread);
+    mainThread->Dispatch(event.forget(), NS_DISPATCH_NORMAL);
   }
 }
 
 template<typename Container, typename Value>
 bool
 ContainerContains(const Container& aContainer, const Value& value)
 {
   return std::find(aContainer.begin(), aContainer.end(), value)