зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1844169 - part7 : implement setServerCertificate. r=jolin
Differential Revision: https://phabricator.services.mozilla.com/D191353
This commit is contained in:
Родитель
89c1dfed16
Коммит
d28c7e7af7
|
@ -86,6 +86,12 @@ class WMFCDMImpl final {
|
|||
return mCDM->RemoveSession(aPromiseId, aSessionId);
|
||||
}
|
||||
|
||||
RefPtr<GenericPromise> SetServerCertificate(uint32_t aPromiseId,
|
||||
nsTArray<uint8_t>& aCert) {
|
||||
MOZ_DIAGNOSTIC_ASSERT(mCDM);
|
||||
return mCDM->SetServerCertificate(aPromiseId, aCert);
|
||||
}
|
||||
|
||||
uint64_t Id() {
|
||||
MOZ_DIAGNOSTIC_ASSERT(mCDM,
|
||||
"Should be called only after Init() is resolved");
|
||||
|
|
|
@ -311,6 +311,27 @@ void WMFCDMProxy::OnExpirationChange(const nsAString& aSessionId,
|
|||
}
|
||||
}
|
||||
|
||||
void WMFCDMProxy::SetServerCertificate(PromiseId aPromiseId,
|
||||
nsTArray<uint8_t>& aCert) {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
RETURN_IF_SHUTDOWN();
|
||||
EME_LOG("WMFCDMProxy::SetServerCertificate(this=%p, pid=%" PRIu32 ")", this,
|
||||
aPromiseId);
|
||||
mCDM->SetServerCertificate(aPromiseId, aCert)
|
||||
->Then(
|
||||
mMainThread, __func__,
|
||||
[self = RefPtr{this}, this, aPromiseId]() {
|
||||
RETURN_IF_SHUTDOWN();
|
||||
ResolvePromise(aPromiseId);
|
||||
},
|
||||
[self = RefPtr{this}, this, aPromiseId]() {
|
||||
RETURN_IF_SHUTDOWN();
|
||||
RejectPromiseWithStateError(
|
||||
aPromiseId,
|
||||
nsLiteralCString("WMFCDMProxy::SetServerCertificate failed!"));
|
||||
});
|
||||
}
|
||||
|
||||
bool WMFCDMProxy::IsHardwareDecryptionSupported() const {
|
||||
return mozilla::IsHardwareDecryptionSupported(mConfig);
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ class WMFCDMProxy : public CDMProxy {
|
|||
const nsAString& aSessionId) override;
|
||||
|
||||
void SetServerCertificate(PromiseId aPromiseId,
|
||||
nsTArray<uint8_t>& aCert) override {}
|
||||
nsTArray<uint8_t>& aCert) override;
|
||||
|
||||
void UpdateSession(const nsAString& aSessionId, PromiseId aPromiseId,
|
||||
nsTArray<uint8_t>& aResponse) override;
|
||||
|
|
|
@ -434,6 +434,49 @@ RefPtr<GenericPromise> MFCDMChild::RemoveSession(uint32_t aPromiseId,
|
|||
return mPendingGenericPromises[aPromiseId].Ensure(__func__);
|
||||
}
|
||||
|
||||
RefPtr<GenericPromise> MFCDMChild::SetServerCertificate(
|
||||
uint32_t aPromiseId, nsTArray<uint8_t>& aCert) {
|
||||
MOZ_ASSERT(mManagerThread);
|
||||
MOZ_ASSERT(mId > 0, "Should call Init() first and wait for it");
|
||||
|
||||
if (mShutdown) {
|
||||
return GenericPromise::CreateAndReject(NS_ERROR_ABORT, __func__);
|
||||
}
|
||||
|
||||
MOZ_ASSERT(mPendingGenericPromises.find(aPromiseId) ==
|
||||
mPendingGenericPromises.end());
|
||||
mPendingGenericPromises.emplace(aPromiseId,
|
||||
MozPromiseHolder<GenericPromise>{});
|
||||
mManagerThread->Dispatch(NS_NewRunnableFunction(
|
||||
__func__,
|
||||
[self = RefPtr{this}, this, cert = std::move(aCert), aPromiseId] {
|
||||
SendSetServerCertificate(cert)->Then(
|
||||
mManagerThread, __func__,
|
||||
[self, this, aPromiseId](
|
||||
PMFCDMChild::SetServerCertificatePromise::ResolveOrRejectValue&&
|
||||
aResult) {
|
||||
auto iter = mPendingGenericPromises.find(aPromiseId);
|
||||
if (iter == mPendingGenericPromises.end()) {
|
||||
return;
|
||||
}
|
||||
auto& promiseHolder = iter->second;
|
||||
if (aResult.IsResolve()) {
|
||||
if (NS_SUCCEEDED(aResult.ResolveValue())) {
|
||||
promiseHolder.ResolveIfExists(true, __func__);
|
||||
} else {
|
||||
promiseHolder.RejectIfExists(aResult.ResolveValue(),
|
||||
__func__);
|
||||
}
|
||||
} else {
|
||||
// IPC died
|
||||
promiseHolder.RejectIfExists(NS_ERROR_FAILURE, __func__);
|
||||
}
|
||||
mPendingGenericPromises.erase(iter);
|
||||
});
|
||||
}));
|
||||
return mPendingGenericPromises[aPromiseId].Ensure(__func__);
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult MFCDMChild::RecvOnSessionKeyMessage(
|
||||
const MFCDMKeyMessage& aMessage) {
|
||||
LOG("RecvOnSessionKeyMessage, sessionId=%s",
|
||||
|
|
|
@ -60,6 +60,9 @@ class MFCDMChild final : public PMFCDMChild {
|
|||
RefPtr<GenericPromise> RemoveSession(uint32_t aPromiseId,
|
||||
const nsAString& aSessionId);
|
||||
|
||||
RefPtr<GenericPromise> SetServerCertificate(uint32_t aPromiseId,
|
||||
nsTArray<uint8_t>& aCert);
|
||||
|
||||
mozilla::ipc::IPCResult RecvOnSessionKeyMessage(
|
||||
const MFCDMKeyMessage& aMessage);
|
||||
mozilla::ipc::IPCResult RecvOnSessionKeyStatusesChanged(
|
||||
|
|
|
@ -843,6 +843,20 @@ mozilla::ipc::IPCResult MFCDMParent::RecvRemoveSession(
|
|||
return IPC_OK();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult MFCDMParent::RecvSetServerCertificate(
|
||||
const CopyableTArray<uint8_t>& aCertificate,
|
||||
UpdateSessionResolver&& aResolver) {
|
||||
MOZ_ASSERT(mCDM, "RecvInit() must be called and waited on before this call");
|
||||
nsresult rv = NS_OK;
|
||||
MFCDM_PARENT_LOG("Set server certificate");
|
||||
MFCDM_REJECT_IF_FAILED(mCDM->SetServerCertificate(
|
||||
static_cast<const BYTE*>(aCertificate.Elements()),
|
||||
aCertificate.Length()),
|
||||
NS_ERROR_DOM_MEDIA_CDM_ERR);
|
||||
aResolver(rv);
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
void MFCDMParent::ConnectSessionEvents(MFCDMSession* aSession) {
|
||||
// TODO : clear session's event source when the session gets removed.
|
||||
mKeyMessageEvents.Forward(aSession->KeyMessageEvent());
|
||||
|
|
|
@ -64,6 +64,10 @@ class MFCDMParent final : public PMFCDMParent {
|
|||
mozilla::ipc::IPCResult RecvRemoveSession(const nsString& aSessionId,
|
||||
UpdateSessionResolver&& aResolver);
|
||||
|
||||
mozilla::ipc::IPCResult RecvSetServerCertificate(
|
||||
const CopyableTArray<uint8_t>& aCertificate,
|
||||
UpdateSessionResolver&& aResolver);
|
||||
|
||||
nsISerialEventTarget* ManagerThread() { return mManagerThread; }
|
||||
void AssertOnManagerThread() const {
|
||||
MOZ_ASSERT(mManagerThread->IsOnCurrentThread());
|
||||
|
|
|
@ -106,6 +106,7 @@ parent:
|
|||
async UpdateSession(nsString sessionId, uint8_t[] response) returns (nsresult result);
|
||||
async CloseSession(nsString sessionId) returns (nsresult result);
|
||||
async RemoveSession(nsString sessionId) returns (nsresult result);
|
||||
async SetServerCertificate(uint8_t[] certificate) returns (nsresult result);
|
||||
async __delete__();
|
||||
|
||||
child:
|
||||
|
|
Загрузка…
Ссылка в новой задаче