| Index: media/blink/webcontentdecryptionmodulesession_impl.cc
|
| diff --git a/media/blink/webcontentdecryptionmodulesession_impl.cc b/media/blink/webcontentdecryptionmodulesession_impl.cc
|
| index 749987457900570b2c69caffbf47fc4770321698..d7cdb2cf39eec3e660a9850b7cbcdcfa47da6adc 100644
|
| --- a/media/blink/webcontentdecryptionmodulesession_impl.cc
|
| +++ b/media/blink/webcontentdecryptionmodulesession_impl.cc
|
| @@ -434,15 +434,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_,
|
|
|