Bug 1274522. Part 2 - fix comments. r=gerald. draft 1274522_AsyncShutdown_MediaShutdownManager
authorJW Wang <jwwang@mozilla.com>
Tue, 24 May 2016 11:47:23 +0800
branch1274522_AsyncShutdown_MediaShutdownManager
changeset 370603 b0f4848dc4b411d3eaa17084d21716c62204f9bf
parent 370602 39cf90bef116438aa5013392c41c91efe9f499f0
child 370604 c08c82c76bef3d92bc11dd4076201c4cb89b1194
child 724575 cc7a59d7b4244a21ca4bf3f2ac90bee7963311cd
push id19124
push userjwwang@mozilla.com
push dateWed, 25 May 2016 06:27:58 +0000
reviewersgerald
bugs1274522
milestone49.0a1
Bug 1274522. Part 2 - fix comments. r=gerald. MozReview-Commit-ID: J7YKTy1m7PU
dom/media/MediaShutdownManager.cpp
dom/media/MediaShutdownManager.h
--- a/dom/media/MediaShutdownManager.cpp
+++ b/dom/media/MediaShutdownManager.cpp
@@ -74,17 +74,17 @@ MediaShutdownManager::EnsureCorrectShutd
         this, NS_LITERAL_STRING(__FILE__), __LINE__,
         NS_LITERAL_STRING("MediaShutdownManager shutdown"));
       MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv));
     } else {
       GetShutdownBarrier()->RemoveBlocker(this);
       // Clear our singleton reference. This will probably delete
       // this instance, so don't deref |this| clearing sInstance.
       sInstance = nullptr;
-      DECODER_LOG(LogLevel::Debug, ("MediaShutdownManager::Shutdown() end."));
+      DECODER_LOG(LogLevel::Debug, ("MediaShutdownManager::BlockShutdown() end."));
     }
   }
 }
 
 void
 MediaShutdownManager::Register(MediaDecoder* aDecoder)
 {
   MOZ_ASSERT(NS_IsMainThread());
@@ -121,17 +121,17 @@ MediaShutdownManager::GetState(nsIProper
 }
 
 NS_IMETHODIMP
 MediaShutdownManager::BlockShutdown(nsIAsyncShutdownClient*)
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(sInstance);
 
-  DECODER_LOG(LogLevel::Debug, ("MediaShutdownManager::Shutdown() start..."));
+  DECODER_LOG(LogLevel::Debug, ("MediaShutdownManager::BlockShutdown() start..."));
 
   // Set this flag to ensure no Register() is allowed when Shutdown() begins.
   mIsDoingXPCOMShutDown = true;
 
   DebugOnly<uint32_t> oldCount = mDecoders.Count();
   MOZ_ASSERT(oldCount > 0);
 
   // Iterate over the decoders and shut them down.
--- a/dom/media/MediaShutdownManager.h
+++ b/dom/media/MediaShutdownManager.h
@@ -16,39 +16,31 @@
 #include "nsHashKeys.h"
 #include "nsTHashtable.h"
 
 namespace mozilla {
 
 class MediaDecoder;
 
 // The MediaShutdownManager manages shutting down the MediaDecoder
-// infrastructure in response to an xpcom-shutdown notification. This happens
-// when Gecko is shutting down in the middle of operation. This is tricky, as
-// there are a number of moving parts that must be shutdown in a particular
-// order. Additionally the xpcom-shutdown observer *must* block until all
-// threads are shutdown, which is tricky since we have a number of threads
-// here and their shutdown is asynchronous. We can't have each element of
-// our pipeline listening for xpcom-shutdown, as if each observer blocks
-// waiting for its threads to shutdown it will block other xpcom-shutdown
-// notifications from firing, and shutdown of one part of the media pipeline
-// (say the State Machine thread) may depend another part to be shutdown
-// first (the MediaDecoder threads). The MediaShutdownManager encapsulates
-// all these dependencies, and provides a single xpcom-shutdown listener
-// for the MediaDecoder infrastructure, to ensure that no shutdown order
-// dependencies leak out of the MediaDecoder stack. The MediaShutdownManager
-// is a singleton.
+// infrastructure in response to an xpcom-shutdown notification.
+// This happens when Gecko is shutting down in the middle of operation.
+// This is tricky, as there are a number of moving parts that must
+// be shutdown in a particular order. The MediaShutdownManager
+// encapsulates all these dependencies to ensure that no shutdown
+// order dependencies leak out of the MediaDecoder stack.
+// The MediaShutdownManager is a singleton.
 //
-// The MediaShutdownManager ensures that the MediaDecoder stack is shutdown
-// before returning from its xpcom-shutdown observer by keeping track of all
-// the active MediaDecoders, and upon xpcom-shutdown calling Shutdown() on
-// every MediaDecoder and then spinning the main thread event loop until all
-// SharedThreadPools have shutdown. Once the SharedThreadPools are shutdown,
-// all the state machines and their threads have been shutdown, the
-// xpcom-shutdown observer returns.
+// The MediaShutdownManager ensures that the MediaDecoder stack
+// is shutdown before exiting xpcom-shutdown stage by registering
+// itself with nsIAsyncShutdownService to receive notification
+// when the stage of shutdown has started and then calls Shutdown()
+// on every MediaDecoder. Shutdown will not proceed until all
+// MediaDecoders finish shutdown and MediaShutdownManager unregisters
+// itself from the async shutdown service.
 //
 // Note that calling the Unregister() functions may result in the singleton
 // being deleted, so don't store references to the singleton, always use the
 // singleton by derefing the referenced returned by
 // MediaShutdownManager::Instance(), which ensures that the singleton is
 // created when needed.
 // i.e. like this:
 //    MediaShutdownManager::Instance()::Unregister(someDecoder);