| 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 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 std::unique_ptr<media::SimpleCdmPromise> promise( | 413 std::unique_ptr<media::SimpleCdmPromise> promise( |
| 414 new media::CdmCallbackPromise<>( | 414 new media::CdmCallbackPromise<>( |
| 415 base::Bind(&ClearKeyCdm::OnPromiseResolved, base::Unretained(this), | 415 base::Bind(&ClearKeyCdm::OnPromiseResolved, base::Unretained(this), |
| 416 promise_id), | 416 promise_id), |
| 417 base::Bind(&ClearKeyCdm::OnPromiseFailed, base::Unretained(this), | 417 base::Bind(&ClearKeyCdm::OnPromiseFailed, base::Unretained(this), |
| 418 promise_id))); | 418 promise_id))); |
| 419 decryptor_->UpdateSession( | 419 decryptor_->UpdateSession( |
| 420 web_session_str, std::vector<uint8_t>(response, response + response_size), | 420 web_session_str, std::vector<uint8_t>(response, response + response_size), |
| 421 std::move(promise)); | 421 std::move(promise)); |
| 422 | 422 |
| 423 if (key_system_ == kExternalClearKeyRenewalKeySystem && !renewal_timer_set_) { | 423 // TODO(xhwang): Only schedule renewal and update expiration change when the |
| 424 ScheduleNextRenewal(); | 424 // promise is resolved. |
| 425 renewal_timer_set_ = true; | 425 |
| 426 cdm::Time expiration = 0.0; // Never expires. |
| 427 |
| 428 if (key_system_ == kExternalClearKeyRenewalKeySystem) { |
| 429 // For renewal key system, set a non-zero expiration that is approximately |
| 430 // 100 years after 01 January 1970 UTC. |
| 431 expiration = 3153600000.0; // 100 * 365 * 24 * 60 * 60; |
| 432 |
| 433 if (!renewal_timer_set_) { |
| 434 ScheduleNextRenewal(); |
| 435 renewal_timer_set_ = true; |
| 436 } |
| 426 } | 437 } |
| 438 |
| 439 host_->OnExpirationChange(session_id, session_id_length, expiration); |
| 427 } | 440 } |
| 428 | 441 |
| 429 void ClearKeyCdm::CloseSession(uint32_t promise_id, | 442 void ClearKeyCdm::CloseSession(uint32_t promise_id, |
| 430 const char* session_id, | 443 const char* session_id, |
| 431 uint32_t session_id_length) { | 444 uint32_t session_id_length) { |
| 432 DVLOG(1) << __func__; | 445 DVLOG(1) << __func__; |
| 433 std::string web_session_str(session_id, session_id_length); | 446 std::string web_session_str(session_id, session_id_length); |
| 434 | 447 |
| 435 // If closing the loadable session, use the actual session id generated. | 448 // If closing the loadable session, use the actual session id generated. |
| 436 if (web_session_str == std::string(kLoadableSessionId)) | 449 if (web_session_str == std::string(kLoadableSessionId)) |
| (...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1025 challenge.data(), challenge.size()); | 1038 challenge.data(), challenge.size()); |
| 1026 } | 1039 } |
| 1027 | 1040 |
| 1028 void ClearKeyCdm::VerifyCdmHostTest() { | 1041 void ClearKeyCdm::VerifyCdmHostTest() { |
| 1029 // VerifyCdmHost() should have already been called and test result stored | 1042 // VerifyCdmHost() should have already been called and test result stored |
| 1030 // in |g_verify_host_files_result|. | 1043 // in |g_verify_host_files_result|. |
| 1031 OnUnitTestComplete(g_verify_host_files_result); | 1044 OnUnitTestComplete(g_verify_host_files_result); |
| 1032 } | 1045 } |
| 1033 | 1046 |
| 1034 } // namespace media | 1047 } // namespace media |
| OLD | NEW |