Bug 1113474 - Keep MediaKeys alive until it has resolved all of its stored promises - r=cpearce a=lmandel
authorEdwin Flores <eflores@mozilla.com>
Wed, 11 Feb 2015 11:43:49 +1300
changeset 250205 c85410a124c6
parent 250204 d72d2f792d90
child 250206 706bf5c21e6d
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)
reviewerscpearce, lmandel
bugs1113474
milestone37.0
Bug 1113474 - Keep MediaKeys alive until it has resolved all of its stored promises - r=cpearce a=lmandel
dom/media/eme/MediaKeys.cpp
--- a/dom/media/eme/MediaKeys.cpp
+++ b/dom/media/eme/MediaKeys.cpp
@@ -164,26 +164,32 @@ MediaKeys::MakePromise(ErrorResult& aRv)
 }
 
 PromiseId
 MediaKeys::StorePromise(Promise* aPromise)
 {
   static uint32_t sEMEPromiseCount = 1;
   MOZ_ASSERT(aPromise);
   uint32_t id = sEMEPromiseCount++;
+
+  // Keep MediaKeys alive for the lifetime of its promises. Any still-pending
+  // promises are rejected in Shutdown().
+  AddRef();
+
   mPromises.Put(id, aPromise);
   return id;
 }
 
 already_AddRefed<Promise>
 MediaKeys::RetrievePromise(PromiseId aId)
 {
   MOZ_ASSERT(mPromises.Contains(aId));
   nsRefPtr<Promise> promise;
   mPromises.Remove(aId, getter_AddRefs(promise));
+  Release();
   return promise.forget();
 }
 
 void
 MediaKeys::RejectPromise(PromiseId aId, nsresult aExceptionCode)
 {
   nsRefPtr<Promise> promise(RetrievePromise(aId));
   if (!promise) {