Bug 1540136 - P2: CDMProxy stores main thread as nsISerialEventTarget, rather than nsIEventTarget. r=cpearce
authorBryce Van Dyk <bvandyk@mozilla.com>
Tue, 09 Apr 2019 15:06:38 +0000
changeset 468578 bc7e92510e95a39fef9f9fc32224c416e9d6f11f
parent 468577 7c83e08566d34fe194069a5219a16755d1cbe757
child 468579 7178347182f50db3fce7af4910e97274d11cb7fa
push id35843
push usernbeleuzu@mozilla.com
push dateTue, 09 Apr 2019 22:08:13 +0000
treeherdermozilla-central@a31032a16330 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpearce
bugs1540136
milestone68.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 1540136 - P2: CDMProxy stores main thread as nsISerialEventTarget, rather than nsIEventTarget. r=cpearce This gives us greater flexibility in using the main thread member to run promises. The site where we obtain the main thread returns a serial event target, so we're not doing much more work here, we're just keeping the serial event target interface, rather than converting to an event target interface. Differential Revision: https://phabricator.services.mozilla.com/D26205
dom/media/eme/CDMProxy.h
dom/media/eme/MediaKeys.cpp
dom/media/eme/MediaKeys.h
dom/media/eme/mediadrm/MediaDrmCDMProxy.cpp
dom/media/eme/mediadrm/MediaDrmCDMProxy.h
dom/media/gmp/ChromiumCDMProxy.cpp
dom/media/gmp/ChromiumCDMProxy.h
--- a/dom/media/eme/CDMProxy.h
+++ b/dom/media/eme/CDMProxy.h
@@ -77,17 +77,17 @@ class CDMProxy {
   typedef dom::MediaKeySessionType MediaKeySessionType;
 
  public:
   NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING
 
   // Main thread only.
   CDMProxy(dom::MediaKeys* aKeys, const nsAString& aKeySystem,
            bool aDistinctiveIdentifierRequired, bool aPersistentStateRequired,
-           nsIEventTarget* aMainThread)
+           nsISerialEventTarget* aMainThread)
       : mKeys(aKeys),
         mKeySystem(aKeySystem),
         mCapabilites("CDMProxy::mCDMCaps"),
         mDistinctiveIdentifierRequired(aDistinctiveIdentifierRequired),
         mPersistentStateRequired(aPersistentStateRequired),
         mMainThread(aMainThread) {}
 
   // Main thread only.
@@ -267,14 +267,14 @@ class CDMProxy {
   nsCString mNodeId;
 
   DataMutex<CDMCaps> mCapabilites;
 
   const bool mDistinctiveIdentifierRequired;
   const bool mPersistentStateRequired;
 
   // The main thread associated with the root document.
-  const nsCOMPtr<nsIEventTarget> mMainThread;
+  const nsCOMPtr<nsISerialEventTarget> mMainThread;
 };
 
 }  // namespace mozilla
 
 #endif  // CDMProxy_h_
--- a/dom/media/eme/MediaKeys.cpp
+++ b/dom/media/eme/MediaKeys.cpp
@@ -367,17 +367,17 @@ class MediaKeysGMPCrashHelper : public G
                : nullptr;
   }
 
  private:
   WeakPtr<MediaKeys> mMediaKeys;
 };
 
 already_AddRefed<CDMProxy> MediaKeys::CreateCDMProxy(
-    nsIEventTarget* aMainThread) {
+    nsISerialEventTarget* aMainThread) {
   EME_LOG("MediaKeys[%p]::CreateCDMProxy()", this);
   RefPtr<CDMProxy> proxy;
 #ifdef MOZ_WIDGET_ANDROID
   if (IsWidevineKeySystem(mKeySystem)) {
     proxy = new MediaDrmCDMProxy(
         this, mKeySystem,
         mConfig.mDistinctiveIdentifier == MediaKeysRequirement::Required,
         mConfig.mPersistentState == MediaKeysRequirement::Required,
--- a/dom/media/eme/MediaKeys.h
+++ b/dom/media/eme/MediaKeys.h
@@ -150,17 +150,17 @@ class MediaKeys final : public nsIDocume
 
   template <typename T>
   void ResolvePromiseWithResult(PromiseId aId, const T& aResult);
 
  private:
   // Instantiate CDMProxy instance.
   // It could be MediaDrmCDMProxy (Widevine on Fennec) or ChromiumCDMProxy (the
   // rest).
-  already_AddRefed<CDMProxy> CreateCDMProxy(nsIEventTarget* aMainThread);
+  already_AddRefed<CDMProxy> CreateCDMProxy(nsISerialEventTarget* aMainThread);
 
   // Removes promise from mPromises, and returns it.
   already_AddRefed<DetailedPromise> RetrievePromise(PromiseId aId);
 
   void RegisterActivityObserver();
   void UnregisterActivityObserver();
 
   // Owning ref to proxy. The proxy has a weak reference back to the MediaKeys,
--- a/dom/media/eme/mediadrm/MediaDrmCDMProxy.cpp
+++ b/dom/media/eme/mediadrm/MediaDrmCDMProxy.cpp
@@ -23,17 +23,17 @@ MediaDrmSessionType ToMediaDrmSessionTyp
       return kKeyStreaming;
   };
 }
 
 MediaDrmCDMProxy::MediaDrmCDMProxy(dom::MediaKeys* aKeys,
                                    const nsAString& aKeySystem,
                                    bool aDistinctiveIdentifierRequired,
                                    bool aPersistentStateRequired,
-                                   nsIEventTarget* aMainThread)
+                                   nsISerialEventTarget* aMainThread)
     : CDMProxy(aKeys, aKeySystem, aDistinctiveIdentifierRequired,
                aPersistentStateRequired, aMainThread),
       mCDM(nullptr),
       mShutdownCalled(false) {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_COUNT_CTOR(MediaDrmCDMProxy);
 }
 
