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

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: 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 729 matching lines...) Expand 10 before | Expand all | Expand 10 after
998 const PPB_Console* console = reinterpret_cast<const PPB_Console*>( 997 const PPB_Console* console = reinterpret_cast<const PPB_Console*>(
999 pp::Module::Get()->GetBrowserInterface(PPB_CONSOLE_INTERFACE)); 998 pp::Module::Get()->GetBrowserInterface(PPB_CONSOLE_INTERFACE));
1000 console->Log(pp_instance(), PP_LOGLEVEL_LOG, value.pp_var()); 999 console->Log(pp_instance(), PP_LOGLEVEL_LOG, value.pp_var());
1001 } 1000 }
1002 #endif // !defined(NDEBUG) 1001 #endif // !defined(NDEBUG)
1003 1002
1004 void CdmAdapter::SendPlatformChallenge( 1003 void CdmAdapter::SendPlatformChallenge(
1005 const char* service_id, uint32_t service_id_length, 1004 const char* service_id, uint32_t service_id_length,
1006 const char* challenge, uint32_t challenge_length) { 1005 const char* challenge, uint32_t challenge_length) {
1007 #if defined(OS_CHROMEOS) 1006 #if defined(OS_CHROMEOS)
1008 PP_DCHECK(!challenge_in_progress_);
1009
1010 // Ensure member variables set by the callback are in a clean state.
1011 signed_data_output_ = pp::Var();
1012 signed_data_signature_output_ = pp::Var();
1013 platform_key_certificate_output_ = pp::Var();
1014
1015 pp::VarArrayBuffer challenge_var(challenge_length); 1007 pp::VarArrayBuffer challenge_var(challenge_length);
1016 uint8_t* var_data = static_cast<uint8_t*>(challenge_var.Map()); 1008 uint8_t* var_data = static_cast<uint8_t*>(challenge_var.Map());
1017 memcpy(var_data, challenge, challenge_length); 1009 memcpy(var_data, challenge, challenge_length);
1018 1010
1019 std::string service_id_str(service_id, service_id_length); 1011 std::string service_id_str(service_id, service_id_length);
1020 int32_t result = platform_verification_.ChallengePlatform( 1012 int32_t result = platform_verification_.ChallengePlatform(
1021 pp::Var(service_id_str), challenge_var, &signed_data_output_, 1013 pp::Var(service_id_str), challenge_var, &signed_data_output_,
1022 &signed_data_signature_output_, &platform_key_certificate_output_, 1014 &signed_data_signature_output_, &platform_key_certificate_output_,
1023 callback_factory_.NewCallback(&CdmAdapter::SendPlatformChallengeDone)); 1015 callback_factory_.NewCallback(&CdmAdapter::SendPlatformChallengeDone));
dmichael (off chromium) 2014/07/15 21:59:52 Do you know you can bind parameters with the callb
DaleCurtis 2014/07/15 22:04:31 That would be awesome if it works now. IIRC, at t
1024 challenge_var.Unmap(); 1016 challenge_var.Unmap();
1025 if (result == PP_OK_COMPLETIONPENDING) { 1017 if (result == PP_OK_COMPLETIONPENDING)
1026 challenge_in_progress_ = true;
1027 return; 1018 return;
1028 }
1029 1019
1030 // Fall through on error and issue an empty OnPlatformChallengeResponse(). 1020 // Fall through on error and issue an empty OnPlatformChallengeResponse().
1031 PP_DCHECK(result != PP_OK); 1021 PP_DCHECK(result != PP_OK);
1032 #endif 1022 #endif
1033 1023
1034 cdm::PlatformChallengeResponse response = {}; 1024 cdm::PlatformChallengeResponse response = {};
1035 cdm_->OnPlatformChallengeResponse(response); 1025 cdm_->OnPlatformChallengeResponse(response);
1036 } 1026 }
1037 1027
1038 void CdmAdapter::EnableOutputProtection(uint32_t desired_protection_mask) { 1028 void CdmAdapter::EnableOutputProtection(uint32_t desired_protection_mask) {
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
1144 uma_for_output_protection_positive_result_reported_ = true; 1134 uma_for_output_protection_positive_result_reported_ = true;
1145 return; 1135 return;
1146 } 1136 }
1147 1137
1148 // Do not report a negative result because it could be a false negative. 1138 // Do not report a negative result because it could be a false negative.
1149 // Instead, we will calculate number of negatives using the total number of 1139 // Instead, we will calculate number of negatives using the total number of
1150 // queries and success results. 1140 // queries and success results.
1151 } 1141 }
1152 1142
1153 void CdmAdapter::SendPlatformChallengeDone(int32_t result) { 1143 void CdmAdapter::SendPlatformChallengeDone(int32_t result) {
1154 challenge_in_progress_ = false;
1155
1156 if (result != PP_OK) { 1144 if (result != PP_OK) {
1157 CDM_DLOG() << __FUNCTION__ << ": Platform challenge failed!"; 1145 CDM_DLOG() << __FUNCTION__ << ": Platform challenge failed!";
1158 cdm::PlatformChallengeResponse response = {}; 1146 cdm::PlatformChallengeResponse response = {};
1159 cdm_->OnPlatformChallengeResponse(response); 1147 cdm_->OnPlatformChallengeResponse(response);
1160 return; 1148 return;
1161 } 1149 }
1162 1150
1163 pp::VarArrayBuffer signed_data_var(signed_data_output_); 1151 pp::VarArrayBuffer signed_data_var(signed_data_output_);
1164 pp::VarArrayBuffer signed_data_signature_var(signed_data_signature_output_); 1152 pp::VarArrayBuffer signed_data_signature_var(signed_data_signature_output_);
1165 std::string platform_key_certificate_string = 1153 std::string platform_key_certificate_string =
1166 platform_key_certificate_output_.AsString(); 1154 platform_key_certificate_output_.AsString();
1167 1155
1168 cdm::PlatformChallengeResponse response = { 1156 cdm::PlatformChallengeResponse response = {
1169 static_cast<uint8_t*>(signed_data_var.Map()), 1157 static_cast<uint8_t*>(signed_data_var.Map()),
1170 signed_data_var.ByteLength(), 1158 signed_data_var.ByteLength(),
1171 static_cast<uint8_t*>(signed_data_signature_var.Map()), 1159 static_cast<uint8_t*>(signed_data_signature_var.Map()),
1172 signed_data_signature_var.ByteLength(), 1160 signed_data_signature_var.ByteLength(),
1173 reinterpret_cast<const uint8_t*>(platform_key_certificate_string.data()), 1161 reinterpret_cast<const uint8_t*>(platform_key_certificate_string.data()),
1174 static_cast<uint32_t>(platform_key_certificate_string.length())}; 1162 static_cast<uint32_t>(platform_key_certificate_string.length())};
1175 cdm_->OnPlatformChallengeResponse(response); 1163 cdm_->OnPlatformChallengeResponse(response);
1176 1164
1177 signed_data_var.Unmap(); 1165 signed_data_var.Unmap();
1178 signed_data_signature_var.Unmap(); 1166 signed_data_signature_var.Unmap();
1167
1168 // Ensure member variables are in a clean state.
1169 signed_data_output_ = pp::Var();
1170 signed_data_signature_output_ = pp::Var();
1171 platform_key_certificate_output_ = pp::Var();
xhwang 2014/07/15 01:35:50 Move this block here so that we keep these variabl
1179 } 1172 }
1180 1173
1181 void CdmAdapter::EnableProtectionDone(int32_t result) { 1174 void CdmAdapter::EnableProtectionDone(int32_t result) {
1182 // Does nothing since clients must call QueryOutputProtectionStatus() to 1175 // Does nothing since clients must call QueryOutputProtectionStatus() to
1183 // inspect the protection status on a regular basis. 1176 // inspect the protection status on a regular basis.
1184 CDM_DLOG() << __FUNCTION__ << " : " << result; 1177 CDM_DLOG() << __FUNCTION__ << " : " << result;
1185 } 1178 }
1186 1179
1187 void CdmAdapter::QueryOutputProtectionStatusDone(int32_t result) { 1180 void CdmAdapter::QueryOutputProtectionStatusDone(int32_t result) {
1188 PP_DCHECK(query_output_protection_in_progress_); 1181 PP_DCHECK(query_output_protection_in_progress_);
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
1268 } // namespace media 1261 } // namespace media
1269 1262
1270 namespace pp { 1263 namespace pp {
1271 1264
1272 // Factory function for your specialization of the Module object. 1265 // Factory function for your specialization of the Module object.
1273 Module* CreateModule() { 1266 Module* CreateModule() {
1274 return new media::CdmAdapterModule(); 1267 return new media::CdmAdapterModule();
1275 } 1268 }
1276 1269
1277 } // namespace pp 1270 } // 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