Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(115)

Side by Side Diff: media/cdm/ppapi/cdm_adapter.cc

Issue 393713003: CdmAdapter: Allow parallel SendPlatformChallenge() calls. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments addressed Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « media/cdm/ppapi/cdm_adapter.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 } // namespace 248 } // namespace
249 249
250 namespace media { 250 namespace media {
251 251
252 CdmAdapter::CdmAdapter(PP_Instance instance, pp::Module* module) 252 CdmAdapter::CdmAdapter(PP_Instance instance, pp::Module* module)
253 : pp::Instance(instance), 253 : pp::Instance(instance),
254 pp::ContentDecryptor_Private(this), 254 pp::ContentDecryptor_Private(this),
255 #if defined(OS_CHROMEOS) 255 #if defined(OS_CHROMEOS)
256 output_protection_(this), 256 output_protection_(this),
257 platform_verification_(this), 257 platform_verification_(this),
258 challenge_in_progress_(false),
259 output_link_mask_(0), 258 output_link_mask_(0),
260 output_protection_mask_(0), 259 output_protection_mask_(0),
261 query_output_protection_in_progress_(false), 260 query_output_protection_in_progress_(false),
262 uma_for_output_protection_query_reported_(false), 261 uma_for_output_protection_query_reported_(false),
263 uma_for_output_protection_positive_result_reported_(false), 262 uma_for_output_protection_positive_result_reported_(false),
264 #endif 263 #endif
265 allocator_(this), 264 allocator_(this),
266 cdm_(NULL), 265 cdm_(NULL),
267 deferred_initialize_audio_decoder_(false), 266 deferred_initialize_audio_decoder_(false),
268 deferred_audio_decoder_config_id_(0), 267 deferred_audio_decoder_config_id_(0),
(...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after
1002 const PPB_Console* console = reinterpret_cast<const PPB_Console*>( 1001 const PPB_Console* console = reinterpret_cast<const PPB_Console*>(
1003 pp::Module::Get()->GetBrowserInterface(PPB_CONSOLE_INTERFACE)); 1002 pp::Module::Get()->GetBrowserInterface(PPB_CONSOLE_INTERFACE));
1004 console->Log(pp_instance(), PP_LOGLEVEL_LOG, value.pp_var()); 1003 console->Log(pp_instance(), PP_LOGLEVEL_LOG, value.pp_var());
1005 } 1004 }
1006 #endif // !defined(NDEBUG) 1005 #endif // !defined(NDEBUG)
1007 1006
1008 void CdmAdapter::SendPlatformChallenge( 1007 void CdmAdapter::SendPlatformChallenge(
1009 const char* service_id, uint32_t service_id_length, 1008 const char* service_id, uint32_t service_id_length,
1010 const char* challenge, uint32_t challenge_length) { 1009 const char* challenge, uint32_t challenge_length) {
1011 #if defined(OS_CHROMEOS) 1010 #if defined(OS_CHROMEOS)
1012 PP_DCHECK(!challenge_in_progress_);
1013
1014 // Ensure member variables set by the callback are in a clean state.
1015 signed_data_output_ = pp::Var();
1016 signed_data_signature_output_ = pp::Var();
1017 platform_key_certificate_output_ = pp::Var();
1018
1019 pp::VarArrayBuffer challenge_var(challenge_length); 1011 pp::VarArrayBuffer challenge_var(challenge_length);
1020 uint8_t* var_data = static_cast<uint8_t*>(challenge_var.Map()); 1012 uint8_t* var_data = static_cast<uint8_t*>(challenge_var.Map());
1021 memcpy(var_data, challenge, challenge_length); 1013 memcpy(var_data, challenge, challenge_length);
1022 1014
1023 std::string service_id_str(service_id, service_id_length); 1015 std::string service_id_str(service_id, service_id_length);
1016
1017 linked_ptr<PepperPlatformChallengeResponse> response(
1018 new PepperPlatformChallengeResponse());
1019
1024 int32_t result = platform_verification_.ChallengePlatform( 1020 int32_t result = platform_verification_.ChallengePlatform(
1025 pp::Var(service_id_str), challenge_var, &signed_data_output_, 1021 pp::Var(service_id_str),
1026 &signed_data_signature_output_, &platform_key_certificate_output_, 1022 challenge_var,
1027 callback_factory_.NewCallback(&CdmAdapter::SendPlatformChallengeDone)); 1023 &response->signed_data,
1024 &response->signed_data_signature,
1025 &response->platform_key_certificate,
1026 callback_factory_.NewCallback(&CdmAdapter::SendPlatformChallengeDone,
1027 response));
1028 challenge_var.Unmap(); 1028 challenge_var.Unmap();
1029 if (result == PP_OK_COMPLETIONPENDING) { 1029 if (result == PP_OK_COMPLETIONPENDING)
1030 challenge_in_progress_ = true;
1031 return; 1030 return;
1032 }
1033 1031
1034 // Fall through on error and issue an empty OnPlatformChallengeResponse(). 1032 // Fall through on error and issue an empty OnPlatformChallengeResponse().
1035 PP_DCHECK(result != PP_OK); 1033 PP_DCHECK(result != PP_OK);
1036 #endif 1034 #endif
1037 1035
1038 cdm::PlatformChallengeResponse response = {}; 1036 cdm::PlatformChallengeResponse platform_challenge_response = {};
1039 cdm_->OnPlatformChallengeResponse(response); 1037 cdm_->OnPlatformChallengeResponse(platform_challenge_response);
1040 } 1038 }
1041 1039
1042 void CdmAdapter::EnableOutputProtection(uint32_t desired_protection_mask) { 1040 void CdmAdapter::EnableOutputProtection(uint32_t desired_protection_mask) {
1043 #if defined(OS_CHROMEOS) 1041 #if defined(OS_CHROMEOS)
1044 int32_t result = output_protection_.EnableProtection( 1042 int32_t result = output_protection_.EnableProtection(
1045 desired_protection_mask, callback_factory_.NewCallback( 1043 desired_protection_mask, callback_factory_.NewCallback(
1046 &CdmAdapter::EnableProtectionDone)); 1044 &CdmAdapter::EnableProtectionDone));
1047 1045
1048 // Errors are ignored since clients must call QueryOutputProtectionStatus() to 1046 // Errors are ignored since clients must call QueryOutputProtectionStatus() to
1049 // inspect the protection status on a regular basis. 1047 // inspect the protection status on a regular basis.
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
1147 OUTPUT_PROTECTION_ALL_EXTERNAL_LINKS_PROTECTED); 1145 OUTPUT_PROTECTION_ALL_EXTERNAL_LINKS_PROTECTED);
1148 uma_for_output_protection_positive_result_reported_ = true; 1146 uma_for_output_protection_positive_result_reported_ = true;
1149 return; 1147 return;
1150 } 1148 }
1151 1149
1152 // Do not report a negative result because it could be a false negative. 1150 // Do not report a negative result because it could be a false negative.
1153 // Instead, we will calculate number of negatives using the total number of 1151 // Instead, we will calculate number of negatives using the total number of
1154 // queries and success results. 1152 // queries and success results.
1155 } 1153 }
1156 1154
1157 void CdmAdapter::SendPlatformChallengeDone(int32_t result) { 1155 void CdmAdapter::SendPlatformChallengeDone(
1158 challenge_in_progress_ = false; 1156 int32_t result,
1159 1157 const linked_ptr<PepperPlatformChallengeResponse>& response) {
1160 if (result != PP_OK) { 1158 if (result != PP_OK) {
1161 CDM_DLOG() << __FUNCTION__ << ": Platform challenge failed!"; 1159 CDM_DLOG() << __FUNCTION__ << ": Platform challenge failed!";
1162 cdm::PlatformChallengeResponse response = {}; 1160 cdm::PlatformChallengeResponse platform_challenge_response = {};
1163 cdm_->OnPlatformChallengeResponse(response); 1161 cdm_->OnPlatformChallengeResponse(platform_challenge_response);
1164 return; 1162 return;
1165 } 1163 }
1166 1164
1167 pp::VarArrayBuffer signed_data_var(signed_data_output_); 1165 pp::VarArrayBuffer signed_data_var(response->signed_data);
1168 pp::VarArrayBuffer signed_data_signature_var(signed_data_signature_output_); 1166 pp::VarArrayBuffer signed_data_signature_var(response->signed_data_signature);
1169 std::string platform_key_certificate_string = 1167 std::string platform_key_certificate_string =
1170 platform_key_certificate_output_.AsString(); 1168 response->platform_key_certificate.AsString();
1171 1169
1172 cdm::PlatformChallengeResponse response = { 1170 cdm::PlatformChallengeResponse platform_challenge_response = {
1173 static_cast<uint8_t*>(signed_data_var.Map()), 1171 static_cast<uint8_t*>(signed_data_var.Map()),
1174 signed_data_var.ByteLength(), 1172 signed_data_var.ByteLength(),
1175 static_cast<uint8_t*>(signed_data_signature_var.Map()), 1173 static_cast<uint8_t*>(signed_data_signature_var.Map()),
1176 signed_data_signature_var.ByteLength(), 1174 signed_data_signature_var.ByteLength(),
1177 reinterpret_cast<const uint8_t*>(platform_key_certificate_string.data()), 1175 reinterpret_cast<const uint8_t*>(platform_key_certificate_string.data()),
1178 static_cast<uint32_t>(platform_key_certificate_string.length())}; 1176 static_cast<uint32_t>(platform_key_certificate_string.length())};
1179 cdm_->OnPlatformChallengeResponse(response); 1177 cdm_->OnPlatformChallengeResponse(platform_challenge_response);
1180 1178
1181 signed_data_var.Unmap(); 1179 signed_data_var.Unmap();
1182 signed_data_signature_var.Unmap(); 1180 signed_data_signature_var.Unmap();
1183 } 1181 }
1184 1182
1185 void CdmAdapter::EnableProtectionDone(int32_t result) { 1183 void CdmAdapter::EnableProtectionDone(int32_t result) {
1186 // Does nothing since clients must call QueryOutputProtectionStatus() to 1184 // Does nothing since clients must call QueryOutputProtectionStatus() to
1187 // inspect the protection status on a regular basis. 1185 // inspect the protection status on a regular basis.
1188 CDM_DLOG() << __FUNCTION__ << " : " << result; 1186 CDM_DLOG() << __FUNCTION__ << " : " << result;
1189 } 1187 }
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
1272 } // namespace media 1270 } // namespace media
1273 1271
1274 namespace pp { 1272 namespace pp {
1275 1273
1276 // Factory function for your specialization of the Module object. 1274 // Factory function for your specialization of the Module object.
1277 Module* CreateModule() { 1275 Module* CreateModule() {
1278 return new media::CdmAdapterModule(); 1276 return new media::CdmAdapterModule();
1279 } 1277 }
1280 1278
1281 } // namespace pp 1279 } // namespace pp
OLDNEW
« no previous file with comments | « media/cdm/ppapi/cdm_adapter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698