Chromium Code Reviews| Index: media/filters/decrypting_video_decoder.cc |
| diff --git a/media/filters/decrypting_video_decoder.cc b/media/filters/decrypting_video_decoder.cc |
| index 6fe6e69e0fd3304eea6008568917426f0bb71956..6179fd72369a002cc0ab38d8fcf97404fc0a40b2 100644 |
| --- a/media/filters/decrypting_video_decoder.cc |
| +++ b/media/filters/decrypting_video_decoder.cc |
| @@ -24,6 +24,7 @@ DecryptingVideoDecoder::DecryptingVideoDecoder( |
| const scoped_refptr<base::MessageLoopProxy>& message_loop, |
| const SetDecryptorReadyCB& set_decryptor_ready_cb) |
| : message_loop_(message_loop), |
| + weak_factory_(this), |
| state_(kUninitialized), |
| set_decryptor_ready_cb_(set_decryptor_ready_cb), |
| decryptor_(NULL), |
| @@ -40,6 +41,7 @@ void DecryptingVideoDecoder::Initialize( |
| DCHECK_EQ(state_, kUninitialized) << state_; |
| DCHECK(stream); |
| init_cb_ = BindToCurrentLoop(status_cb); |
| + weak_this_ = weak_factory_.GetWeakPtr(); |
|
Ami GONE FROM CHROMIUM
2013/03/22 23:48:01
Nothing ever invalidates the underlying WeakRefere
xhwang
2013/03/22 23:59:03
Hmm, is this required for all classes that uses We
Ami GONE FROM CHROMIUM
2013/03/23 00:02:01
Oh good, I think you're right!
(this is how I _tho
|
| const VideoDecoderConfig& config = stream->video_decoder_config(); |
| if (!config.IsValidConfig()) { |
| @@ -61,7 +63,7 @@ void DecryptingVideoDecoder::Initialize( |
| state_ = kDecryptorRequested; |
| set_decryptor_ready_cb_.Run(BindToCurrentLoop(base::Bind( |
| - &DecryptingVideoDecoder::SetDecryptor, this))); |
| + &DecryptingVideoDecoder::SetDecryptor, weak_this_))); |
| } |
| void DecryptingVideoDecoder::Read(const ReadCB& read_cb) { |
| @@ -166,7 +168,7 @@ void DecryptingVideoDecoder::SetDecryptor(Decryptor* decryptor) { |
| state_ = kPendingDecoderInit; |
| decryptor_->InitializeVideoDecoder( |
| demuxer_stream_->video_decoder_config(), BindToCurrentLoop(base::Bind( |
| - &DecryptingVideoDecoder::FinishInitialization, this))); |
| + &DecryptingVideoDecoder::FinishInitialization, weak_this_))); |
| } |
| void DecryptingVideoDecoder::FinishInitialization(bool success) { |
| @@ -188,7 +190,7 @@ void DecryptingVideoDecoder::FinishInitialization(bool success) { |
| } |
| decryptor_->RegisterNewKeyCB(Decryptor::kVideo, BindToCurrentLoop( |
| - base::Bind(&DecryptingVideoDecoder::OnKeyAdded, this))); |
| + base::Bind(&DecryptingVideoDecoder::OnKeyAdded, weak_this_))); |
| // Success! |
| state_ = kIdle; |
| @@ -230,7 +232,7 @@ void DecryptingVideoDecoder::ReadFromDemuxerStream() { |
| DCHECK(!read_cb_.is_null()); |
| demuxer_stream_->Read( |
| - base::Bind(&DecryptingVideoDecoder::DecryptAndDecodeBuffer, this)); |
| + base::Bind(&DecryptingVideoDecoder::DecryptAndDecodeBuffer, weak_this_)); |
|
Ami GONE FROM CHROMIUM
2013/03/22 23:48:01
What guarantees you get called back on this thread
scherkus (not reviewing)
2013/03/28 02:00:01
short term: it's part of the API contract to call
|
| } |
| void DecryptingVideoDecoder::DecryptAndDecodeBuffer( |
| @@ -253,7 +255,7 @@ void DecryptingVideoDecoder::DecryptAndDecodeBuffer( |
| decryptor_->DeinitializeDecoder(Decryptor::kVideo); |
| decryptor_->InitializeVideoDecoder( |
| demuxer_stream_->video_decoder_config(), BindToCurrentLoop(base::Bind( |
| - &DecryptingVideoDecoder::FinishConfigChange, this))); |
| + &DecryptingVideoDecoder::FinishConfigChange, weak_this_))); |
| return; |
| } |
| @@ -289,7 +291,7 @@ void DecryptingVideoDecoder::DecodePendingBuffer() { |
| decryptor_->DecryptAndDecodeVideo( |
| pending_buffer_to_decode_, BindToCurrentLoop(base::Bind( |
| - &DecryptingVideoDecoder::DeliverFrame, this, buffer_size))); |
| + &DecryptingVideoDecoder::DeliverFrame, weak_this_, buffer_size))); |
| } |
| void DecryptingVideoDecoder::DeliverFrame( |