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 "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 5 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/linked_ptr.h" | 10 #include "base/memory/linked_ptr.h" |
11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
12 #include "base/stl_util.h" | |
12 #include "base/stringprintf.h" | 13 #include "base/stringprintf.h" |
13 #include "base/time.h" | 14 #include "base/time.h" |
14 #include "base/utf_offset_string_conversions.h" | 15 #include "base/utf_offset_string_conversions.h" |
15 #include "base/utf_string_conversions.h" | 16 #include "base/utf_string_conversions.h" |
17 #include "media/base/decoder_buffer.h" | |
18 #include "media/base/decryptor_client.h" | |
16 #include "ppapi/c/dev/ppb_find_dev.h" | 19 #include "ppapi/c/dev/ppb_find_dev.h" |
17 #include "ppapi/c/dev/ppb_zoom_dev.h" | 20 #include "ppapi/c/dev/ppb_zoom_dev.h" |
18 #include "ppapi/c/dev/ppp_find_dev.h" | 21 #include "ppapi/c/dev/ppp_find_dev.h" |
19 #include "ppapi/c/dev/ppp_selection_dev.h" | 22 #include "ppapi/c/dev/ppp_selection_dev.h" |
20 #include "ppapi/c/dev/ppp_text_input_dev.h" | 23 #include "ppapi/c/dev/ppp_text_input_dev.h" |
21 #include "ppapi/c/dev/ppp_zoom_dev.h" | 24 #include "ppapi/c/dev/ppp_zoom_dev.h" |
22 #include "ppapi/c/pp_rect.h" | 25 #include "ppapi/c/pp_rect.h" |
23 #include "ppapi/c/ppb_audio_config.h" | 26 #include "ppapi/c/ppb_audio_config.h" |
24 #include "ppapi/c/ppb_core.h" | 27 #include "ppapi/c/ppb_core.h" |
25 #include "ppapi/c/ppb_gamepad.h" | 28 #include "ppapi/c/ppb_gamepad.h" |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
294 for (size_t i = 0; i < vector.size(); ++i) | 297 for (size_t i = 0; i < vector.size(); ++i) |
295 array[i] = vector[i].c_str(); | 298 array[i] = vector[i].c_str(); |
296 return array.Pass(); | 299 return array.Pass(); |
297 } | 300 } |
298 | 301 |
299 // Creates a PP_Resource containing a PPB_Buffer_Impl, copies |data| into the | 302 // Creates a PP_Resource containing a PPB_Buffer_Impl, copies |data| into the |
300 // buffer resource, and returns it. Returns a an invalid PP_Resource with an ID | 303 // buffer resource, and returns it. Returns a an invalid PP_Resource with an ID |
301 // of 0 on failure. Upon success, the returned Buffer resource has a reference | 304 // of 0 on failure. Upon success, the returned Buffer resource has a reference |
302 // count of 1. | 305 // count of 1. |
303 PP_Resource MakeBufferResource(PP_Instance instance, | 306 PP_Resource MakeBufferResource(PP_Instance instance, |
304 const base::StringPiece& data) { | 307 const uint8* data, int size) { |
Tom Finegan
2012/08/22 01:05:47
nit: seems to be consistently one arg per line in
dmichael (off chromium)
2012/08/22 20:30:15
We usually do 1-per-line, but since those two are
xhwang
2012/08/24 00:51:51
Yeah, this is actually in chromium code style guid
| |
305 if (data.empty()) | 308 if (!data || size == 0) |
306 return 0; | 309 return 0; |
307 | 310 |
308 ScopedPPResource resource(PPB_Buffer_Impl::Create(instance, data.size())); | 311 ScopedPPResource resource(PPB_Buffer_Impl::Create(instance, size)); |
309 if (!resource.get()) | 312 if (!resource.get()) |
310 return 0; | 313 return 0; |
311 | 314 |
312 EnterResourceNoLock<PPB_Buffer_API> enter(resource, true); | 315 EnterResourceNoLock<PPB_Buffer_API> enter(resource, true); |
313 if (enter.failed()) | 316 if (enter.failed()) |
314 return 0; | 317 return 0; |
315 | 318 |
316 BufferAutoMapper mapper(enter.object()); | 319 BufferAutoMapper mapper(enter.object()); |
317 memcpy(mapper.data(), data.data(), data.size()); | 320 if (!mapper.data() || mapper.size() < static_cast<size_t>(size)) |
321 return 0; | |
318 | 322 |
323 memcpy(mapper.data(), data, size); | |
319 return resource.get(); | 324 return resource.get(); |
320 } | 325 } |
321 | 326 |
322 } // namespace | 327 } // namespace |
323 | 328 |
324 // static | 329 // static |
325 PluginInstance* PluginInstance::Create(PluginDelegate* delegate, | 330 PluginInstance* PluginInstance::Create(PluginDelegate* delegate, |
326 PluginModule* module) { | 331 PluginModule* module) { |
327 base::Callback<const void*(const char*)> get_plugin_interface_func = | 332 base::Callback<const void*(const char*)> get_plugin_interface_func = |
328 base::Bind(&PluginModule::GetPluginInterface, module); | 333 base::Bind(&PluginModule::GetPluginInterface, module); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
370 sad_plugin_(NULL), | 375 sad_plugin_(NULL), |
371 input_event_mask_(0), | 376 input_event_mask_(0), |
372 filtered_input_event_mask_(0), | 377 filtered_input_event_mask_(0), |
373 text_input_type_(kPluginDefaultTextInputType), | 378 text_input_type_(kPluginDefaultTextInputType), |
374 text_input_caret_(0, 0, 0, 0), | 379 text_input_caret_(0, 0, 0, 0), |
375 text_input_caret_bounds_(0, 0, 0, 0), | 380 text_input_caret_bounds_(0, 0, 0, 0), |
376 text_input_caret_set_(false), | 381 text_input_caret_set_(false), |
377 selection_caret_(0), | 382 selection_caret_(0), |
378 selection_anchor_(0), | 383 selection_anchor_(0), |
379 pending_user_gesture_(0.0), | 384 pending_user_gesture_(0.0), |
380 flash_impl_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { | 385 flash_impl_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), |
386 decryptor_client_(NULL), | |
387 next_decryption_request_id_(0) { | |
ddorwin
2012/08/22 01:26:26
Should we avoid using 0?
xhwang
2012/08/24 00:51:51
Done.
dmichael (off chromium)
2012/08/27 20:14:48
Don't know if you care, but 0 is still possible on
xhwang
2012/08/27 22:58:14
Session ID is not likely to roll-over at all. Not
| |
381 pp_instance_ = HostGlobals::Get()->AddInstance(this); | 388 pp_instance_ = HostGlobals::Get()->AddInstance(this); |
382 | 389 |
383 memset(¤t_print_settings_, 0, sizeof(current_print_settings_)); | 390 memset(¤t_print_settings_, 0, sizeof(current_print_settings_)); |
384 DCHECK(delegate); | 391 DCHECK(delegate); |
385 module_->InstanceCreated(this); | 392 module_->InstanceCreated(this); |
386 delegate_->InstanceCreated(this); | 393 delegate_->InstanceCreated(this); |
387 message_channel_.reset(new MessageChannel(this)); | 394 message_channel_.reset(new MessageChannel(this)); |
388 | 395 |
389 view_data_.is_page_visible = delegate->IsPageVisible(); | 396 view_data_.is_page_visible = delegate->IsPageVisible(); |
390 | 397 |
(...skipping 920 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1311 if (!LoadPdfInterface()) | 1318 if (!LoadPdfInterface()) |
1312 return; | 1319 return; |
1313 PP_PrivatePageTransformType transform_type = | 1320 PP_PrivatePageTransformType transform_type = |
1314 type == WebPlugin::RotationType90Clockwise ? | 1321 type == WebPlugin::RotationType90Clockwise ? |
1315 PP_PRIVATEPAGETRANSFORMTYPE_ROTATE_90_CW : | 1322 PP_PRIVATEPAGETRANSFORMTYPE_ROTATE_90_CW : |
1316 PP_PRIVATEPAGETRANSFORMTYPE_ROTATE_90_CCW; | 1323 PP_PRIVATEPAGETRANSFORMTYPE_ROTATE_90_CCW; |
1317 plugin_pdf_interface_->Transform(pp_instance(), transform_type); | 1324 plugin_pdf_interface_->Transform(pp_instance(), transform_type); |
1318 // NOTE: plugin instance may have been deleted. | 1325 // NOTE: plugin instance may have been deleted. |
1319 } | 1326 } |
1320 | 1327 |
1328 void PluginInstance::SetDecryptClient( | |
ddorwin
2012/08/22 04:09:21
Why not set_decryptor_client()?
xhwang
2012/08/24 00:51:51
Done.
| |
1329 media::DecryptorClient* decryptor_client) { | |
1330 DCHECK(decryptor_client); | |
1331 decryptor_client_ = decryptor_client; | |
ddorwin
2012/08/22 01:26:26
Does this class assume it's only called on the mai
dmichael (off chromium)
2012/08/22 20:30:15
Yes
| |
1332 } | |
1333 | |
1321 bool PluginInstance::GenerateKeyRequest(const std::string& key_system, | 1334 bool PluginInstance::GenerateKeyRequest(const std::string& key_system, |
1322 const std::string& init_data) { | 1335 const std::string& init_data) { |
1323 if (!LoadContentDecryptorInterface()) | 1336 if (!LoadContentDecryptorInterface()) |
1324 return false; | 1337 return false; |
1325 if (key_system.empty()) | 1338 if (key_system.empty()) |
1326 return false; | 1339 return false; |
1340 | |
1327 PP_Var init_data_array = | 1341 PP_Var init_data_array = |
1328 PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferPPVar( | 1342 PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferPPVar( |
1329 init_data.size(), init_data.data()); | 1343 init_data.size(), init_data.data()); |
1330 | 1344 |
1331 return PP_ToBool(plugin_decryption_interface_->GenerateKeyRequest( | 1345 return PP_ToBool(plugin_decryption_interface_->GenerateKeyRequest( |
1332 pp_instance(), | 1346 pp_instance(), |
1333 StringVar::StringToPPVar(key_system), | 1347 StringVar::StringToPPVar(key_system), |
1334 init_data_array)); | 1348 init_data_array)); |
1335 } | 1349 } |
1336 | 1350 |
(...skipping 19 matching lines...) Expand all Loading... | |
1356 | 1370 |
1357 bool PluginInstance::CancelKeyRequest(const std::string& session_id) { | 1371 bool PluginInstance::CancelKeyRequest(const std::string& session_id) { |
1358 if (!LoadContentDecryptorInterface()) | 1372 if (!LoadContentDecryptorInterface()) |
1359 return false; | 1373 return false; |
1360 | 1374 |
1361 return PP_ToBool(plugin_decryption_interface_->CancelKeyRequest( | 1375 return PP_ToBool(plugin_decryption_interface_->CancelKeyRequest( |
1362 pp_instance(), | 1376 pp_instance(), |
1363 StringVar::StringToPPVar(session_id))); | 1377 StringVar::StringToPPVar(session_id))); |
1364 } | 1378 } |
1365 | 1379 |
1366 bool PluginInstance::Decrypt(const base::StringPiece& encrypted_block, | 1380 namespace { |
1367 const DecryptedDataCB& callback) { | 1381 |
Tom Finegan
2012/08/22 01:05:47
This probably belongs in the anonymous namespace w
ddorwin
2012/08/22 01:26:26
Right, anonymous namespaces should not be in the m
xhwang
2012/08/24 00:51:51
Done.
xhwang
2012/08/24 00:51:51
Done.
| |
1382 template <uint32_t array_size> | |
1383 void CopyStringToArray(const std::string& str, | |
1384 uint8 (&array)[array_size], uint32_t* data_size) { | |
1385 DCHECK_LE(str.size(), array_size); | |
ddorwin
2012/08/22 04:09:21
CHECK_LE? Crash rather than overrun.
xhwang
2012/08/24 00:51:51
Done.
| |
1386 DCHECK(data_size); | |
1387 memcpy(array, str.data(), str.size()); | |
1388 *data_size = str.size(); | |
1389 } | |
1390 | |
1391 void MakePPEncryptedBlockInfo( | |
Tom Finegan
2012/08/22 01:05:47
s/MakePPEncryptedBlockInfo/MakeEncryptedBlockInfo/
xhwang
2012/08/24 00:51:51
Done.
| |
1392 const media::DecryptConfig& decrypt_config, | |
1393 int64_t timestamp, | |
1394 uint64_t request_id, | |
1395 PP_EncryptedBlockInfo* block_info) { | |
1396 DCHECK(block_info); | |
1397 | |
1398 block_info->tracking_info.request_id = request_id; | |
1399 block_info->tracking_info.timestamp = timestamp; | |
1400 block_info->data_offset = decrypt_config.data_offset(); | |
1401 | |
1402 CopyStringToArray(decrypt_config.key_id(), | |
ddorwin
2012/08/22 04:09:21
Just looking at the parameters here, the implement
xhwang
2012/08/24 00:51:51
Done.
| |
1403 block_info->key_id, &block_info->key_id_size); | |
1404 CopyStringToArray(decrypt_config.iv(), block_info->iv, &block_info->iv_size); | |
1405 CopyStringToArray(decrypt_config.checksum(), | |
1406 block_info->checksum, &block_info->checksum_size); | |
1407 | |
1408 block_info->num_subsamples = decrypt_config.subsamples().size(); | |
1409 CHECK(block_info->num_subsamples < arraysize(block_info->subsamples)); | |
ddorwin
2012/08/22 04:09:21
Do we check nicely somewhere else? We shouldn't cr
xhwang
2012/08/24 00:51:51
Done.
| |
1410 for (uint32_t i = 0; i < block_info->num_subsamples; ++i) { | |
1411 block_info->subsamples[i].clear_bytes = | |
1412 decrypt_config.subsamples()[i].clear_bytes; | |
1413 block_info->subsamples[i].cipher_bytes = | |
1414 decrypt_config.subsamples()[i].cypher_bytes; | |
1415 } | |
1416 } | |
1417 | |
1418 } // namespace | |
1419 | |
1420 bool PluginInstance::Decrypt( | |
1421 const scoped_refptr<media::DecoderBuffer>& encrypted_buffer, | |
1422 const media::Decryptor::DecryptCB& decrypt_cb) { | |
dmichael (off chromium)
2012/08/22 20:30:15
Does it still make sense to have a callback instea
xhwang
2012/08/24 00:51:51
Unfortunately, decrypt_client_ connects the decryp
| |
1368 if (!LoadContentDecryptorInterface()) | 1423 if (!LoadContentDecryptorInterface()) |
1369 return false; | 1424 return false; |
1370 ScopedPPResource encrypted_resource(MakeBufferResource(pp_instance(), | 1425 |
1371 encrypted_block)); | 1426 ScopedPPResource encrypted_resource(MakeBufferResource( |
1427 pp_instance(), | |
1428 encrypted_buffer->GetData(), | |
1429 encrypted_buffer->GetDataSize())); | |
1372 if (!encrypted_resource.get()) | 1430 if (!encrypted_resource.get()) |
1373 return false; | 1431 return false; |
1374 | 1432 |
1433 uint64_t request_id = next_decryption_request_id_++; | |
1434 | |
1375 PP_EncryptedBlockInfo block_info; | 1435 PP_EncryptedBlockInfo block_info; |
1436 memset(&block_info, 0, sizeof(block_info)); | |
ddorwin
2012/08/22 04:09:21
TODO - fix initialization here and in Tom's CL.
xhwang
2012/08/24 00:51:51
Done.
| |
1376 | 1437 |
1377 // TODO(tomfinegan): Store callback and ID in a map, and pass ID to decryptor. | 1438 DCHECK(encrypted_buffer->GetDecryptConfig()); |
1439 MakePPEncryptedBlockInfo(*encrypted_buffer->GetDecryptConfig(), | |
1440 encrypted_buffer->GetTimestamp().InMicroseconds(), | |
1441 request_id, | |
1442 &block_info); | |
Tom Finegan
2012/08/22 01:05:47
Wish there was a way to avoid this copy...
xhwang
2012/08/24 00:51:51
Yeah, it's ugly, fortunately we are not actually c
| |
1443 | |
1444 DCHECK(!ContainsKey(pending_decryption_cbs_, request_id)); | |
1445 pending_decryption_cbs_.insert(std::make_pair(request_id, decrypt_cb)); | |
1446 | |
1378 return PP_ToBool(plugin_decryption_interface_->Decrypt(pp_instance(), | 1447 return PP_ToBool(plugin_decryption_interface_->Decrypt(pp_instance(), |
1379 encrypted_resource, | 1448 encrypted_resource, |
1380 &block_info)); | 1449 &block_info)); |
1381 } | 1450 } |
1382 | 1451 |
1383 bool PluginInstance::DecryptAndDecode(const base::StringPiece& encrypted_block, | 1452 bool PluginInstance::DecryptAndDecode( |
1384 const DecryptedDataCB& callback) { | 1453 const scoped_refptr<media::DecoderBuffer>& encrypted_buffer, |
1454 const media::Decryptor::DecryptCB& decrypt_cb) { | |
1385 if (!LoadContentDecryptorInterface()) | 1455 if (!LoadContentDecryptorInterface()) |
1386 return false; | 1456 return false; |
1387 ScopedPPResource encrypted_resource(MakeBufferResource(pp_instance(), | 1457 |
1388 encrypted_block)); | 1458 ScopedPPResource encrypted_resource(MakeBufferResource( |
1459 pp_instance(), | |
1460 encrypted_buffer->GetData(), | |
1461 encrypted_buffer->GetDataSize())); | |
1389 if (!encrypted_resource.get()) | 1462 if (!encrypted_resource.get()) |
1390 return false; | 1463 return false; |
1391 | 1464 |
1392 PP_EncryptedBlockInfo block_info; | 1465 PP_EncryptedBlockInfo block_info; |
1393 | 1466 |
1394 // TODO(tomfinegan): Store callback and ID in a map, and pass ID to decryptor. | 1467 // TODO(tomfinegan): Store callback and ID in a map, and pass ID to decryptor. |
1395 return PP_ToBool(plugin_decryption_interface_->DecryptAndDecode( | 1468 return PP_ToBool(plugin_decryption_interface_->DecryptAndDecode( |
1396 pp_instance(), | 1469 pp_instance(), |
1397 encrypted_resource, | 1470 encrypted_resource, |
1398 &block_info)); | 1471 &block_info)); |
(...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2009 void PluginInstance::NeedKey(PP_Instance instance, | 2082 void PluginInstance::NeedKey(PP_Instance instance, |
2010 PP_Var key_system_var, | 2083 PP_Var key_system_var, |
2011 PP_Var session_id_var, | 2084 PP_Var session_id_var, |
2012 PP_Var init_data_var) { | 2085 PP_Var init_data_var) { |
2013 // TODO(tomfinegan): send the data to media stack. | 2086 // TODO(tomfinegan): send the data to media stack. |
2014 } | 2087 } |
2015 | 2088 |
2016 void PluginInstance::KeyAdded(PP_Instance instance, | 2089 void PluginInstance::KeyAdded(PP_Instance instance, |
2017 PP_Var key_system_var, | 2090 PP_Var key_system_var, |
2018 PP_Var session_id_var) { | 2091 PP_Var session_id_var) { |
2019 // TODO(tomfinegan): send the data to media stack. | 2092 StringVar* key_system_string = StringVar::FromPPVar(key_system_var); |
2093 StringVar* session_id_string = StringVar::FromPPVar(session_id_var); | |
2094 | |
2095 DCHECK(decryptor_client_); | |
2096 decryptor_client_->KeyAdded(key_system_string->value(), | |
2097 session_id_string->value()); | |
2020 } | 2098 } |
2021 | 2099 |
2022 void PluginInstance::KeyMessage(PP_Instance instance, | 2100 void PluginInstance::KeyMessage(PP_Instance instance, |
2023 PP_Var key_system_var, | 2101 PP_Var key_system_var, |
2024 PP_Var session_id_var, | 2102 PP_Var session_id_var, |
2025 PP_Resource message_resource, | 2103 PP_Resource message_resource, |
2026 PP_Var default_url_var) { | 2104 PP_Var default_url_var) { |
2027 // TODO(tomfinegan): send the data to media stack. | 2105 StringVar* key_system_string = StringVar::FromPPVar(key_system_var); |
2106 StringVar* session_id_string = StringVar::FromPPVar(session_id_var); | |
2107 StringVar* default_url_string = StringVar::FromPPVar(default_url_var); | |
dmichael (off chromium)
2012/08/22 20:30:15
You have to check these pointers before calling va
xhwang
2012/08/24 00:51:51
Done.
| |
2108 | |
2109 EnterResourceNoLock<PPB_Buffer_API> enter(message_resource, true); | |
2110 if (!enter.succeeded()) { | |
2111 decryptor_client_->KeyError(key_system_string->value(), | |
2112 session_id_string->value(), | |
2113 media::Decryptor::kUnknownError, | |
2114 0); | |
2115 } | |
2116 | |
2117 BufferAutoMapper mapper(enter.object()); | |
2118 scoped_array<uint8> message_array(new uint8[mapper.size()]); | |
2119 if (mapper.data() || mapper.size()) | |
ddorwin
2012/08/22 04:09:21
&& ?
xhwang
2012/08/24 00:51:51
Done.
| |
2120 memcpy(message_array.get(), mapper.data(), mapper.size()); | |
2121 | |
2122 DCHECK(decryptor_client_); | |
2123 decryptor_client_->KeyMessage(key_system_string->value(), | |
2124 session_id_string->value(), | |
2125 message_array.Pass(), | |
2126 mapper.size(), | |
2127 default_url_string->value()); | |
2028 } | 2128 } |
2029 | 2129 |
2030 void PluginInstance::KeyError(PP_Instance instance, | 2130 void PluginInstance::KeyError(PP_Instance instance, |
2031 PP_Var key_system_var, | 2131 PP_Var key_system_var, |
2032 PP_Var session_id_var, | 2132 PP_Var session_id_var, |
2033 int32_t media_error, | 2133 int32_t media_error, |
2034 int32_t system_code) { | 2134 int32_t system_code) { |
2035 // TODO(tomfinegan): send the data to media stack. | 2135 StringVar* key_system_string = StringVar::FromPPVar(key_system_var); |
2136 StringVar* session_id_string = StringVar::FromPPVar(session_id_var); | |
2137 | |
2138 DCHECK(decryptor_client_); | |
2139 decryptor_client_->KeyError( | |
2140 key_system_string->value(), | |
2141 session_id_string->value(), | |
2142 static_cast<media::Decryptor::KeyError>(media_error), | |
2143 system_code); | |
2036 } | 2144 } |
2037 | 2145 |
2038 void PluginInstance::DeliverBlock(PP_Instance instance, | 2146 void PluginInstance::DeliverBlock(PP_Instance instance, |
2039 PP_Resource decrypted_block, | 2147 PP_Resource decrypted_block, |
2040 const PP_DecryptedBlockInfo* block_info) { | 2148 const PP_DecryptedBlockInfo* block_info) { |
2041 // TODO(xhwang): Pass the decrypted block back to media stack. | 2149 DCHECK(block_info); |
2150 | |
2151 DecryptionCBMap::iterator found = pending_decryption_cbs_.find( | |
2152 block_info->tracking_info.request_id); | |
2153 | |
2154 if (found == pending_decryption_cbs_.end()) { | |
2155 LOG(WARNING) << "DeliverBlock(): request_id: " | |
2156 << block_info->tracking_info.request_id << " not found."; | |
ddorwin
2012/08/22 04:09:21
The ID isn't really useful to anyone not debugging
xhwang
2012/08/24 00:51:51
Suppose the CDM is implemented by a third party. T
| |
2157 return; | |
2158 } | |
2159 | |
2160 media::Decryptor::DecryptCB decrypt_cb = found->second; | |
2161 pending_decryption_cbs_.erase(found); | |
2162 | |
2163 if (block_info->result == PP_DECRYPTRESULT_DECRYPT_ERROR) { | |
2164 decrypt_cb.Run(media::Decryptor::kError, NULL); | |
2165 return; | |
2166 } | |
2167 | |
2168 if (block_info->result == PP_DECRYPTRESULT_DECRYPT_NOKEY) { | |
2169 decrypt_cb.Run(media::Decryptor::kNoKey, NULL); | |
2170 return; | |
2171 } | |
2172 | |
dmichael (off chromium)
2012/08/22 20:30:15
nit: It seems like there are a few excess lines he
| |
2173 DCHECK_EQ(block_info->result, PP_DECRYPTRESULT_SUCCESS); | |
ddorwin
2012/08/22 04:09:21
Is there a DECODE_ERROR yet or is that another CL?
xhwang
2012/08/24 00:51:51
DeliverBlock should not handle decode_error. Chang
| |
2174 EnterResourceNoLock<PPB_Buffer_API> enter(decrypted_block, true); | |
2175 if (!enter.succeeded()) { | |
2176 decrypt_cb.Run(media::Decryptor::kError, NULL); | |
2177 return; | |
2178 } | |
2179 | |
2180 BufferAutoMapper mapper(enter.object()); | |
2181 if (mapper.data() == NULL || mapper.size() == 0) { | |
ddorwin
2012/08/22 04:09:21
Inconsistent use of == vs. 2119.
xhwang
2012/08/24 00:51:51
Done.
| |
2182 decrypt_cb.Run(media::Decryptor::kError, NULL); | |
2183 return; | |
2184 } | |
2185 | |
2186 scoped_refptr<media::DecoderBuffer> decrypted_buffer( | |
2187 media::DecoderBuffer::CopyFrom( | |
2188 reinterpret_cast<const uint8*>(mapper.data()), mapper.size())); | |
2189 decrypted_buffer->SetTimestamp(base::TimeDelta::FromMicroseconds( | |
2190 block_info->tracking_info.timestamp)); | |
2191 decrypt_cb.Run(media::Decryptor::kSuccess, decrypted_buffer); | |
2042 } | 2192 } |
2043 | 2193 |
2044 void PluginInstance::DeliverFrame(PP_Instance instance, | 2194 void PluginInstance::DeliverFrame(PP_Instance instance, |
2045 PP_Resource decrypted_frame, | 2195 PP_Resource decrypted_frame, |
2046 const PP_DecryptedBlockInfo* block_info) { | 2196 const PP_DecryptedBlockInfo* block_info) { |
2047 // TODO(tomfinegan): To be implemented after completion of v0.1 of the | 2197 // TODO(tomfinegan): To be implemented after completion of v0.1 of the |
2048 // EME/CDM work. | 2198 // EME/CDM work. |
2049 } | 2199 } |
2050 | 2200 |
2051 void PluginInstance::DeliverSamples(PP_Instance instance, | 2201 void PluginInstance::DeliverSamples(PP_Instance instance, |
2052 PP_Resource decrypted_samples, | 2202 PP_Resource decrypted_samples, |
2053 const PP_DecryptedBlockInfo* block_info) { | 2203 const PP_DecryptedBlockInfo* block_info) { |
2054 // TODO(tomfinegan): To be implemented after completion of v0.1 of the | 2204 // TODO(tomfinegan): To be implemented after completion of v0.1 of the |
2055 // EME/CDM work. | 2205 // EME/CDM work. |
2056 } | 2206 } |
2057 | 2207 |
2058 | |
2059 void PluginInstance::NumberOfFindResultsChanged(PP_Instance instance, | 2208 void PluginInstance::NumberOfFindResultsChanged(PP_Instance instance, |
2060 int32_t total, | 2209 int32_t total, |
2061 PP_Bool final_result) { | 2210 PP_Bool final_result) { |
2062 DCHECK_NE(find_identifier_, -1); | 2211 DCHECK_NE(find_identifier_, -1); |
2063 delegate_->NumberOfFindResultsChanged(find_identifier_, total, | 2212 delegate_->NumberOfFindResultsChanged(find_identifier_, total, |
2064 PP_ToBool(final_result)); | 2213 PP_ToBool(final_result)); |
2065 } | 2214 } |
2066 | 2215 |
2067 void PluginInstance::SelectedFindResultChanged(PP_Instance instance, | 2216 void PluginInstance::SelectedFindResultChanged(PP_Instance instance, |
2068 int32_t index) { | 2217 int32_t index) { |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2424 screen_size_for_fullscreen_ = gfx::Size(); | 2573 screen_size_for_fullscreen_ = gfx::Size(); |
2425 WebElement element = container_->element(); | 2574 WebElement element = container_->element(); |
2426 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); | 2575 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); |
2427 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); | 2576 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); |
2428 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); | 2577 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); |
2429 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); | 2578 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); |
2430 } | 2579 } |
2431 | 2580 |
2432 } // namespace ppapi | 2581 } // namespace ppapi |
2433 } // namespace webkit | 2582 } // namespace webkit |
OLD | NEW |