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

Unified Diff: media/blink/webcontentdecryptionmodulesession_impl.cc

Issue 2545083004: [eme] Handle multiple calls to MediaKeySession.close() (Closed)
Patch Set: rebase for MediaKeys rename 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 | « media/base/content_decryption_module.h ('k') | media/cdm/aes_decryptor.h » ('j') | no next file with comments »
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 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_,
« no previous file with comments | « media/base/content_decryption_module.h ('k') | media/cdm/aes_decryptor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698