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 "base/callback_helpers.h" | 7 #include "base/callback_helpers.h" |
8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
9 #include "base/message_loop/message_loop_proxy.h" | 9 #include "base/message_loop/message_loop_proxy.h" |
10 #include "base/metrics/sparse_histogram.h" | 10 #include "base/metrics/sparse_histogram.h" |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 case PP_CDMEXCEPTIONCODE_CLIENTERROR: | 285 case PP_CDMEXCEPTIONCODE_CLIENTERROR: |
286 return MediaKeys::CLIENT_ERROR; | 286 return MediaKeys::CLIENT_ERROR; |
287 case PP_CDMEXCEPTIONCODE_OUTPUTERROR: | 287 case PP_CDMEXCEPTIONCODE_OUTPUTERROR: |
288 return MediaKeys::OUTPUT_ERROR; | 288 return MediaKeys::OUTPUT_ERROR; |
289 default: | 289 default: |
290 NOTREACHED(); | 290 NOTREACHED(); |
291 return MediaKeys::UNKNOWN_ERROR; | 291 return MediaKeys::UNKNOWN_ERROR; |
292 } | 292 } |
293 } | 293 } |
294 | 294 |
| 295 media::CdmKeyInformation::KeyStatus PpCdmKeyStatusToCdmKeyInformationKeyStatus( |
| 296 PP_CdmKeyStatus status) { |
| 297 switch (status) { |
| 298 case PP_CDMKEYSTATUS_USABLE: |
| 299 return media::CdmKeyInformation::USABLE; |
| 300 case PP_CDMKEYSTATUS_INVALID: |
| 301 return media::CdmKeyInformation::INTERNAL_ERROR; |
| 302 case PP_CDMKEYSTATUS_EXPIRED: |
| 303 return media::CdmKeyInformation::EXPIRED; |
| 304 case PP_CDMKEYSTATUS_OUTPUTNOTALLOWED: |
| 305 return media::CdmKeyInformation::OUTPUT_NOT_ALLOWED; |
| 306 default: |
| 307 NOTREACHED(); |
| 308 return media::CdmKeyInformation::INTERNAL_ERROR; |
| 309 } |
| 310 } |
| 311 |
295 // TODO(xhwang): Unify EME UMA reporting code when prefixed EME is deprecated. | 312 // TODO(xhwang): Unify EME UMA reporting code when prefixed EME is deprecated. |
296 // See http://crbug.com/412987 for details. | 313 // See http://crbug.com/412987 for details. |
297 void ReportSystemCodeUMA(const std::string& key_system, uint32 system_code) { | 314 void ReportSystemCodeUMA(const std::string& key_system, uint32 system_code) { |
298 // Sparse histogram macro does not cache the histogram, so it's safe to use | 315 // Sparse histogram macro does not cache the histogram, so it's safe to use |
299 // macro with non-static histogram name here. | 316 // macro with non-static histogram name here. |
300 UMA_HISTOGRAM_SPARSE_SLOWLY( | 317 UMA_HISTOGRAM_SPARSE_SLOWLY( |
301 "Media.EME." + media::GetKeySystemNameForUMA(key_system) + ".SystemCode", | 318 "Media.EME." + media::GetKeySystemNameForUMA(key_system) + ".SystemCode", |
302 system_code); | 319 system_code); |
303 } | 320 } |
304 | 321 |
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
747 std::vector<uint8> message_vector; | 764 std::vector<uint8> message_vector; |
748 if (message_array_buffer) { | 765 if (message_array_buffer) { |
749 const uint8* data = static_cast<const uint8*>(message_array_buffer->Map()); | 766 const uint8* data = static_cast<const uint8*>(message_array_buffer->Map()); |
750 message_vector.assign(data, data + message_array_buffer->ByteLength()); | 767 message_vector.assign(data, data + message_array_buffer->ByteLength()); |
751 } | 768 } |
752 | 769 |
753 session_message_cb_.Run(web_session_id_string->value(), message_vector, | 770 session_message_cb_.Run(web_session_id_string->value(), message_vector, |
754 GURL::EmptyGURL()); | 771 GURL::EmptyGURL()); |
755 } | 772 } |
756 | 773 |
757 // TODO(jrummell): Decode |key_information| and pass it to the callback. | |
758 void ContentDecryptorDelegate::OnSessionKeysChange( | 774 void ContentDecryptorDelegate::OnSessionKeysChange( |
759 PP_Var web_session_id, | 775 PP_Var web_session_id, |
760 PP_Bool has_additional_usable_key, | 776 PP_Bool has_additional_usable_key, |
761 uint32_t key_count, | 777 uint32_t key_count, |
762 const struct PP_KeyInformation key_information[]) { | 778 const struct PP_KeyInformation key_information[]) { |
763 if (session_keys_change_cb_.is_null()) | 779 if (session_keys_change_cb_.is_null()) |
764 return; | 780 return; |
765 | 781 |
766 StringVar* web_session_id_string = StringVar::FromPPVar(web_session_id); | 782 StringVar* web_session_id_string = StringVar::FromPPVar(web_session_id); |
767 DCHECK(web_session_id_string); | 783 DCHECK(web_session_id_string); |
768 | 784 |
769 // TODO(jrummell): Pass key information through Pepper. | 785 media::CdmKeysInfo keys_info; |
| 786 keys_info.reserve(key_count); |
| 787 for (uint32_t i = 0; i < key_count; ++i) { |
| 788 scoped_ptr<media::CdmKeyInformation> key_info(new media::CdmKeyInformation); |
| 789 const auto& info = key_information[i]; |
| 790 key_info->key_id.assign(info.key_id, info.key_id + info.key_id_size); |
| 791 key_info->status = |
| 792 PpCdmKeyStatusToCdmKeyInformationKeyStatus(info.key_status); |
| 793 key_info->system_code = info.system_code; |
| 794 keys_info.push_back(key_info.release()); |
| 795 } |
| 796 |
770 session_keys_change_cb_.Run(web_session_id_string->value(), | 797 session_keys_change_cb_.Run(web_session_id_string->value(), |
771 PP_ToBool(has_additional_usable_key), | 798 PP_ToBool(has_additional_usable_key), |
772 media::CdmKeysInfo()); | 799 keys_info.Pass()); |
773 } | 800 } |
774 | 801 |
775 void ContentDecryptorDelegate::OnSessionExpirationChange( | 802 void ContentDecryptorDelegate::OnSessionExpirationChange( |
776 PP_Var web_session_id, | 803 PP_Var web_session_id, |
777 PP_Time new_expiry_time) { | 804 PP_Time new_expiry_time) { |
778 if (session_expiration_update_cb_.is_null()) | 805 if (session_expiration_update_cb_.is_null()) |
779 return; | 806 return; |
780 | 807 |
781 StringVar* web_session_id_string = StringVar::FromPPVar(web_session_id); | 808 StringVar* web_session_id_string = StringVar::FromPPVar(web_session_id); |
782 DCHECK(web_session_id_string); | 809 DCHECK(web_session_id_string); |
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1258 | 1285 |
1259 scoped_ptr<CdmPromise> ContentDecryptorDelegate::TakePromise( | 1286 scoped_ptr<CdmPromise> ContentDecryptorDelegate::TakePromise( |
1260 uint32_t promise_id) { | 1287 uint32_t promise_id) { |
1261 PromiseMap::iterator it = promises_.find(promise_id); | 1288 PromiseMap::iterator it = promises_.find(promise_id); |
1262 if (it == promises_.end()) | 1289 if (it == promises_.end()) |
1263 return scoped_ptr<CdmPromise>(); | 1290 return scoped_ptr<CdmPromise>(); |
1264 return promises_.take_and_erase(it); | 1291 return promises_.take_and_erase(it); |
1265 } | 1292 } |
1266 | 1293 |
1267 } // namespace content | 1294 } // namespace content |
OLD | NEW |