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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "webcontentdecryptionmodulesession_impl.h" 5 #include "webcontentdecryptionmodulesession_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback_helpers.h" 8 #include "base/callback_helpers.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 } 428 }
429 429
430 adapter_->UpdateSession( 430 adapter_->UpdateSession(
431 session_id_, sanitized_response, 431 session_id_, sanitized_response,
432 std::unique_ptr<SimpleCdmPromise>(new CdmResultPromise<>( 432 std::unique_ptr<SimpleCdmPromise>(new CdmResultPromise<>(
433 result, adapter_->GetKeySystemUMAPrefix() + kUpdateSessionUMAName))); 433 result, adapter_->GetKeySystemUMAPrefix() + kUpdateSessionUMAName)));
434 } 434 }
435 435
436 void WebContentDecryptionModuleSessionImpl::close( 436 void WebContentDecryptionModuleSessionImpl::close(
437 blink::WebContentDecryptionModuleResult result) { 437 blink::WebContentDecryptionModuleResult result) {
438 // close() shouldn't be called if the session is already closed. blink
439 // prevents a second call to close(), but since the operation is
440 // asynchronous, there is a window where close() was called just before
441 // the closed event arrives. The CDM should handle the case where
442 // close() is called after it has already closed the session.
443 DCHECK(!session_id_.empty()); 438 DCHECK(!session_id_.empty());
444 DCHECK(!has_close_been_called_);
445 DCHECK(thread_checker_.CalledOnValidThread()); 439 DCHECK(thread_checker_.CalledOnValidThread());
446 440
441 // close() shouldn't be called if the session is already closed. Since the
442 // operation is asynchronous, there is a window where close() was called
443 // just before the closed event arrives. The CDM should handle the case where
444 // close() is called after it has already closed the session. However, if
445 // we can tell the session is now closed, simply resolve the promise.
446 if (is_closed_) {
447 result.complete();
448 return;
449 }
450
447 has_close_been_called_ = true; 451 has_close_been_called_ = true;
448 adapter_->CloseSession( 452 adapter_->CloseSession(
449 session_id_, 453 session_id_,
450 std::unique_ptr<SimpleCdmPromise>(new CdmResultPromise<>( 454 std::unique_ptr<SimpleCdmPromise>(new CdmResultPromise<>(
451 result, adapter_->GetKeySystemUMAPrefix() + kCloseSessionUMAName))); 455 result, adapter_->GetKeySystemUMAPrefix() + kCloseSessionUMAName)));
452 } 456 }
453 457
454 void WebContentDecryptionModuleSessionImpl::remove( 458 void WebContentDecryptionModuleSessionImpl::remove(
455 blink::WebContentDecryptionModuleResult result) { 459 blink::WebContentDecryptionModuleResult result) {
456 DCHECK(!session_id_.empty()); 460 DCHECK(!session_id_.empty());
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 521
518 DCHECK(session_id_.empty()) << "Session ID may not be changed once set."; 522 DCHECK(session_id_.empty()) << "Session ID may not be changed once set.";
519 session_id_ = session_id; 523 session_id_ = session_id;
520 *status = 524 *status =
521 adapter_->RegisterSession(session_id_, weak_ptr_factory_.GetWeakPtr()) 525 adapter_->RegisterSession(session_id_, weak_ptr_factory_.GetWeakPtr())
522 ? SessionInitStatus::NEW_SESSION 526 ? SessionInitStatus::NEW_SESSION
523 : SessionInitStatus::SESSION_ALREADY_EXISTS; 527 : SessionInitStatus::SESSION_ALREADY_EXISTS;
524 } 528 }
525 529
526 } // namespace media 530 } // namespace media
OLDNEW
« 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