Index: content/renderer/pepper/content_decryptor_delegate.cc |
diff --git a/content/renderer/pepper/content_decryptor_delegate.cc b/content/renderer/pepper/content_decryptor_delegate.cc |
index 49790db2b7b8b15ab993a79297f7cb338e56bbf4..a7d75dd30c0b1fd223a6f18d458ef840d2279392 100644 |
--- a/content/renderer/pepper/content_decryptor_delegate.cc |
+++ b/content/renderer/pepper/content_decryptor_delegate.cc |
@@ -255,7 +255,8 @@ ContentDecryptorDelegate::ContentDecryptorDelegate( |
pending_video_decode_request_id_(0), |
audio_samples_per_second_(0), |
audio_channel_count_(0), |
- weak_ptr_factory_(this) { |
+ weak_ptr_factory_(this), |
+ is_instance_crashed_(false) { |
weak_this_ = weak_ptr_factory_.GetWeakPtr(); |
} |
@@ -285,10 +286,56 @@ void ContentDecryptorDelegate::SetSessionEventCallbacks( |
session_error_cb_ = session_error_cb; |
} |
+void ContentDecryptorDelegate::InstanceCrashed() { |
+ if (!pending_audio_decoder_init_cb_.is_null()) { |
+ pending_audio_decoder_init_request_id_ = 0; |
+ base::ResetAndReturn(&pending_audio_decoder_init_cb_).Run(false); |
+ } |
+ |
+ if (!pending_video_decoder_init_cb_.is_null()) { |
+ pending_video_decoder_init_request_id_ = 0; |
+ base::ResetAndReturn(&pending_video_decoder_init_cb_).Run(false); |
+ } |
+ |
+ if (!pending_audio_decrypt_cb_.is_null()) { |
+ audio_input_resource_ = NULL; |
+ pending_audio_decrypt_request_id_ = 0; |
+ base::ResetAndReturn(&pending_audio_decrypt_cb_) |
+ .Run(media::Decryptor::kError, NULL); |
+ } |
+ |
+ if (!pending_video_decrypt_cb_.is_null()) { |
+ video_input_resource_ = NULL; |
+ pending_video_decrypt_request_id_ = 0; |
+ base::ResetAndReturn(&pending_video_decrypt_cb_) |
+ .Run(media::Decryptor::kError, NULL); |
+ } |
+ |
+ if (!pending_audio_decode_cb_.is_null()) { |
+ audio_input_resource_ = NULL; |
+ pending_audio_decode_request_id_ = 0; |
+ const media::Decryptor::AudioBuffers empty_frames; |
+ base::ResetAndReturn(&pending_audio_decode_cb_) |
+ .Run(media::Decryptor::kError, empty_frames); |
+ } |
+ |
+ if (!pending_video_decode_cb_.is_null()) { |
+ video_input_resource_ = NULL; |
+ pending_video_decode_request_id_ = 0; |
+ base::ResetAndReturn(&pending_video_decode_cb_) |
+ .Run(media::Decryptor::kError, NULL); |
+ } |
+ |
+ is_instance_crashed_ = true; |
+} |
xhwang
2013/12/28 01:00:28
We have too many duplicate code about reqeust_id a
|
+ |
bool ContentDecryptorDelegate::CreateSession(uint32 session_id, |
const std::string& type, |
const uint8* init_data, |
int init_data_length) { |
+ if (is_instance_crashed_) |
+ return false; |
+ |
PP_Var init_data_array = |
PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferPPVar( |
init_data_length, init_data); |
@@ -303,6 +350,9 @@ bool ContentDecryptorDelegate::CreateSession(uint32 session_id, |
bool ContentDecryptorDelegate::UpdateSession(uint32 session_id, |
const uint8* response, |
int response_length) { |
+ if (is_instance_crashed_) |
+ return false; |
+ |
PP_Var response_array = |
PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferPPVar( |
response_length, response); |
@@ -312,6 +362,9 @@ bool ContentDecryptorDelegate::UpdateSession(uint32 session_id, |
} |
bool ContentDecryptorDelegate::ReleaseSession(uint32 session_id) { |
+ if (is_instance_crashed_) |
+ return false; |
+ |
plugin_decryption_interface_->ReleaseSession(pp_instance_, session_id); |
return true; |
} |
@@ -323,6 +376,10 @@ bool ContentDecryptorDelegate::Decrypt( |
const scoped_refptr<media::DecoderBuffer>& encrypted_buffer, |
const media::Decryptor::DecryptCB& decrypt_cb) { |
DVLOG(3) << "Decrypt() - stream_type: " << stream_type; |
+ |
+ if (is_instance_crashed_) |
+ return false; |
+ |
// |{audio|video}_input_resource_| is not being used by the plugin |
// now because there is only one pending audio/video decrypt request at any |
// time. This is enforced by the media pipeline. |
@@ -375,6 +432,9 @@ bool ContentDecryptorDelegate::CancelDecrypt( |
media::Decryptor::StreamType stream_type) { |
DVLOG(3) << "CancelDecrypt() - stream_type: " << stream_type; |
+ if (is_instance_crashed_) |
+ return false; |
+ |
media::Decryptor::DecryptCB decrypt_cb; |
switch (stream_type) { |
case media::Decryptor::kAudio: |
@@ -407,6 +467,9 @@ bool ContentDecryptorDelegate::CancelDecrypt( |
bool ContentDecryptorDelegate::InitializeAudioDecoder( |
const media::AudioDecoderConfig& decoder_config, |
const media::Decryptor::DecoderInitCB& init_cb) { |
+ if (is_instance_crashed_) |
+ return false; |
+ |
PP_AudioDecoderConfig pp_decoder_config; |
pp_decoder_config.codec = |
MediaAudioCodecToPpAudioCodec(decoder_config.codec()); |
@@ -442,6 +505,9 @@ bool ContentDecryptorDelegate::InitializeAudioDecoder( |
bool ContentDecryptorDelegate::InitializeVideoDecoder( |
const media::VideoDecoderConfig& decoder_config, |
const media::Decryptor::DecoderInitCB& init_cb) { |
+ if (is_instance_crashed_) |
+ return false; |
+ |
PP_VideoDecoderConfig pp_decoder_config; |
pp_decoder_config.codec = |
MediaVideoCodecToPpVideoCodec(decoder_config.codec()); |
@@ -477,6 +543,9 @@ bool ContentDecryptorDelegate::InitializeVideoDecoder( |
bool ContentDecryptorDelegate::DeinitializeDecoder( |
media::Decryptor::StreamType stream_type) { |
+ if (is_instance_crashed_) |
+ return false; |
+ |
CancelDecode(stream_type); |
natural_size_ = gfx::Size(); |
@@ -490,6 +559,9 @@ bool ContentDecryptorDelegate::DeinitializeDecoder( |
bool ContentDecryptorDelegate::ResetDecoder( |
media::Decryptor::StreamType stream_type) { |
+ if (is_instance_crashed_) |
+ return false; |
+ |
CancelDecode(stream_type); |
// TODO(tomfinegan): Add decoder reset request tracking. |
@@ -501,6 +573,9 @@ bool ContentDecryptorDelegate::ResetDecoder( |
bool ContentDecryptorDelegate::DecryptAndDecodeAudio( |
const scoped_refptr<media::DecoderBuffer>& encrypted_buffer, |
const media::Decryptor::AudioDecodeCB& audio_decode_cb) { |
+ if (is_instance_crashed_) |
+ return false; |
+ |
// |audio_input_resource_| is not being used by the plugin now |
// because there is only one pending audio decode request at any time. |
// This is enforced by the media pipeline. |
@@ -545,6 +620,9 @@ bool ContentDecryptorDelegate::DecryptAndDecodeAudio( |
bool ContentDecryptorDelegate::DecryptAndDecodeVideo( |
const scoped_refptr<media::DecoderBuffer>& encrypted_buffer, |
const media::Decryptor::VideoDecodeCB& video_decode_cb) { |
+ if (is_instance_crashed_) |
+ return false; |
+ |
// |video_input_resource_| is not being used by the plugin now |
// because there is only one pending video decode request at any time. |
// This is enforced by the media pipeline. |