Bug 1222888 - Implement MediaKeySession callable value. r=gerald

This commit is contained in:
Chris Pearce 2015-11-10 07:59:28 +13:00
Родитель e5a1a9af55
Коммит 386cb9ef1b
2 изменённых файлов: 34 добавлений и 0 удалений

Просмотреть файл

@ -264,6 +264,16 @@ MediaKeySession::Update(const ArrayBufferViewOrArrayBuffer& aResponse, ErrorResu
if (aRv.Failed()) {
return nullptr;
}
if (!IsCallable()) {
// If this object's callable value is false, return a promise rejected
// with a new DOMException whose name is InvalidStateError.
EME_LOG("MediaKeySession[%p,''] Update() called before sessionId set by CDM", this);
promise->MaybeReject(NS_ERROR_DOM_INVALID_STATE_ERR,
NS_LITERAL_CSTRING("MediaKeySession.Update() called before sessionId set by CDM"));
return promise.forget();
}
nsTArray<uint8_t> data;
if (IsClosed() || !mKeys->GetCDMProxy()) {
promise->MaybeReject(NS_ERROR_DOM_INVALID_STATE_ERR,
@ -309,6 +319,14 @@ MediaKeySession::Close(ErrorResult& aRv)
if (aRv.Failed()) {
return nullptr;
}
if (!IsCallable()) {
// If this object's callable value is false, return a promise rejected
// with a new DOMException whose name is InvalidStateError.
EME_LOG("MediaKeySession[%p,''] Close() called before sessionId set by CDM", this);
promise->MaybeReject(NS_ERROR_DOM_INVALID_STATE_ERR,
NS_LITERAL_CSTRING("MediaKeySession.Close() called before sessionId set by CDM"));
return promise.forget();
}
if (IsClosed() || !mKeys->GetCDMProxy()) {
EME_LOG("MediaKeySession[%p,'%s'] Close() already closed",
this, NS_ConvertUTF16toUTF8(mSessionId).get());
@ -352,6 +370,14 @@ MediaKeySession::Remove(ErrorResult& aRv)
if (aRv.Failed()) {
return nullptr;
}
if (!IsCallable()) {
// If this object's callable value is false, return a promise rejected
// with a new DOMException whose name is InvalidStateError.
EME_LOG("MediaKeySession[%p,''] Remove() called before sessionId set by CDM", this);
promise->MaybeReject(NS_ERROR_DOM_INVALID_STATE_ERR,
NS_LITERAL_CSTRING("MediaKeySession.Remove() called before sessionId set by CDM"));
return promise.forget();
}
if (mSessionType != SessionType::Persistent) {
promise->MaybeReject(NS_ERROR_DOM_INVALID_ACCESS_ERR,
NS_LITERAL_CSTRING("Calling MediaKeySession.remove() on non-persistent session"));

Просмотреть файл

@ -101,6 +101,14 @@ private:
~MediaKeySession();
void UpdateKeyStatusMap();
bool IsCallable() const {
// The EME spec sets the "callable value" to true whenever the CDM sets
// the sessionId. When the session is initialized, sessionId is empty and
// callable is thus false.
return !mSessionId.IsEmpty();
}
already_AddRefed<DetailedPromise> MakePromise(ErrorResult& aRv,
const nsACString& aName);