--- a/dom/media/eme/mediadrm/MediaDrmCDMProxy.h
+++ b/dom/media/eme/mediadrm/MediaDrmCDMProxy.h
@@ -26,17 +26,18 @@ namespace mozilla {
 
 class MediaDrmCDMCallbackProxy;
 class MediaDrmCDMProxy : public CDMProxy {
  public:
   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MediaDrmCDMProxy, override)
 
   MediaDrmCDMProxy(dom::MediaKeys* aKeys, const nsAString& aKeySystem,
                    bool aDistinctiveIdentifierRequired,
-                   bool aPersistentStateRequired, nsIEventTarget* aMainThread);
+                   bool aPersistentStateRequired,
+                   nsISerialEventTarget* aMainThread);
 
   void Init(PromiseId aPromiseId, const nsAString& aOrigin,
             const nsAString& aTopLevelOrigin,
             const nsAString& aGMPName) override;
 
   void CreateSession(uint32_t aCreateSessionToken,
                      MediaKeySessionType aSessionType, PromiseId aPromiseId,
                      const nsAString& aInitDataType,
--- a/dom/media/gmp/ChromiumCDMProxy.cpp
+++ b/dom/media/gmp/ChromiumCDMProxy.cpp
@@ -17,17 +17,17 @@
 
 namespace mozilla {
 
 ChromiumCDMProxy::ChromiumCDMProxy(dom::MediaKeys* aKeys,
                                    const nsAString& aKeySystem,
                                    GMPCrashHelper* aCrashHelper,
                                    bool aDistinctiveIdentifierRequired,
                                    bool aPersistentStateRequired,
-                                   nsIEventTarget* aMainThread)
+                                   nsISerialEventTarget* aMainThread)
     : CDMProxy(aKeys, aKeySystem, aDistinctiveIdentifierRequired,
                aPersistentStateRequired, aMainThread),
       mCrashHelper(aCrashHelper),
       mCDMMutex("ChromiumCDMProxy"),
       mGMPThread(GetGMPAbstractThread()) {
   MOZ_ASSERT(NS_IsMainThread());
 }
 
--- a/dom/media/gmp/ChromiumCDMProxy.h
+++ b/dom/media/gmp/ChromiumCDMProxy.h
@@ -18,17 +18,17 @@ class DecryptJob;
 class ChromiumCDMCallbackProxy;
 class ChromiumCDMProxy : public CDMProxy {
  public:
   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(ChromiumCDMProxy, override)
 
   ChromiumCDMProxy(dom::MediaKeys* aKeys, const nsAString& aKeySystem,
                    GMPCrashHelper* aCrashHelper,
                    bool aAllowDistinctiveIdentifier, bool aAllowPersistentState,
-                   nsIEventTarget* aMainThread);
+                   nsISerialEventTarget* aMainThread);
 
   void Init(PromiseId aPromiseId, const nsAString& aOrigin,
             const nsAString& aTopLevelOrigin,
             const nsAString& aGMPName) override;
 
   void CreateSession(uint32_t aCreateSessionToken,
                      dom::MediaKeySessionType aSessionType,
                      PromiseId aPromiseId, const nsAString& aInitDataType,