Bug 1314797 - Dispatch 'gmp-changed' notification after updating GMP capabilities. r?gerald
This ensures that when requests for keysystem access in the content process
retry, they do so on an up-to-date set of capabilities.
MozReview-Commit-ID: JxmlZnFhKYs
--- a/dom/ipc/ContentChild.cpp
+++ b/dom/ipc/ContentChild.cpp
@@ -1705,18 +1705,16 @@ 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;
}
bool
ContentChild::RecvNotifyEmptyHTTPCache()
{
MOZ_ASSERT(NS_IsMainThread());
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
--- a/dom/media/gmp/GMPServiceChild.cpp
+++ b/dom/media/gmp/GMPServiceChild.cpp
@@ -11,16 +11,18 @@
#include "mozIGeckoMediaPluginChromeService.h"
#include "nsCOMPtr.h"
#include "GMPParent.h"
#include "GMPContentParent.h"
#include "nsXPCOMPrivate.h"
#include "mozilla/SyncRunnable.h"
#include "runnable_utils.h"
#include "base/task.h"
+#include "nsIObserverService.h"
+#include "nsComponentManagerUtils.h"
namespace mozilla {
#ifdef LOG
#undef LOG
#endif
#define LOGD(msg) MOZ_LOG(GetGMPLog(), mozilla::LogLevel::Debug, msg)
@@ -201,16 +203,24 @@ GeckoMediaPluginServiceChild::UpdateGMPC
ClearOnShutdown(&sGMPCapabilities);
}
sGMPCapabilities->Clear();
for (const GMPCapabilityData& plugin : aCapabilities) {
sGMPCapabilities->AppendElement(GMPCapabilityAndVersion(plugin));
}
LOGD(("UpdateGMPCapabilities {%s}", GMPCapabilitiesToString().get()));
+
+ // Fire a notification so that any MediaKeySystemAccess
+ // requests waiting on a CDM to download will retry.
+ nsCOMPtr<nsIObserverService> obsService = mozilla::services::GetObserverService();
+ MOZ_ASSERT(obsService);
+ if (obsService) {
+ obsService->NotifyObservers(nullptr, "gmp-changed", nullptr);
+ }
}
NS_IMETHODIMP
GeckoMediaPluginServiceChild::GetPluginVersionForAPI(const nsACString& aAPI,
nsTArray<nsCString>* aTags,
bool* aHasPlugin,
nsACString& aOutVersion)
{
--- a/dom/media/gmp/GMPServiceParent.cpp
+++ b/dom/media/gmp/GMPServiceParent.cpp
@@ -834,19 +834,16 @@ GeckoMediaPluginServiceParent::PathRunna
{
mService->RemoveOnGMPThread(mPath,
mOperation == REMOVE_AND_DELETE_FROM_DISK,
mDefer);
mService->UpdateContentProcessGMPCapabilities();
#ifndef MOZ_WIDGET_GONK // Bug 1214967: disabled on B2G due to inscrutable test failures.
- // For e10s, we must fire a notification so that all ContentParents notify
- // their children to update the codecs that the GMPDecoderModule can use.
- NS_DispatchToMainThread(new NotifyObserversTask("gmp-changed"), NS_DISPATCH_NORMAL);
// For non-e10s, and for decoding in the chrome process, must update GMP
// PDM's codecs list directly.
NS_DispatchToMainThread(NS_NewRunnableFunction([]() -> void {
GMPDecoderModule::UpdateUsableCodecs();
}));
#endif
return NS_OK;
}
@@ -890,16 +887,24 @@ GeckoMediaPluginServiceParent::UpdateCon
x.capabilities().AppendElement(GMPAPITags(tag.mAPIName, tag.mAPITags));
}
caps.AppendElement(Move(x));
}
}
for (auto* cp : ContentParent::AllProcesses(ContentParent::eLive)) {
Unused << cp->SendGMPsChanged(caps);
}
+
+ // For non-e10s, we must fire a notification so that any MediaKeySystemAccess
+ // requests waiting on a CDM to download will retry.
+ nsCOMPtr<nsIObserverService> obsService = mozilla::services::GetObserverService();
+ MOZ_ASSERT(obsService);
+ if (obsService) {
+ obsService->NotifyObservers(nullptr, "gmp-changed", nullptr);
+ }
}
RefPtr<GenericPromise>
GeckoMediaPluginServiceParent::AsyncAddPluginDirectory(const nsAString& aDirectory)
{
RefPtr<AbstractThread> thread(GetAbstractGMPThread());
if (!thread) {
return GenericPromise::CreateAndReject(NS_ERROR_FAILURE, __func__);
@@ -908,23 +913,16 @@ GeckoMediaPluginServiceParent::AsyncAddP
nsString dir(aDirectory);
RefPtr<GeckoMediaPluginServiceParent> self = this;
return InvokeAsync(thread, this, __func__, &GeckoMediaPluginServiceParent::AddOnGMPThread, dir)
->Then(AbstractThread::MainThread(), __func__,
[dir, self]() -> void {
LOGD(("GeckoMediaPluginServiceParent::AsyncAddPluginDirectory %s succeeded",
NS_ConvertUTF16toUTF8(dir).get()));
MOZ_ASSERT(NS_IsMainThread());
- // For e10s, we must fire a notification so that all ContentParents notify
- // their children to update the codecs that the GMPDecoderModule can use.
- nsCOMPtr<nsIObserverService> obsService = mozilla::services::GetObserverService();
- MOZ_ASSERT(obsService);
- if (obsService) {
- obsService->NotifyObservers(nullptr, "gmp-changed", nullptr);
- }
self->UpdateContentProcessGMPCapabilities();
// For non-e10s, and for decoding in the chrome process, must update GMP
// PDM's codecs list directly.
GMPDecoderModule::UpdateUsableCodecs();
},
[dir]() -> void {
LOGD(("GeckoMediaPluginServiceParent::AsyncAddPluginDirectory %s failed",
NS_ConvertUTF16toUTF8(dir).get()));