Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1048)

Unified Diff: media/blink/webcontentdecryptionmodulesession_impl.cc

Issue 2545083004: [eme] Handle multiple calls to MediaKeySession.close() (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | media/cdm/aes_decryptor.cc » ('j') | media/cdm/aes_decryptor.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_,
« no previous file with comments | « no previous file | media/cdm/aes_decryptor.cc » ('j') | media/cdm/aes_decryptor.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698