| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/renderer/pepper/content_decryptor_delegate.h" | 5 #include "content/renderer/pepper/content_decryptor_delegate.h" |
| 6 | 6 |
| 7 #include <string.h> | 7 #include <string.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 735 } | 735 } |
| 736 | 736 |
| 737 void ContentDecryptorDelegate::OnPromiseResolved(uint32_t promise_id) { | 737 void ContentDecryptorDelegate::OnPromiseResolved(uint32_t promise_id) { |
| 738 cdm_promise_adapter_.ResolvePromise(promise_id); | 738 cdm_promise_adapter_.ResolvePromise(promise_id); |
| 739 } | 739 } |
| 740 | 740 |
| 741 void ContentDecryptorDelegate::OnPromiseResolvedWithSession(uint32_t promise_id, | 741 void ContentDecryptorDelegate::OnPromiseResolvedWithSession(uint32_t promise_id, |
| 742 PP_Var session_id) { | 742 PP_Var session_id) { |
| 743 StringVar* session_id_string = StringVar::FromPPVar(session_id); | 743 StringVar* session_id_string = StringVar::FromPPVar(session_id); |
| 744 DCHECK(session_id_string); | 744 DCHECK(session_id_string); |
| 745 cdm_session_tracker_.AddSession(session_id_string->value()); |
| 745 cdm_promise_adapter_.ResolvePromise(promise_id, session_id_string->value()); | 746 cdm_promise_adapter_.ResolvePromise(promise_id, session_id_string->value()); |
| 746 } | 747 } |
| 747 | 748 |
| 748 void ContentDecryptorDelegate::OnPromiseRejected( | 749 void ContentDecryptorDelegate::OnPromiseRejected( |
| 749 uint32_t promise_id, | 750 uint32_t promise_id, |
| 750 PP_CdmExceptionCode exception_code, | 751 PP_CdmExceptionCode exception_code, |
| 751 uint32_t system_code, | 752 uint32_t system_code, |
| 752 PP_Var error_description) { | 753 PP_Var error_description) { |
| 753 ReportSystemCodeUMA(key_system_, system_code); | 754 ReportSystemCodeUMA(key_system_, system_code); |
| 754 | 755 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 814 return; | 815 return; |
| 815 | 816 |
| 816 StringVar* session_id_string = StringVar::FromPPVar(session_id); | 817 StringVar* session_id_string = StringVar::FromPPVar(session_id); |
| 817 DCHECK(session_id_string); | 818 DCHECK(session_id_string); |
| 818 | 819 |
| 819 session_expiration_update_cb_.Run(session_id_string->value(), | 820 session_expiration_update_cb_.Run(session_id_string->value(), |
| 820 ppapi::PPTimeToTime(new_expiry_time)); | 821 ppapi::PPTimeToTime(new_expiry_time)); |
| 821 } | 822 } |
| 822 | 823 |
| 823 void ContentDecryptorDelegate::OnSessionClosed(PP_Var session_id) { | 824 void ContentDecryptorDelegate::OnSessionClosed(PP_Var session_id) { |
| 824 if (session_closed_cb_.is_null()) | |
| 825 return; | |
| 826 | |
| 827 StringVar* session_id_string = StringVar::FromPPVar(session_id); | 825 StringVar* session_id_string = StringVar::FromPPVar(session_id); |
| 828 DCHECK(session_id_string); | 826 DCHECK(session_id_string); |
| 829 | 827 |
| 830 session_closed_cb_.Run(session_id_string->value()); | 828 cdm_session_tracker_.RemoveSession(session_id_string->value()); |
| 829 if (!session_closed_cb_.is_null()) |
| 830 session_closed_cb_.Run(session_id_string->value()); |
| 831 } | 831 } |
| 832 | 832 |
| 833 void ContentDecryptorDelegate::DecoderInitializeDone( | 833 void ContentDecryptorDelegate::DecoderInitializeDone( |
| 834 PP_DecryptorStreamType decoder_type, | 834 PP_DecryptorStreamType decoder_type, |
| 835 uint32_t request_id, | 835 uint32_t request_id, |
| 836 PP_Bool success) { | 836 PP_Bool success) { |
| 837 if (decoder_type == PP_DECRYPTORSTREAMTYPE_AUDIO) { | 837 if (decoder_type == PP_DECRYPTORSTREAMTYPE_AUDIO) { |
| 838 // If the request ID is not valid or does not match what's saved, do | 838 // If the request ID is not valid or does not match what's saved, do |
| 839 // nothing. | 839 // nothing. |
| 840 if (request_id == 0 || !audio_decoder_init_cb_.Matches(request_id)) | 840 if (request_id == 0 || !audio_decoder_init_cb_.Matches(request_id)) |
| (...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1250 if (!audio_decode_cb_.is_null()) { | 1250 if (!audio_decode_cb_.is_null()) { |
| 1251 const media::Decryptor::AudioFrames empty_frames; | 1251 const media::Decryptor::AudioFrames empty_frames; |
| 1252 audio_decode_cb_.ResetAndReturn().Run(media::Decryptor::kError, | 1252 audio_decode_cb_.ResetAndReturn().Run(media::Decryptor::kError, |
| 1253 empty_frames); | 1253 empty_frames); |
| 1254 } | 1254 } |
| 1255 | 1255 |
| 1256 if (!video_decode_cb_.is_null()) | 1256 if (!video_decode_cb_.is_null()) |
| 1257 video_decode_cb_.ResetAndReturn().Run(media::Decryptor::kError, NULL); | 1257 video_decode_cb_.ResetAndReturn().Run(media::Decryptor::kError, NULL); |
| 1258 | 1258 |
| 1259 cdm_promise_adapter_.Clear(); | 1259 cdm_promise_adapter_.Clear(); |
| 1260 |
| 1261 cdm_session_tracker_.CloseRemainingSessions(session_closed_cb_); |
| 1260 } | 1262 } |
| 1261 | 1263 |
| 1262 } // namespace content | 1264 } // namespace content |
| OLD | NEW |