Bug 1288976 - Only retry MediaKeySystemAccess requests on 'gmp-changed' notification if the CDM is now installed. r=gerald

This ensures we'll only retry requests if we know the install operation has
completed for a given GMP. This means if (say) OpenH264 happens to install
while we have a Widevine request pending, we won't retry the Widevine request,
as that would fail. The Widevine request will retry once the Widevine CDM
has downloaded and in turn fires its gmp-changed notification.



MozReview-Commit-ID: E3CV9uID4pS

--HG--
extra : rebase_source : 4e27210a9e6c28118e93f45846b63aaa64f5882d
This commit is contained in:
Chris Pearce 2016-07-25 13:38:08 +12:00
parent d183d8433b
commit d29928ce19

View File

@ -264,7 +264,30 @@ MediaKeySystemAccessManager::Observe(nsISupports* aSubject,
EME_LOG("MediaKeySystemAccessManager::Observe %s", aTopic);
if (!strcmp(aTopic, "gmp-changed")) {
nsTArray<PendingRequest> requests(Move(mRequests));
// Filter out the requests where the CDM's install-status is no longer
// "unavailable". This will be the CDMs which have downloaded since the
// initial request.
// Note: We don't have a way to communicate from chrome that the CDM has
// failed to download, so we'll just let the timeout fail us in that case.
nsTArray<PendingRequest> requests;
for (size_t i = mRequests.Length(); i > 0; i--) {
const size_t index = i - i;
PendingRequest& request = mRequests[index];
nsAutoCString message;
nsAutoCString cdmVersion;
MediaKeySystemStatus status =
MediaKeySystemAccess::GetKeySystemStatus(request.mKeySystem,
NO_CDM_VERSION,
message,
cdmVersion);
if (status == MediaKeySystemStatus::Cdm_not_installed) {
// Not yet installed, don't retry. Keep waiting until timeout.
continue;
}
// Status has changed, retry request.
requests.AppendElement(Move(request));
mRequests.RemoveElementAt(index);
}
// Retry all pending requests, but this time fail if the CDM is not installed.
for (PendingRequest& request : requests) {
RetryRequest(request);