Bug 1113474 - Keep MediaKeys alive until it has resolved all of its stored promises - r=cpearce
authorEdwin Flores <eflores@mozilla.com>
Wed, 11 Feb 2015 11:43:49 +1300
changeset 228547 e3b66bc377064b06a8484b04270778b210638e0e
parent 228546 6f42cfe37f5c43fd7ccc58c516f721508bd25ecd
child 228548 18ae6f259c06e373218bafb532b68c019777c055
push id28264
push usercbook@mozilla.com
push dateWed, 11 Feb 2015 13:58:35 +0000
treeherdermozilla-central@38058cb42a0e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpearce
bugs1113474
milestone38.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1113474 - Keep MediaKeys alive until it has resolved all of its stored promises - r=cpearce
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) {