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

Side by Side Diff: content/renderer/pepper/content_decryptor_delegate.cc

Issue 116443009: Handle plugin instance crash in ContentDecryptorDelegate. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments addressed Created 6 years, 11 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
OLDNEW
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 "content/renderer/pepper/content_decryptor_delegate.h" 5 #include "content/renderer/pepper/content_decryptor_delegate.h"
6 6
7 #include "base/callback_helpers.h" 7 #include "base/callback_helpers.h"
8 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "base/message_loop/message_loop_proxy.h" 9 #include "base/message_loop/message_loop_proxy.h"
10 #include "base/safe_numerics.h" 10 #include "base/safe_numerics.h"
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 : pp_instance_(pp_instance), 249 : pp_instance_(pp_instance),
250 plugin_decryption_interface_(plugin_decryption_interface), 250 plugin_decryption_interface_(plugin_decryption_interface),
251 next_decryption_request_id_(1), 251 next_decryption_request_id_(1),
252 audio_samples_per_second_(0), 252 audio_samples_per_second_(0),
253 audio_channel_count_(0), 253 audio_channel_count_(0),
254 weak_ptr_factory_(this) { 254 weak_ptr_factory_(this) {
255 weak_this_ = weak_ptr_factory_.GetWeakPtr(); 255 weak_this_ = weak_ptr_factory_.GetWeakPtr();
256 } 256 }
257 257
258 ContentDecryptorDelegate::~ContentDecryptorDelegate() { 258 ContentDecryptorDelegate::~ContentDecryptorDelegate() {
259 SatisfyAllPendingCallbacksOnError();
259 } 260 }
260 261
261 void ContentDecryptorDelegate::Initialize(const std::string& key_system) { 262 void ContentDecryptorDelegate::Initialize(
263 const std::string& key_system,
264 const media::SessionCreatedCB& session_created_cb,
265 const media::SessionMessageCB& session_message_cb,
266 const media::SessionReadyCB& session_ready_cb,
267 const media::SessionClosedCB& session_closed_cb,
268 const media::SessionErrorCB& session_error_cb,
269 const base::Closure& fatal_plugin_error_cb) {
262 DCHECK(!key_system.empty()); 270 DCHECK(!key_system.empty());
263 DCHECK(key_system_.empty()); 271 DCHECK(key_system_.empty());
264 key_system_ = key_system; 272 key_system_ = key_system;
265 273
266 plugin_decryption_interface_->Initialize(
267 pp_instance_,
268 StringVar::StringToPPVar(key_system_));
269 }
270
271 void ContentDecryptorDelegate::SetSessionEventCallbacks(
272 const media::SessionCreatedCB& session_created_cb,
273 const media::SessionMessageCB& session_message_cb,
274 const media::SessionReadyCB& session_ready_cb,
275 const media::SessionClosedCB& session_closed_cb,
276 const media::SessionErrorCB& session_error_cb) {
277 session_created_cb_ = session_created_cb; 274 session_created_cb_ = session_created_cb;
278 session_message_cb_ = session_message_cb; 275 session_message_cb_ = session_message_cb;
279 session_ready_cb_ = session_ready_cb; 276 session_ready_cb_ = session_ready_cb;
280 session_closed_cb_ = session_closed_cb; 277 session_closed_cb_ = session_closed_cb;
281 session_error_cb_ = session_error_cb; 278 session_error_cb_ = session_error_cb;
279 fatal_plugin_error_cb_ = fatal_plugin_error_cb;
280
281 plugin_decryption_interface_->Initialize(
282 pp_instance_, StringVar::StringToPPVar(key_system_));
283 }
284
285 void ContentDecryptorDelegate::InstanceCrashed() {
286 fatal_plugin_error_cb_.Run();
287 SatisfyAllPendingCallbacksOnError();
282 } 288 }
283 289
284 bool ContentDecryptorDelegate::CreateSession(uint32 session_id, 290 bool ContentDecryptorDelegate::CreateSession(uint32 session_id,
285 const std::string& type, 291 const std::string& type,
286 const uint8* init_data, 292 const uint8* init_data,
287 int init_data_length) { 293 int init_data_length) {
288 PP_Var init_data_array = 294 PP_Var init_data_array =
289 PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferPPVar( 295 PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferPPVar(
290 init_data_length, init_data); 296 init_data_length, init_data);
291 297
(...skipping 20 matching lines...) Expand all
312 return true; 318 return true;
313 } 319 }
314 320
315 // TODO(xhwang): Remove duplication of code in Decrypt(), 321 // TODO(xhwang): Remove duplication of code in Decrypt(),
316 // DecryptAndDecodeAudio() and DecryptAndDecodeVideo(). 322 // DecryptAndDecodeAudio() and DecryptAndDecodeVideo().
317 bool ContentDecryptorDelegate::Decrypt( 323 bool ContentDecryptorDelegate::Decrypt(
318 Decryptor::StreamType stream_type, 324 Decryptor::StreamType stream_type,
319 const scoped_refptr<media::DecoderBuffer>& encrypted_buffer, 325 const scoped_refptr<media::DecoderBuffer>& encrypted_buffer,
320 const Decryptor::DecryptCB& decrypt_cb) { 326 const Decryptor::DecryptCB& decrypt_cb) {
321 DVLOG(3) << "Decrypt() - stream_type: " << stream_type; 327 DVLOG(3) << "Decrypt() - stream_type: " << stream_type;
328
322 // |{audio|video}_input_resource_| is not being used by the plugin 329 // |{audio|video}_input_resource_| is not being used by the plugin
323 // now because there is only one pending audio/video decrypt request at any 330 // now because there is only one pending audio/video decrypt request at any
324 // time. This is enforced by the media pipeline. 331 // time. This is enforced by the media pipeline.
325 scoped_refptr<PPB_Buffer_Impl> encrypted_resource; 332 scoped_refptr<PPB_Buffer_Impl> encrypted_resource;
326 if (!MakeMediaBufferResource( 333 if (!MakeMediaBufferResource(
327 stream_type, encrypted_buffer, &encrypted_resource) || 334 stream_type, encrypted_buffer, &encrypted_resource) ||
328 !encrypted_resource.get()) { 335 !encrypted_resource.get()) {
329 return false; 336 return false;
330 } 337 }
331 ScopedPPResource pp_resource(encrypted_resource.get()); 338 ScopedPPResource pp_resource(encrypted_resource.get());
(...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after
1015 frame_count)); 1022 frame_count));
1016 frames->push_back(frame); 1023 frames->push_back(frame);
1017 1024
1018 cur += frame_size; 1025 cur += frame_size;
1019 bytes_left -= frame_size; 1026 bytes_left -= frame_size;
1020 } while (bytes_left > 0); 1027 } while (bytes_left > 0);
1021 1028
1022 return true; 1029 return true;
1023 } 1030 }
1024 1031
1032 void ContentDecryptorDelegate::SatisfyAllPendingCallbacksOnError() {
1033 if (!audio_decoder_init_cb_.is_null())
1034 audio_decoder_init_cb_.ResetAndReturn().Run(false);
1035
1036 if (!video_decoder_init_cb_.is_null())
1037 video_decoder_init_cb_.ResetAndReturn().Run(false);
1038
1039 audio_input_resource_ = NULL;
1040 video_input_resource_ = NULL;
1041
1042 if (!audio_decrypt_cb_.is_null())
1043 audio_decrypt_cb_.ResetAndReturn().Run(media::Decryptor::kError, NULL);
1044
1045 if (!video_decrypt_cb_.is_null())
1046 video_decrypt_cb_.ResetAndReturn().Run(media::Decryptor::kError, NULL);
1047
1048 if (!audio_decode_cb_.is_null()) {
1049 const media::Decryptor::AudioBuffers empty_frames;
1050 audio_decode_cb_.ResetAndReturn().Run(media::Decryptor::kError,
1051 empty_frames);
1052 }
1053
1054 if (!video_decode_cb_.is_null())
1055 video_decode_cb_.ResetAndReturn().Run(media::Decryptor::kError, NULL);
1056 }
1057
1025 } // namespace content 1058 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698