Bug 1101328 - Use AsyncEventDispatcher to dispatch keyschange to MediaKeySession, since it doesn't require an nsIDocument. r=peterv
authorChris Pearce <cpearce@mozilla.com>
Thu, 11 Dec 2014 15:59:37 +1300
changeset 219235 af3dbca127d1e4f1acd54a3f6cec42eeea13b328
parent 219234 49a918ec025fba6c0fcfa83b404a10f2dd18b310
child 219236 1a2cec4f5833bc4583686dcc273f9734eeab2ff9
push id10368
push userkwierso@gmail.com
push dateFri, 12 Dec 2014 01:38:39 +0000
treeherderfx-team@5288b15d22de [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspeterv
bugs1101328
milestone37.0a1
Bug 1101328 - Use AsyncEventDispatcher to dispatch keyschange to MediaKeySession, since it doesn't require an nsIDocument. r=peterv
dom/media/eme/MediaKeySession.cpp
dom/media/eme/MediaKeys.cpp
dom/media/eme/MediaKeys.h
--- a/dom/media/eme/MediaKeySession.cpp
+++ b/dom/media/eme/MediaKeySession.cpp
@@ -286,23 +286,15 @@ MediaKeySession::DispatchKeyError(uint32
 }
 
 void
 MediaKeySession::DispatchKeysChange()
 {
   if (IsClosed()) {
     return;
   }
-  DebugOnly<nsresult> rv =
-    nsContentUtils::DispatchTrustedEvent(mKeys->GetOwnerDoc(),
-                                         this,
-                                         NS_LITERAL_STRING("keyschange"),
-                                         false,
-                                         false);
-#ifdef DEBUG
-  if (NS_FAILED(rv)) {
-    NS_WARNING("Failed to dispatch keyschange event");
-  }
-#endif
+  nsRefPtr<AsyncEventDispatcher> asyncDispatcher =
+    new AsyncEventDispatcher(this, NS_LITERAL_STRING("keyschange"), false);
+  asyncDispatcher->PostDOMEvent();
 }
 
 } // namespace dom
 } // namespace mozilla
--- a/dom/media/eme/MediaKeys.cpp
+++ b/dom/media/eme/MediaKeys.cpp
@@ -459,16 +459,10 @@ CopyArrayBufferViewOrArrayBufferData(con
     bufferview.ComputeLengthAndData();
     aOutData.AppendElements(bufferview.Data(), bufferview.Length());
   } else {
     return false;
   }
   return true;
 }
 
-nsIDocument*
-MediaKeys::GetOwnerDoc() const
-{
-  return mElement ? mElement->OwnerDoc() : nullptr;
-}
-
 } // namespace dom
 } // namespace mozilla
--- a/dom/media/eme/MediaKeys.h
+++ b/dom/media/eme/MediaKeys.h
@@ -106,20 +106,16 @@ public:
 
   // Returns true if this MediaKeys has been bound to a media element.
   bool IsBoundToMediaElement() const;
 
   // Return NS_OK if the principals are the same as when the MediaKeys
   // was created, failure otherwise.
   nsresult CheckPrincipals();
 
-  // Returns a pointer to the bound media element's owner doc.
-  // If we're not bound, this returns null.
-  nsIDocument* GetOwnerDoc() const;
-
 private:
 
   bool IsInPrivateBrowsing();
 
   // Removes promise from mPromises, and returns it.
   already_AddRefed<Promise> RetrievePromise(PromiseId aId);
 
   // Owning ref to proxy. The proxy has a weak reference back to the MediaKeys,