| Index: media/blink/webcontentdecryptionmodulesession_impl.cc
|
| diff --git a/media/blink/webcontentdecryptionmodulesession_impl.cc b/media/blink/webcontentdecryptionmodulesession_impl.cc
|
| index 2ee66b0d3c087a7542747454fc204b6c6f5deb3e..707fe5a0d39986bac1b1de342586d371817c6290 100644
|
| --- a/media/blink/webcontentdecryptionmodulesession_impl.cc
|
| +++ b/media/blink/webcontentdecryptionmodulesession_impl.cc
|
| @@ -435,15 +435,19 @@ void WebContentDecryptionModuleSessionImpl::update(
|
|
|
| void WebContentDecryptionModuleSessionImpl::close(
|
| blink::WebContentDecryptionModuleResult result) {
|
| - // close() shouldn't be called if the session is already closed. blink
|
| - // prevents a second call to close(), but since the operation is
|
| - // asynchronous, there is a window where close() was called just before
|
| - // the closed event arrives. The CDM should handle the case where
|
| - // close() is called after it has already closed the session.
|
| DCHECK(!session_id_.empty());
|
| - DCHECK(!has_close_been_called_);
|
| DCHECK(thread_checker_.CalledOnValidThread());
|
|
|
| + // close() shouldn't be called if the session is already closed. Since the
|
| + // operation is asynchronous, there is a window where close() was called
|
| + // just before the closed event arrives. The CDM should handle the case where
|
| + // close() is called after it has already closed the session. However, if
|
| + // we can tell the session is now closed, simply resolve the promise.
|
| + if (is_closed_) {
|
| + result.complete();
|
| + return;
|
| + }
|
| +
|
| has_close_been_called_ = true;
|
| adapter_->CloseSession(
|
| session_id_,
|
|
|