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
--- 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