diff options
Diffstat (limited to 'dom/media/eme/MediaKeySystemAccessManager.cpp')
-rw-r--r-- | dom/media/eme/MediaKeySystemAccessManager.cpp | 67 |
1 files changed, 26 insertions, 41 deletions
diff --git a/dom/media/eme/MediaKeySystemAccessManager.cpp b/dom/media/eme/MediaKeySystemAccessManager.cpp index 8ebe7ceee7..84389d1db0 100644 --- a/dom/media/eme/MediaKeySystemAccessManager.cpp +++ b/dom/media/eme/MediaKeySystemAccessManager.cpp @@ -368,8 +368,6 @@ void MediaKeySystemAccessManager::RequestMediaKeySystemAccess( // 5. Let promise be a new promise. // 6. Run the following steps in parallel: - DecoderDoctorDiagnostics diagnostics; - // 1. If keySystem is not one of the Key Systems supported by the user // agent, reject promise with a NotSupportedError. String comparison is // case-sensitive. @@ -383,7 +381,7 @@ void MediaKeySystemAccessManager::RequestMediaKeySystemAccess( // supported. aRequest->RejectPromiseWithNotSupportedError( "Key system is unsupported"_ns); - diagnostics.StoreMediaKeySystemAccess( + aRequest->mDiagnostics.StoreMediaKeySystemAccess( mWindow->GetExtantDoc(), aRequest->mKeySystem, false, __func__); return; } @@ -399,7 +397,7 @@ void MediaKeySystemAccessManager::RequestMediaKeySystemAccess( MediaKeySystemStatus::Api_disabled); } aRequest->RejectPromiseWithNotSupportedError("EME has been preffed off"_ns); - diagnostics.StoreMediaKeySystemAccess( + aRequest->mDiagnostics.StoreMediaKeySystemAccess( mWindow->GetExtantDoc(), aRequest->mKeySystem, false, __func__); return; } @@ -439,7 +437,7 @@ void MediaKeySystemAccessManager::RequestMediaKeySystemAccess( // "I can't play, updating" notification. aRequest->RejectPromiseWithNotSupportedError( "Timed out while waiting for a CDM update"_ns); - diagnostics.StoreMediaKeySystemAccess( + aRequest->mDiagnostics.StoreMediaKeySystemAccess( mWindow->GetExtantDoc(), aRequest->mKeySystem, false, __func__); return; } @@ -453,6 +451,7 @@ void MediaKeySystemAccessManager::RequestMediaKeySystemAccess( keySystem = NS_ConvertUTF8toUTF16(kWidevineExperimentKeySystemName); } #endif + auto& diagnostics = aRequest->mDiagnostics; if (AwaitInstall(std::move(aRequest))) { // Notify chrome that we're going to wait for the CDM to download/update. EME_LOG("Await %s for installation", @@ -480,25 +479,6 @@ void MediaKeySystemAccessManager::RequestMediaKeySystemAccess( return; } - nsCOMPtr<Document> doc = mWindow->GetExtantDoc(); - nsTHashMap<nsCharPtrHashKey, bool> warnings; - std::function<void(const char*)> deprecationWarningLogFn = - [&](const char* aMsgName) { - EME_LOG( - "MediaKeySystemAccessManager::DeprecationWarningLambda Logging " - "deprecation warning '%s' to WebConsole.", - aMsgName); - warnings.InsertOrUpdate(aMsgName, true); - AutoTArray<nsString, 1> params; - nsString& uri = *params.AppendElement(); - if (doc) { - Unused << doc->GetDocumentURI(uri); - } - nsContentUtils::ReportToConsole(nsIScriptError::warningFlag, "Media"_ns, - doc, nsContentUtils::eDOM_PROPERTIES, - aMsgName, params); - }; - bool isPrivateBrowsing = mWindow->GetExtantDoc() && mWindow->GetExtantDoc()->NodePrincipal()->GetPrivateBrowsingId() > 0; @@ -517,23 +497,28 @@ void MediaKeySystemAccessManager::RequestMediaKeySystemAccess( // 3. Let the cdm implementation value be implementation. // 2. Resolve promise with access and abort the parallel steps of this // algorithm. - MediaKeySystemConfiguration config; - if (MediaKeySystemAccess::GetSupportedConfig( - aRequest->mKeySystem, aRequest->mConfigs, config, &diagnostics, - isPrivateBrowsing, deprecationWarningLogFn)) { - aRequest->mSupportedConfig = Some(config); - // The app gets the final say on if we provide access or not. - CheckDoesAppAllowProtectedMedia(std::move(aRequest)); - return; - } - // 4. Reject promise with a NotSupportedError. - - // Not to inform user, because nothing to do if the corresponding keySystem - // configuration is not supported. - aRequest->RejectPromiseWithNotSupportedError( - "Key system configuration is not supported"_ns); - diagnostics.StoreMediaKeySystemAccess(mWindow->GetExtantDoc(), - aRequest->mKeySystem, false, __func__); + MediaKeySystemAccess::GetSupportedConfig(aRequest.get(), isPrivateBrowsing, + mWindow->GetExtantDoc()) + ->Then(GetMainThreadSerialEventTarget(), __func__, + [self = RefPtr<MediaKeySystemAccessManager>{this}, this, + request = UniquePtr<PendingRequest>{std::move(aRequest)}]( + const KeySystemConfig::KeySystemConfigPromise:: + ResolveOrRejectValue& aResult) mutable { + if (aResult.IsResolve()) { + request->mSupportedConfig = Some(aResult.ResolveValue()); + // The app gets the final say on if we provide access or not. + CheckDoesAppAllowProtectedMedia(std::move(request)); + } else { + // 4. Reject promise with a NotSupportedError. + // Not to inform user, because nothing to do if the + // corresponding keySystem configuration is not supported. + request->RejectPromiseWithNotSupportedError( + "Key system configuration is not supported"_ns); + request->mDiagnostics.StoreMediaKeySystemAccess( + mWindow->GetExtantDoc(), request->mKeySystem, false, + __func__); + } + }); } void MediaKeySystemAccessManager::ProvideAccess( |