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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | media/cdm/aes_decryptor.cc » ('j') | media/cdm/aes_decryptor.cc » ('J')
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 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 } 427 }
428 428
429 adapter_->UpdateSession( 429 adapter_->UpdateSession(
430 session_id_, sanitized_response, 430 session_id_, sanitized_response,
431 std::unique_ptr<SimpleCdmPromise>(new CdmResultPromise<>( 431 std::unique_ptr<SimpleCdmPromise>(new CdmResultPromise<>(
432 result, adapter_->GetKeySystemUMAPrefix() + kUpdateSessionUMAName))); 432 result, adapter_->GetKeySystemUMAPrefix() + kUpdateSessionUMAName)));
433 } 433 }
434 434
435 void WebContentDecryptionModuleSessionImpl::close( 435 void WebContentDecryptionModuleSessionImpl::close(
436 blink::WebContentDecryptionModuleResult result) { 436 blink::WebContentDecryptionModuleResult result) {
437 // close() shouldn't be called if the session is already closed. blink
438 // prevents a second call to close(), but since the operation is
439 // asynchronous, there is a window where close() was called just before
440 // the closed event arrives. The CDM should handle the case where
441 // close() is called after it has already closed the session.
442 DCHECK(!session_id_.empty()); 437 DCHECK(!session_id_.empty());
443 DCHECK(!has_close_been_called_);
444 DCHECK(thread_checker_.CalledOnValidThread()); 438 DCHECK(thread_checker_.CalledOnValidThread());
445 439
440 // close() shouldn't be called if the session is already closed. Since the
441 // operation is asynchronous, there is a window where close() was called
442 // just before the closed event arrives. The CDM should handle the case where
443 // close() is called after it has already closed the session. However, if
444 // we can tell the session is now closed, simply resolve the promise.
445 if (is_closed_) {
446 result.complete();
447 return;
448 }
449
446 has_close_been_called_ = true; 450 has_close_been_called_ = true;
447 adapter_->CloseSession( 451 adapter_->CloseSession(
448 session_id_, 452 session_id_,
449 std::unique_ptr<SimpleCdmPromise>(new CdmResultPromise<>( 453 std::unique_ptr<SimpleCdmPromise>(new CdmResultPromise<>(
450 result, adapter_->GetKeySystemUMAPrefix() + kCloseSessionUMAName))); 454 result, adapter_->GetKeySystemUMAPrefix() + kCloseSessionUMAName)));
451 } 455 }
452 456
453 void WebContentDecryptionModuleSessionImpl::remove( 457 void WebContentDecryptionModuleSessionImpl::remove(
454 blink::WebContentDecryptionModuleResult result) { 458 blink::WebContentDecryptionModuleResult result) {
455 DCHECK(!session_id_.empty()); 459 DCHECK(!session_id_.empty());
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 520
517 DCHECK(session_id_.empty()) << "Session ID may not be changed once set."; 521 DCHECK(session_id_.empty()) << "Session ID may not be changed once set.";
518 session_id_ = session_id; 522 session_id_ = session_id;
519 *status = 523 *status =
520 adapter_->RegisterSession(session_id_, weak_ptr_factory_.GetWeakPtr()) 524 adapter_->RegisterSession(session_id_, weak_ptr_factory_.GetWeakPtr())
521 ? SessionInitStatus::NEW_SESSION 525 ? SessionInitStatus::NEW_SESSION
522 : SessionInitStatus::SESSION_ALREADY_EXISTS; 526 : SessionInitStatus::SESSION_ALREADY_EXISTS;
523 } 527 }
524 528
525 } // namespace media 529 } // namespace media
OLDNEW
« 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