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 if (!uma_for_output_protection_query_reported_) { | |
ddorwin
2014/04/30 23:13:35
Why not handle this logic inside the Report functi
xhwang
2014/04/30 23:48:16
Added a helper function to do this.
| |
848 ReportOutputProtectionStatus(OUTPUT_PROTECTION_QUERIED); | |
849 uma_for_output_protection_query_reported_ = true; | |
850 } | |
851 | |
844 return; | 852 return; |
845 } | 853 } |
846 | 854 |
847 // Fall through on error and issue an empty OnQueryOutputProtectionStatus(). | 855 // Fall through on error and issue an empty OnQueryOutputProtectionStatus(). |
848 PP_DCHECK(result != PP_OK); | 856 PP_DCHECK(result != PP_OK); |
849 #endif | 857 #endif |
850 | 858 |
851 cdm_->OnQueryOutputProtectionStatus(0, 0); | 859 cdm_->OnQueryOutputProtectionStatus(0, 0); |
852 } | 860 } |
853 | 861 |
(...skipping 22 matching lines...) Expand all Loading... | |
876 break; | 884 break; |
877 } | 885 } |
878 } | 886 } |
879 | 887 |
880 // The CDM owns the returned object and must call FileIO::Close() to release it. | 888 // The CDM owns the returned object and must call FileIO::Close() to release it. |
881 cdm::FileIO* CdmAdapter::CreateFileIO(cdm::FileIOClient* client) { | 889 cdm::FileIO* CdmAdapter::CreateFileIO(cdm::FileIOClient* client) { |
882 return new CdmFileIOImpl(client, pp_instance()); | 890 return new CdmFileIOImpl(client, pp_instance()); |
883 } | 891 } |
884 | 892 |
885 #if defined(OS_CHROMEOS) | 893 #if defined(OS_CHROMEOS) |
894 void CdmAdapter::ReportOutputProtectionStatus(OutputProtectionStatus status) { | |
895 pp::UMAPrivate uma_interface_(this); | |
896 std::string uma_name = "Media.EME.OutputProtection"; | |
897 uma_interface_.HistogramEnumeration(uma_name, status, OUTPUT_PROTECTION_MAX); | |
898 } | |
899 | |
900 void CdmAdapter::ReportOutputProtectionQueryResult(int32_t result) { | |
901 if (uma_for_output_protection_positive_result_reported_) | |
902 return; | |
903 | |
904 uma_for_output_protection_positive_result_reported_ = true; | |
ddorwin
2014/04/30 23:13:35
A bit weird, but okay. Hmm, maybe we can handle th
xhwang
2014/04/30 23:48:16
Done.
| |
905 | |
906 if (result != PP_OK) { | |
907 ReportOutputProtectionStatus(OUTPUT_PROTECTION_QUERY_ERROR); | |
908 return; | |
909 } | |
910 | |
911 // Report UMAs for output protection query result. | |
912 uint32_t external_links = (output_link_mask_ & ~cdm::kLinkTypeInternal); | |
913 | |
914 if (!external_links) { | |
915 ReportOutputProtectionStatus(OUTPUT_PROTECTION_NO_EXTERNAL_LINK); | |
916 return; | |
917 } | |
918 | |
919 if ((output_protection_mask_ & external_links) == external_links) { | |
920 ReportOutputProtectionStatus( | |
921 OUTPUT_PROTECTION_ALL_EXTERNAL_LINKS_PROTECTED); | |
922 return; | |
923 } | |
924 | |
925 // Do not report a negative result because it could be a false negative. | |
926 // Instead, we will calculate number of negatives using the totally number of | |
927 // queries and success results. | |
928 uma_for_output_protection_positive_result_reported_ = false; | |
929 } | |
930 | |
886 void CdmAdapter::SendPlatformChallengeDone(int32_t result) { | 931 void CdmAdapter::SendPlatformChallengeDone(int32_t result) { |
887 challenge_in_progress_ = false; | 932 challenge_in_progress_ = false; |
888 | 933 |
889 if (result != PP_OK) { | 934 if (result != PP_OK) { |
890 CDM_DLOG() << __FUNCTION__ << ": Platform challenge failed!"; | 935 CDM_DLOG() << __FUNCTION__ << ": Platform challenge failed!"; |
891 cdm::PlatformChallengeResponse response = {}; | 936 cdm::PlatformChallengeResponse response = {}; |
892 cdm_->OnPlatformChallengeResponse(response); | 937 cdm_->OnPlatformChallengeResponse(response); |
893 return; | 938 return; |
894 } | 939 } |
895 | 940 |
(...skipping 25 matching lines...) Expand all Loading... | |
921 } | 966 } |
922 | 967 |
923 void CdmAdapter::QueryOutputProtectionStatusDone(int32_t result) { | 968 void CdmAdapter::QueryOutputProtectionStatusDone(int32_t result) { |
924 PP_DCHECK(query_output_protection_in_progress_); | 969 PP_DCHECK(query_output_protection_in_progress_); |
925 query_output_protection_in_progress_ = false; | 970 query_output_protection_in_progress_ = false; |
926 | 971 |
927 // Return a protection status of none on error. | 972 // Return a protection status of none on error. |
928 if (result != PP_OK) | 973 if (result != PP_OK) |
929 output_link_mask_ = output_protection_mask_ = 0; | 974 output_link_mask_ = output_protection_mask_ = 0; |
930 | 975 |
976 ReportOutputProtectionQueryResult(result); | |
977 | |
931 cdm_->OnQueryOutputProtectionStatus(output_link_mask_, | 978 cdm_->OnQueryOutputProtectionStatus(output_link_mask_, |
932 output_protection_mask_); | 979 output_protection_mask_); |
933 } | 980 } |
934 #endif | 981 #endif |
935 | 982 |
936 void* GetCdmHost(int host_interface_version, void* user_data) { | 983 void* GetCdmHost(int host_interface_version, void* user_data) { |
937 if (!host_interface_version || !user_data) | 984 if (!host_interface_version || !user_data) |
938 return NULL; | 985 return NULL; |
939 | 986 |
940 COMPILE_ASSERT( | 987 COMPILE_ASSERT( |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
992 } // namespace media | 1039 } // namespace media |
993 | 1040 |
994 namespace pp { | 1041 namespace pp { |
995 | 1042 |
996 // Factory function for your specialization of the Module object. | 1043 // Factory function for your specialization of the Module object. |
997 Module* CreateModule() { | 1044 Module* CreateModule() { |
998 return new media::CdmAdapterModule(); | 1045 return new media::CdmAdapterModule(); |
999 } | 1046 } |
1000 | 1047 |
1001 } // namespace pp | 1048 } // namespace pp |
OLD | NEW |