Bug 1288976 - Use gmp-changed rather than gmp-path-added to retry MediaKeys requests. r=gerald
authorChris Pearce <cpearce@mozilla.com>
Mon, 25 Jul 2016 10:18:34 +1200
changeset 306284 9f4d0adc2e73
parent 306283 1523dc120715
child 306285 05b9ca6b58ec
push id30482
push usercbook@mozilla.com
push date2016-07-25 13:47 +0000
treeherdermozilla-central@f44bb9de08ad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgerald
bugs1288976
milestone50.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 1288976 - Use gmp-changed rather than gmp-path-added to retry MediaKeys requests. r=gerald We're already routing the "gmp-changed" observer service notification over from the chrome process to the content process, and it fires at pretty much the same time as the "gmp-path-added" notification (and a few more) so we can just switch to have the MediaKeySystemAccessManager listen on that notification instead, and we'll be e10s compatible. MozReview-Commit-ID: EowFDfdWgAJ
dom/ipc/ContentChild.cpp
dom/media/eme/MediaKeySystemAccessManager.cpp
dom/media/gmp/GMPServiceParent.cpp
--- a/dom/ipc/ContentChild.cpp
+++ b/dom/ipc/ContentChild.cpp
@@ -1678,16 +1678,19 @@ ContentChild::RecvNotifyPresentationRece
 
   return true;
 }
 
 bool
 ContentChild::RecvNotifyGMPsChanged()
 {
   GMPDecoderModule::UpdateUsableCodecs();
+  MOZ_ASSERT(NS_IsMainThread());
+  nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
+  obs->NotifyObservers(nullptr, "gmp-changed", nullptr);
   return true;
 }
 
 PCrashReporterChild*
 ContentChild::AllocPCrashReporterChild(const mozilla::dom::NativeThreadId& id,
                                        const uint32_t& processType)
 {
 #ifdef MOZ_CRASHREPORTER
--- a/dom/media/eme/MediaKeySystemAccessManager.cpp
+++ b/dom/media/eme/MediaKeySystemAccessManager.cpp
@@ -258,17 +258,17 @@ MediaKeySystemAccessManager::RetryReques
 
 nsresult
 MediaKeySystemAccessManager::Observe(nsISupports* aSubject,
                                      const char* aTopic,
                                      const char16_t* aData)
 {
   EME_LOG("MediaKeySystemAccessManager::Observe %s", aTopic);
 
-  if (!strcmp(aTopic, "gmp-path-added")) {
+  if (!strcmp(aTopic, "gmp-changed")) {
     nsTArray<PendingRequest> requests(Move(mRequests));
     // Retry all pending requests, but this time fail if the CDM is not installed.
     for (PendingRequest& request : requests) {
       RetryRequest(request);
     }
   } else if (!strcmp(aTopic, "timer-callback")) {
     // Find the timer that expired and re-run the request for it.
     nsCOMPtr<nsITimer> timer(do_QueryInterface(aSubject));
@@ -291,33 +291,33 @@ MediaKeySystemAccessManager::EnsureObser
   if (mAddedObservers) {
     return true;
   }
 
   nsCOMPtr<nsIObserverService> obsService = mozilla::services::GetObserverService();
   if (NS_WARN_IF(!obsService)) {
     return false;
   }
-  mAddedObservers = NS_SUCCEEDED(obsService->AddObserver(this, "gmp-path-added", false));
+  mAddedObservers = NS_SUCCEEDED(obsService->AddObserver(this, "gmp-changed", false));
   return mAddedObservers;
 }
 
 void
 MediaKeySystemAccessManager::Shutdown()
 {
   EME_LOG("MediaKeySystemAccessManager::Shutdown");
   nsTArray<PendingRequest> requests(Move(mRequests));
   for (PendingRequest& request : requests) {
     // Cancel all requests; we're shutting down.
     request.CancelTimer();
     request.RejectPromise(NS_LITERAL_CSTRING("Promise still outstanding at MediaKeySystemAccessManager shutdown"));
   }
   if (mAddedObservers) {
     nsCOMPtr<nsIObserverService> obsService = mozilla::services::GetObserverService();
     if (obsService) {
-      obsService->RemoveObserver(this, "gmp-path-added");
+      obsService->RemoveObserver(this, "gmp-changed");
       mAddedObservers = false;
     }
   }
 }
 
 } // namespace dom
 } // namespace mozilla
--- a/dom/media/gmp/GMPServiceParent.cpp
+++ b/dom/media/gmp/GMPServiceParent.cpp
@@ -1102,17 +1102,16 @@ GeckoMediaPluginServiceParent::AddOnGMPT
   RefPtr<GeckoMediaPluginServiceParent> self(this);
   return gmp->Init(this, directory)->Then(thread, __func__,
     [gmp, self, dir]() -> void {
       LOGD(("%s::%s: %s Succeeded", __CLASS__, __FUNCTION__, dir.get()));
       {
         MutexAutoLock lock(self->mMutex);
         self->mPlugins.AppendElement(gmp);
       }
-      NS_DispatchToMainThread(new NotifyObserversTask("gmp-path-added"), NS_DISPATCH_NORMAL);
     },
     [dir]() -> void {
       LOGD(("%s::%s: %s Failed", __CLASS__, __FUNCTION__, dir.get()));
     })
     ->CompletionPromise();
 }
 
 void