Bug 1360389 - Have ChromiumCDMParent inform CDMProxy of shutdown. r=gerald draft
authorChris Pearce <cpearce@mozilla.com>
Fri, 28 Apr 2017 12:02:14 +1200
changeset 569931 ff9ee3699915e8b7527570e839eb3bb0a0ab46bc
parent 569930 0612d199686278612e8c58dc97e96a9304ea3ee9
child 569948 c47b17d9bdebf843dfbce92f6eee439c4efe69e1
push id56324
push userbmo:cpearce@mozilla.com
push dateFri, 28 Apr 2017 03:50:02 +0000
reviewersgerald
bugs1360389
milestone55.0a1
Bug 1360389 - Have ChromiumCDMParent inform CDMProxy of shutdown. r=gerald The ChromiumCDMParent is informed of the shutdown of its plugin, so we can use that to inform the CDMProxy that its connection to the CDM has been severed. This means we shutdown cleanly if the browser closes while playing. MozReview-Commit-ID: HphQ2exu1gj
dom/media/gmp/ChromiumCDMParent.cpp
--- a/dom/media/gmp/ChromiumCDMParent.cpp
+++ b/dom/media/gmp/ChromiumCDMParent.cpp
@@ -1062,16 +1062,27 @@ ChromiumCDMParent::Shutdown()
 {
   GMP_LOG("ChromiumCDMParent::Shutdown(this=%p)", this);
 
   if (mIsShutdown) {
     return;
   }
   mIsShutdown = true;
 
+  // If we're shutting down due to the plugin shutting down due to application
+  // shutdown, we should tell the CDM proxy to also shutdown. Otherwise the
+  // proxy will shutdown when the owning MediaKeys is destroyed during cycle
+  // collection, and that will not shut down cleanly as the GMP thread will be
+  // shutdown by then.
+  if (mProxy) {
+    RefPtr<Runnable> task =
+      NewRunnableMethod(mProxy, &ChromiumCDMProxy::Shutdown);
+    NS_DispatchToMainThread(task.forget());
+  }
+
   // We may be called from a task holding the last reference to the proxy, so
   // let's clear our local weak pointer to ensure it will not be used afterward
   // (including from an already-queued task, e.g.: ActorDestroy).
   mProxy = nullptr;
 
   for (RefPtr<DecryptJob>& decrypt : mDecrypts) {
     decrypt->PostResult(AbortedErr);
   }