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

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 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 : pp_instance_(pp_instance), 248 : pp_instance_(pp_instance),
249 plugin_decryption_interface_(plugin_decryption_interface), 249 plugin_decryption_interface_(plugin_decryption_interface),
250 next_decryption_request_id_(1), 250 next_decryption_request_id_(1),
251 audio_samples_per_second_(0), 251 audio_samples_per_second_(0),
252 audio_channel_count_(0), 252 audio_channel_count_(0),
253 weak_ptr_factory_(this) { 253 weak_ptr_factory_(this) {
254 weak_this_ = weak_ptr_factory_.GetWeakPtr(); 254 weak_this_ = weak_ptr_factory_.GetWeakPtr();
255 } 255 }
256 256
257 ContentDecryptorDelegate::~ContentDecryptorDelegate() { 257 ContentDecryptorDelegate::~ContentDecryptorDelegate() {
258 SatisfyAllPendingCallbacksOnError();
258 } 259 }
259 260
260 void ContentDecryptorDelegate::Initialize(const std::string& key_system) { 261 void ContentDecryptorDelegate::Initialize(
262 const std::string& key_system,
263 const media::SessionCreatedCB& session_created_cb,
264 const media::SessionMessageCB& session_message_cb,
265 const media::SessionReadyCB& session_ready_cb,
266 const media::SessionClosedCB& session_closed_cb,
267 const media::SessionErrorCB& session_error_cb,
268 const base::Closure& plugin_error_cb) {
261 DCHECK(!key_system.empty()); 269 DCHECK(!key_system.empty());
262 DCHECK(key_system_.empty()); 270 DCHECK(key_system_.empty());
263 key_system_ = key_system; 271 key_system_ = key_system;
264 272
265 plugin_decryption_interface_->Initialize(
266 pp_instance_,
267 StringVar::StringToPPVar(key_system_));
268 }
269
270 void ContentDecryptorDelegate::SetSessionEventCallbacks(
271 const media::SessionCreatedCB& session_created_cb,
272 const media::SessionMessageCB& session_message_cb,
273 const media::SessionReadyCB& session_ready_cb,
274 const media::SessionClosedCB& session_closed_cb,
275 const media::SessionErrorCB& session_error_cb) {
276 session_created_cb_ = session_created_cb; 273 session_created_cb_ = session_created_cb;
277 session_message_cb_ = session_message_cb; 274 session_message_cb_ = session_message_cb;
278 session_ready_cb_ = session_ready_cb; 275 session_ready_cb_ = session_ready_cb;
279 session_closed_cb_ = session_closed_cb; 276 session_closed_cb_ = session_closed_cb;
280 session_error_cb_ = session_error_cb; 277 session_error_cb_ = session_error_cb;
278 plugin_error_cb_ = plugin_error_cb;
279
280 plugin_decryption_interface_->Initialize(
ddorwin 2014/01/08 23:40:32 I think one/the reason Initialize() was separate b
xhwang 2014/01/09 01:58:49 If we really want to avoid IPC in ctor, we can add
281 pp_instance_, StringVar::StringToPPVar(key_system_));
282 }
283
284 void ContentDecryptorDelegate::InstanceCrashed() {
285 plugin_error_cb_.Run();
286 SatisfyAllPendingCallbacksOnError();
281 } 287 }
282 288
283 bool ContentDecryptorDelegate::CreateSession(uint32 session_id, 289 bool ContentDecryptorDelegate::CreateSession(uint32 session_id,
284 const std::string& type, 290 const std::string& type,
285 const uint8* init_data, 291 const uint8* init_data,
286 int init_data_length) { 292 int init_data_length) {
287 PP_Var init_data_array = 293 PP_Var init_data_array =
288 PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferPPVar( 294 PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferPPVar(
289 init_data_length, init_data); 295 init_data_length, init_data);
290 296
(...skipping 20 matching lines...) Expand all
311 return true; 317 return true;
312 } 318 }
313 319
314 // TODO(xhwang): Remove duplication of code in Decrypt(), 320 // TODO(xhwang): Remove duplication of code in Decrypt(),
315 // DecryptAndDecodeAudio() and DecryptAndDecodeVideo(). 321 // DecryptAndDecodeAudio() and DecryptAndDecodeVideo().
316 bool ContentDecryptorDelegate::Decrypt( 322 bool ContentDecryptorDelegate::Decrypt(
317 Decryptor::StreamType stream_type, 323 Decryptor::StreamType stream_type,
318 const scoped_refptr<media::DecoderBuffer>& encrypted_buffer, 324 const scoped_refptr<media::DecoderBuffer>& encrypted_buffer,
319 const Decryptor::DecryptCB& decrypt_cb) { 325 const Decryptor::DecryptCB& decrypt_cb) {
320 DVLOG(3) << "Decrypt() - stream_type: " << stream_type; 326 DVLOG(3) << "Decrypt() - stream_type: " << stream_type;
327
321 // |{audio|video}_input_resource_| is not being used by the plugin 328 // |{audio|video}_input_resource_| is not being used by the plugin
322 // now because there is only one pending audio/video decrypt request at any 329 // now because there is only one pending audio/video decrypt request at any
323 // time. This is enforced by the media pipeline. 330 // time. This is enforced by the media pipeline.
324 scoped_refptr<PPB_Buffer_Impl> encrypted_resource; 331 scoped_refptr<PPB_Buffer_Impl> encrypted_resource;
325 if (!MakeMediaBufferResource( 332 if (!MakeMediaBufferResource(
326 stream_type, encrypted_buffer, &encrypted_resource) || 333 stream_type, encrypted_buffer, &encrypted_resource) ||
327 !encrypted_resource.get()) { 334 !encrypted_resource.get()) {
328 return false; 335 return false;
329 } 336 }
330 ScopedPPResource pp_resource(encrypted_resource.get()); 337 ScopedPPResource pp_resource(encrypted_resource.get());
(...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after
1014 frame_count)); 1021 frame_count));
1015 frames->push_back(frame); 1022 frames->push_back(frame);
1016 1023
1017 cur += frame_size; 1024 cur += frame_size;
1018 bytes_left -= frame_size; 1025 bytes_left -= frame_size;
1019 } while (bytes_left > 0); 1026 } while (bytes_left > 0);
1020 1027
1021 return true; 1028 return true;
1022 } 1029 }
1023 1030
1031 void ContentDecryptorDelegate::SatisfyAllPendingCallbacksOnError() {
1032 if (!audio_decoder_init_cb_.is_null())
1033 audio_decoder_init_cb_.ResetAndReturn().Run(false);
1034
1035 if (!video_decoder_init_cb_.is_null())
1036 video_decoder_init_cb_.ResetAndReturn().Run(false);
1037
1038 audio_input_resource_ = NULL;
1039 video_input_resource_ = NULL;
1040
1041 if (!audio_decrypt_cb_.is_null())
1042 audio_decrypt_cb_.ResetAndReturn().Run(media::Decryptor::kError, NULL);
1043
1044 if (!video_decrypt_cb_.is_null())
1045 video_decrypt_cb_.ResetAndReturn().Run(media::Decryptor::kError, NULL);
1046
1047 if (!audio_decode_cb_.is_null()) {
1048 const media::Decryptor::AudioBuffers empty_frames;
1049 audio_decode_cb_.ResetAndReturn().Run(media::Decryptor::kError,
1050 empty_frames);
1051 }
1052
1053 if (!video_decode_cb_.is_null())
1054 video_decode_cb_.ResetAndReturn().Run(media::Decryptor::kError, NULL);
1055 }
1056
1024 } // namespace content 1057 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698