Chromium Code Reviews| 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/cdm_adapter.h" | 5 #include "media/cdm/ppapi/cdm_adapter.h" |
| 6 | 6 |
| 7 #include "media/cdm/ppapi/cdm_file_io_impl.h" | 7 #include "media/cdm/ppapi/cdm_file_io_impl.h" |
| 8 #include "media/cdm/ppapi/cdm_helpers.h" | 8 #include "media/cdm/ppapi/cdm_helpers.h" |
| 9 #include "media/cdm/ppapi/cdm_logging.h" | 9 #include "media/cdm/ppapi/cdm_logging.h" |
| 10 #include "media/cdm/ppapi/supported_cdm_versions.h" | 10 #include "media/cdm/ppapi/supported_cdm_versions.h" |
| 11 #include "ppapi/c/ppb_console.h" | 11 #include "ppapi/c/ppb_console.h" |
| 12 #include "ppapi/cpp/private/uma_private.h" | |
| 12 | 13 |
| 13 #if defined(CHECK_DOCUMENT_URL) | 14 #if defined(CHECK_DOCUMENT_URL) |
| 14 #include "ppapi/cpp/dev/url_util_dev.h" | 15 #include "ppapi/cpp/dev/url_util_dev.h" |
| 15 #include "ppapi/cpp/instance_handle.h" | 16 #include "ppapi/cpp/instance_handle.h" |
| 16 #endif // defined(CHECK_DOCUMENT_URL) | 17 #endif // defined(CHECK_DOCUMENT_URL) |
| 17 | 18 |
| 18 namespace { | 19 namespace { |
| 19 | 20 |
| 20 #if !defined(NDEBUG) | 21 #if !defined(NDEBUG) |
| 21 #define DLOG_TO_CONSOLE(message) LogToConsole(message); | 22 #define DLOG_TO_CONSOLE(message) LogToConsole(message); |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 217 CdmAdapter::CdmAdapter(PP_Instance instance, pp::Module* module) | 218 CdmAdapter::CdmAdapter(PP_Instance instance, pp::Module* module) |
| 218 : pp::Instance(instance), | 219 : pp::Instance(instance), |
| 219 pp::ContentDecryptor_Private(this), | 220 pp::ContentDecryptor_Private(this), |
| 220 #if defined(OS_CHROMEOS) | 221 #if defined(OS_CHROMEOS) |
| 221 output_protection_(this), | 222 output_protection_(this), |
| 222 platform_verification_(this), | 223 platform_verification_(this), |
| 223 challenge_in_progress_(false), | 224 challenge_in_progress_(false), |
| 224 output_link_mask_(0), | 225 output_link_mask_(0), |
| 225 output_protection_mask_(0), | 226 output_protection_mask_(0), |
| 226 query_output_protection_in_progress_(false), | 227 query_output_protection_in_progress_(false), |
| 228 uma_for_output_protection_query_reported_(false), | |
| 229 uma_for_output_protection_positive_result_reported_(false), | |
| 227 #endif | 230 #endif |
| 228 allocator_(this), | 231 allocator_(this), |
| 229 cdm_(NULL), | 232 cdm_(NULL), |
| 230 deferred_initialize_audio_decoder_(false), | 233 deferred_initialize_audio_decoder_(false), |
| 231 deferred_audio_decoder_config_id_(0), | 234 deferred_audio_decoder_config_id_(0), |
| 232 deferred_initialize_video_decoder_(false), | 235 deferred_initialize_video_decoder_(false), |
| 233 deferred_video_decoder_config_id_(0) { | 236 deferred_video_decoder_config_id_(0) { |
| 234 callback_factory_.Initialize(this); | 237 callback_factory_.Initialize(this); |
| 235 } | 238 } |
| 236 | 239 |
| (...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 834 PP_DCHECK(!query_output_protection_in_progress_); | 837 PP_DCHECK(!query_output_protection_in_progress_); |
| 835 | 838 |
| 836 output_link_mask_ = output_protection_mask_ = 0; | 839 output_link_mask_ = output_protection_mask_ = 0; |
| 837 const int32_t result = output_protection_.QueryStatus( | 840 const int32_t result = output_protection_.QueryStatus( |
| 838 &output_link_mask_, | 841 &output_link_mask_, |
| 839 &output_protection_mask_, | 842 &output_protection_mask_, |
| 840 callback_factory_.NewCallback( | 843 callback_factory_.NewCallback( |
| 841 &CdmAdapter::QueryOutputProtectionStatusDone)); | 844 &CdmAdapter::QueryOutputProtectionStatusDone)); |
| 842 if (result == PP_OK_COMPLETIONPENDING) { | 845 if (result == PP_OK_COMPLETIONPENDING) { |
| 843 query_output_protection_in_progress_ = true; | 846 query_output_protection_in_progress_ = true; |
| 847 ReportOutputProtectionQuery(); | |
| 844 return; | 848 return; |
| 845 } | 849 } |
| 846 | 850 |
| 847 // Fall through on error and issue an empty OnQueryOutputProtectionStatus(). | 851 // Fall through on error and issue an empty OnQueryOutputProtectionStatus(). |
| 848 PP_DCHECK(result != PP_OK); | 852 PP_DCHECK(result != PP_OK); |
| 849 #endif | 853 #endif |
| 850 | 854 |
| 851 cdm_->OnQueryOutputProtectionStatus(0, 0); | 855 cdm_->OnQueryOutputProtectionStatus(0, 0); |
| 852 } | 856 } |
| 853 | 857 |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 876 break; | 880 break; |
| 877 } | 881 } |
| 878 } | 882 } |
| 879 | 883 |
| 880 // The CDM owns the returned object and must call FileIO::Close() to release it. | 884 // The CDM owns the returned object and must call FileIO::Close() to release it. |
| 881 cdm::FileIO* CdmAdapter::CreateFileIO(cdm::FileIOClient* client) { | 885 cdm::FileIO* CdmAdapter::CreateFileIO(cdm::FileIOClient* client) { |
| 882 return new CdmFileIOImpl(client, pp_instance()); | 886 return new CdmFileIOImpl(client, pp_instance()); |
| 883 } | 887 } |
| 884 | 888 |
| 885 #if defined(OS_CHROMEOS) | 889 #if defined(OS_CHROMEOS) |
| 890 void CdmAdapter::ReportOutputProtectionUMA(OutputProtectionStatus status) { | |
| 891 pp::UMAPrivate uma_interface_(this); | |
| 892 uma_interface_.HistogramEnumeration( | |
| 893 "Media.EME.OutputProtection", status, OUTPUT_PROTECTION_MAX); | |
| 894 } | |
| 895 | |
| 896 void CdmAdapter::ReportOutputProtectionQuery() { | |
| 897 if (uma_for_output_protection_query_reported_) | |
| 898 return; | |
| 899 | |
| 900 ReportOutputProtectionUMA(OUTPUT_PROTECTION_QUERIED); | |
| 901 uma_for_output_protection_query_reported_ = true; | |
| 902 } | |
| 903 | |
| 904 void CdmAdapter::ReportOutputProtectionQueryResult() { | |
| 905 if (uma_for_output_protection_positive_result_reported_) | |
| 906 return; | |
| 907 | |
| 908 // Report UMAs for output protection query result. | |
| 909 uint32_t external_links = (output_link_mask_ & ~cdm::kLinkTypeInternal); | |
| 910 | |
| 911 if (!external_links) { | |
| 912 ReportOutputProtectionUMA(OUTPUT_PROTECTION_NO_EXTERNAL_LINK); | |
| 913 uma_for_output_protection_positive_result_reported_ = true; | |
| 914 return; | |
| 915 } | |
| 916 | |
| 917 if ((output_protection_mask_ & external_links) == external_links) { | |
| 918 ReportOutputProtectionUMA( | |
| 919 OUTPUT_PROTECTION_ALL_EXTERNAL_LINKS_PROTECTED); | |
| 920 uma_for_output_protection_positive_result_reported_ = true; | |
| 921 return; | |
| 922 } | |
| 923 | |
| 924 // Do not report a negative result because it could be a false negative. | |
| 925 // Instead, we will calculate number of negatives using the totally number of | |
|
ddorwin
2014/05/01 04:41:20
nit: total
xhwang
2014/05/01 16:16:45
Done.
| |
| 926 // queries and success results. | |
| 927 } | |
| 928 | |
| 886 void CdmAdapter::SendPlatformChallengeDone(int32_t result) { | 929 void CdmAdapter::SendPlatformChallengeDone(int32_t result) { |
| 887 challenge_in_progress_ = false; | 930 challenge_in_progress_ = false; |
| 888 | 931 |
| 889 if (result != PP_OK) { | 932 if (result != PP_OK) { |
| 890 CDM_DLOG() << __FUNCTION__ << ": Platform challenge failed!"; | 933 CDM_DLOG() << __FUNCTION__ << ": Platform challenge failed!"; |
| 891 cdm::PlatformChallengeResponse response = {}; | 934 cdm::PlatformChallengeResponse response = {}; |
| 892 cdm_->OnPlatformChallengeResponse(response); | 935 cdm_->OnPlatformChallengeResponse(response); |
| 893 return; | 936 return; |
| 894 } | 937 } |
| 895 | 938 |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 920 CDM_DLOG() << __FUNCTION__ << " : " << result; | 963 CDM_DLOG() << __FUNCTION__ << " : " << result; |
| 921 } | 964 } |
| 922 | 965 |
| 923 void CdmAdapter::QueryOutputProtectionStatusDone(int32_t result) { | 966 void CdmAdapter::QueryOutputProtectionStatusDone(int32_t result) { |
| 924 PP_DCHECK(query_output_protection_in_progress_); | 967 PP_DCHECK(query_output_protection_in_progress_); |
| 925 query_output_protection_in_progress_ = false; | 968 query_output_protection_in_progress_ = false; |
| 926 | 969 |
| 927 // Return a protection status of none on error. | 970 // Return a protection status of none on error. |
| 928 if (result != PP_OK) | 971 if (result != PP_OK) |
| 929 output_link_mask_ = output_protection_mask_ = 0; | 972 output_link_mask_ = output_protection_mask_ = 0; |
| 973 else | |
| 974 ReportOutputProtectionQueryResult(); | |
| 930 | 975 |
| 931 cdm_->OnQueryOutputProtectionStatus(output_link_mask_, | 976 cdm_->OnQueryOutputProtectionStatus(output_link_mask_, |
| 932 output_protection_mask_); | 977 output_protection_mask_); |
| 933 } | 978 } |
| 934 #endif | 979 #endif |
| 935 | 980 |
| 936 void* GetCdmHost(int host_interface_version, void* user_data) { | 981 void* GetCdmHost(int host_interface_version, void* user_data) { |
| 937 if (!host_interface_version || !user_data) | 982 if (!host_interface_version || !user_data) |
| 938 return NULL; | 983 return NULL; |
| 939 | 984 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 992 } // namespace media | 1037 } // namespace media |
| 993 | 1038 |
| 994 namespace pp { | 1039 namespace pp { |
| 995 | 1040 |
| 996 // Factory function for your specialization of the Module object. | 1041 // Factory function for your specialization of the Module object. |
| 997 Module* CreateModule() { | 1042 Module* CreateModule() { |
| 998 return new media::CdmAdapterModule(); | 1043 return new media::CdmAdapterModule(); |
| 999 } | 1044 } |
| 1000 | 1045 |
| 1001 } // namespace pp | 1046 } // namespace pp |
| OLD | NEW |