Bug 1113474 - Release MediaKeys when cleaning up pending promises - r=jwwang a=lmandel
authorEdwin Flores <eflores@mozilla.com>
Wed, 11 Feb 2015 15:11:54 +1300
changeset 250206 706bf5c21e6d
parent 250205 c85410a124c6
child 250207 7a78fefaf5bd
push id4521
push usercpearce@mozilla.com
push date2015-03-04 01:22 +0000
treeherdermozilla-beta@8abdbdecd2d6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjwwang, lmandel
bugs1113474
milestone37.0
Bug 1113474 - Release MediaKeys when cleaning up pending promises - r=jwwang a=lmandel
dom/media/eme/MediaKeys.cpp
--- a/dom/media/eme/MediaKeys.cpp
+++ b/dom/media/eme/MediaKeys.cpp
@@ -77,16 +77,17 @@ CopySessions(const nsAString& aKey,
 }
 
 static PLDHashOperator
 CloseSessions(const nsAString& aKey,
               nsRefPtr<MediaKeySession>& aSession,
               void* aClosure)
 {
   aSession->OnClosed();
+  ((MediaKeys*)aClosure)->Release();
   return PL_DHASH_NEXT;
 }
 
 void
 MediaKeys::Terminated()
 {
   KeySessionHashMap keySessions;
   // Remove entries during iteration will screw it. Make a copy first.
@@ -106,17 +107,19 @@ MediaKeys::Terminated()
 void
 MediaKeys::Shutdown()
 {
   if (mProxy) {
     mProxy->Shutdown();
     mProxy = nullptr;
   }
 
-  mPromises.Enumerate(&RejectPromises, nullptr);
+  nsRefPtr<MediaKeys> kungFuDeathGrip = this;
+
+  mPromises.Enumerate(&RejectPromises, this);
   mPromises.Clear();
 }
 
 nsPIDOMWindow*
 MediaKeys::GetParentObject() const
 {
   return mParent;
 }