| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |