| 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 "media/cdm/ppapi/external_clear_key/clear_key_cdm.h" | 5 #include "media/cdm/ppapi/external_clear_key/clear_key_cdm.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cstring> | 8 #include <cstring> |
| 9 #include <sstream> | 9 #include <sstream> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 | 323 |
| 324 namespace media { | 324 namespace media { |
| 325 | 325 |
| 326 ClearKeyCdm::ClearKeyCdm(ClearKeyCdmHost* host, | 326 ClearKeyCdm::ClearKeyCdm(ClearKeyCdmHost* host, |
| 327 const std::string& key_system, | 327 const std::string& key_system, |
| 328 const GURL& origin) | 328 const GURL& origin) |
| 329 : decryptor_(new AesDecryptor( | 329 : decryptor_(new AesDecryptor( |
| 330 origin, | 330 origin, |
| 331 base::Bind(&ClearKeyCdm::OnSessionMessage, base::Unretained(this)), | 331 base::Bind(&ClearKeyCdm::OnSessionMessage, base::Unretained(this)), |
| 332 base::Bind(&ClearKeyCdm::OnSessionClosed, base::Unretained(this)), | 332 base::Bind(&ClearKeyCdm::OnSessionClosed, base::Unretained(this)), |
| 333 base::Bind(&ClearKeyCdm::OnSessionKeysChange, | 333 base::Bind(&ClearKeyCdm::OnSessionKeysChange, base::Unretained(this)), |
| 334 base::Bind(&ClearKeyCdm::OnSessionExpirationUpdate, |
| 334 base::Unretained(this)))), | 335 base::Unretained(this)))), |
| 335 host_(host), | 336 host_(host), |
| 336 key_system_(key_system), | 337 key_system_(key_system), |
| 337 has_received_keys_change_event_for_emulated_loadsession_(false), | 338 has_received_keys_change_event_for_emulated_loadsession_(false), |
| 338 timer_delay_ms_(kInitialTimerDelayMs), | 339 timer_delay_ms_(kInitialTimerDelayMs), |
| 339 renewal_timer_set_(false), | 340 renewal_timer_set_(false), |
| 340 is_running_output_protection_test_(false), | 341 is_running_output_protection_test_(false), |
| 341 is_running_platform_verification_test_(false) { | 342 is_running_platform_verification_test_(false) { |
| 342 #if defined(CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER) | 343 #if defined(CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER) |
| 343 channel_count_ = 0; | 344 channel_count_ = 0; |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 decryptor_->CloseSession(web_session_str, std::move(promise)); | 483 decryptor_->CloseSession(web_session_str, std::move(promise)); |
| 483 } | 484 } |
| 484 | 485 |
| 485 void ClearKeyCdm::RemoveSession(uint32_t promise_id, | 486 void ClearKeyCdm::RemoveSession(uint32_t promise_id, |
| 486 const char* session_id, | 487 const char* session_id, |
| 487 uint32_t session_id_length) { | 488 uint32_t session_id_length) { |
| 488 DVLOG(1) << __func__; | 489 DVLOG(1) << __func__; |
| 489 std::string web_session_str(session_id, session_id_length); | 490 std::string web_session_str(session_id, session_id_length); |
| 490 | 491 |
| 491 // RemoveSession only allowed for the loadable session. | 492 // RemoveSession only allowed for the loadable session. |
| 492 if (web_session_str == std::string(kLoadableSessionId)) { | 493 if (web_session_str == std::string(kLoadableSessionId)) |
| 493 web_session_str = session_id_for_emulated_loadsession_; | 494 web_session_str = session_id_for_emulated_loadsession_; |
| 494 } else { | |
| 495 // TODO(jrummell): This should be a DCHECK once blink does the proper | |
| 496 // checks. | |
| 497 std::string message("Not supported for non-persistent sessions."); | |
| 498 host_->OnRejectPromise(promise_id, | |
| 499 cdm::kInvalidAccessError, | |
| 500 0, | |
| 501 message.data(), | |
| 502 message.length()); | |
| 503 return; | |
| 504 } | |
| 505 | 495 |
| 506 std::unique_ptr<media::SimpleCdmPromise> promise( | 496 std::unique_ptr<media::SimpleCdmPromise> promise( |
| 507 new media::CdmCallbackPromise<>( | 497 new media::CdmCallbackPromise<>( |
| 508 base::Bind(&ClearKeyCdm::OnPromiseResolved, base::Unretained(this), | 498 base::Bind(&ClearKeyCdm::OnPromiseResolved, base::Unretained(this), |
| 509 promise_id), | 499 promise_id), |
| 510 base::Bind(&ClearKeyCdm::OnPromiseFailed, base::Unretained(this), | 500 base::Bind(&ClearKeyCdm::OnPromiseFailed, base::Unretained(this), |
| 511 promise_id))); | 501 promise_id))); |
| 512 decryptor_->RemoveSession(web_session_str, std::move(promise)); | 502 decryptor_->RemoveSession(web_session_str, std::move(promise)); |
| 513 } | 503 } |
| 514 | 504 |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 885 keys_vector.size()); | 875 keys_vector.size()); |
| 886 } | 876 } |
| 887 | 877 |
| 888 void ClearKeyCdm::OnSessionClosed(const std::string& session_id) { | 878 void ClearKeyCdm::OnSessionClosed(const std::string& session_id) { |
| 889 std::string new_session_id = session_id; | 879 std::string new_session_id = session_id; |
| 890 if (new_session_id == session_id_for_emulated_loadsession_) | 880 if (new_session_id == session_id_for_emulated_loadsession_) |
| 891 new_session_id = std::string(kLoadableSessionId); | 881 new_session_id = std::string(kLoadableSessionId); |
| 892 host_->OnSessionClosed(new_session_id.data(), new_session_id.length()); | 882 host_->OnSessionClosed(new_session_id.data(), new_session_id.length()); |
| 893 } | 883 } |
| 894 | 884 |
| 885 void ClearKeyCdm::OnSessionExpirationUpdate(const std::string& session_id, |
| 886 base::Time new_expiry_time) { |
| 887 std::string new_session_id = session_id; |
| 888 if (new_session_id == session_id_for_emulated_loadsession_) |
| 889 new_session_id = std::string(kLoadableSessionId); |
| 890 host_->OnExpirationChange(new_session_id.data(), new_session_id.length(), |
| 891 new_expiry_time.ToDoubleT()); |
| 892 } |
| 893 |
| 895 void ClearKeyCdm::OnSessionCreated(uint32_t promise_id, | 894 void ClearKeyCdm::OnSessionCreated(uint32_t promise_id, |
| 896 const std::string& session_id) { | 895 const std::string& session_id) { |
| 897 // Save the latest session ID for renewal and file IO test messages. | 896 // Save the latest session ID for renewal and file IO test messages. |
| 898 last_session_id_ = session_id; | 897 last_session_id_ = session_id; |
| 899 | 898 |
| 900 host_->OnResolveNewSessionPromise(promise_id, session_id.data(), | 899 host_->OnResolveNewSessionPromise(promise_id, session_id.data(), |
| 901 session_id.length()); | 900 session_id.length()); |
| 902 } | 901 } |
| 903 | 902 |
| 904 void ClearKeyCdm::OnSessionLoaded(uint32_t promise_id, | 903 void ClearKeyCdm::OnSessionLoaded(uint32_t promise_id, |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1065 challenge.data(), challenge.size()); | 1064 challenge.data(), challenge.size()); |
| 1066 } | 1065 } |
| 1067 | 1066 |
| 1068 void ClearKeyCdm::VerifyCdmHostTest() { | 1067 void ClearKeyCdm::VerifyCdmHostTest() { |
| 1069 // VerifyCdmHost() should have already been called and test result stored | 1068 // VerifyCdmHost() should have already been called and test result stored |
| 1070 // in |g_verify_host_files_result|. | 1069 // in |g_verify_host_files_result|. |
| 1071 OnUnitTestComplete(g_verify_host_files_result); | 1070 OnUnitTestComplete(g_verify_host_files_result); |
| 1072 } | 1071 } |
| 1073 | 1072 |
| 1074 } // namespace media | 1073 } // namespace media |
| OLD | NEW |