Chromium Code Reviews| Index: media/filters/decrypting_demuxer_stream.cc |
| diff --git a/media/filters/decrypting_demuxer_stream.cc b/media/filters/decrypting_demuxer_stream.cc |
| index 39386e075ec68b2ab27095624a407b5dd0e6a72c..170fad850d991d111719e5793c7affb032eb1abe 100644 |
| --- a/media/filters/decrypting_demuxer_stream.cc |
| +++ b/media/filters/decrypting_demuxer_stream.cc |
| @@ -43,17 +43,16 @@ DecryptingDemuxerStream::DecryptingDemuxerStream( |
| key_added_while_decrypt_pending_(false) { |
| } |
| -void DecryptingDemuxerStream::Initialize( |
| - DemuxerStream* stream, |
| - const PipelineStatusCB& status_cb) { |
| - DVLOG(2) << "Initialize()"; |
| +void DecryptingDemuxerStream::Initialize(DemuxerStream* stream, |
| + const PipelineStatusCB& status_cb) { |
| + DVLOG(2) << __FUNCTION__; |
| DCHECK(message_loop_->BelongsToCurrentThread()); |
| DCHECK_EQ(state_, kUninitialized) << state_; |
| DCHECK(!demuxer_stream_); |
| weak_this_ = weak_factory_.GetWeakPtr(); |
| demuxer_stream_ = stream; |
| - init_cb_ = status_cb; |
| + init_cb_ = BindToCurrentLoop(status_cb); |
| InitializeDecoderConfig(); |
| @@ -63,20 +62,20 @@ void DecryptingDemuxerStream::Initialize( |
| } |
| void DecryptingDemuxerStream::Read(const ReadCB& read_cb) { |
| - DVLOG(3) << "Read()"; |
| + DVLOG(3) << __FUNCTION__; |
| DCHECK(message_loop_->BelongsToCurrentThread()); |
| DCHECK_EQ(state_, kIdle) << state_; |
| DCHECK(!read_cb.is_null()); |
| CHECK(read_cb_.is_null()) << "Overlapping reads are not supported."; |
| - read_cb_ = read_cb; |
| + read_cb_ = BindToCurrentLoop(read_cb); |
| state_ = kPendingDemuxerRead; |
| demuxer_stream_->Read( |
| base::Bind(&DecryptingDemuxerStream::DecryptBuffer, weak_this_)); |
| } |
| void DecryptingDemuxerStream::Reset(const base::Closure& closure) { |
| - DVLOG(2) << "Reset() - state: " << state_; |
| + DVLOG(2) << __FUNCTION__ << " - state: " << state_; |
| DCHECK(message_loop_->BelongsToCurrentThread()); |
| DCHECK(state_ != kUninitialized && state_ != kDecryptorRequested) << state_; |
| DCHECK(init_cb_.is_null()); // No Reset() during pending initialization. |
| @@ -126,10 +125,16 @@ void DecryptingDemuxerStream::EnableBitstreamConverter() { |
| demuxer_stream_->EnableBitstreamConverter(); |
| } |
| -DecryptingDemuxerStream::~DecryptingDemuxerStream() {} |
| +DecryptingDemuxerStream::~DecryptingDemuxerStream() { |
| + DVLOG(2) << __FUNCTION__; |
| + if (!set_decryptor_ready_cb_.is_null()) { |
| + base::ResetAndReturn(&set_decryptor_ready_cb_).Run(DecryptorReadyCB()); |
| + set_decryptor_ready_cb_.Reset(); |
|
whywhat
2013/09/17 01:00:40
Hm, so you reset the callback, then call it and re
xhwang
2013/09/17 01:13:00
Good catch. Done.
|
| + } |
| +} |
| void DecryptingDemuxerStream::SetDecryptor(Decryptor* decryptor) { |
| - DVLOG(2) << "SetDecryptor()"; |
| + DVLOG(2) << __FUNCTION__; |
| DCHECK(message_loop_->BelongsToCurrentThread()); |
| DCHECK_EQ(state_, kDecryptorRequested) << state_; |
| DCHECK(!init_cb_.is_null()); |
| @@ -138,8 +143,8 @@ void DecryptingDemuxerStream::SetDecryptor(Decryptor* decryptor) { |
| set_decryptor_ready_cb_.Reset(); |
| if (!decryptor) { |
| - base::ResetAndReturn(&init_cb_).Run(DECODER_ERROR_NOT_SUPPORTED); |
|
xhwang
2013/09/17 00:53:49
The caller could destroy |this| and create a new o
whywhat
2013/09/17 01:00:40
I'd at least leave a comment in the code saying th
xhwang
2013/09/17 01:13:00
I am forcing the post. See line 55 in the new code
|
| state_ = kUninitialized; |
| + base::ResetAndReturn(&init_cb_).Run(DECODER_ERROR_NOT_SUPPORTED); |
| return; |
| } |
| @@ -156,7 +161,7 @@ void DecryptingDemuxerStream::SetDecryptor(Decryptor* decryptor) { |
| void DecryptingDemuxerStream::DecryptBuffer( |
| DemuxerStream::Status status, |
| const scoped_refptr<DecoderBuffer>& buffer) { |
| - DVLOG(3) << "DecryptBuffer()"; |
| + DVLOG(3) << __FUNCTION__; |
| DCHECK(message_loop_->BelongsToCurrentThread()); |
| DCHECK_EQ(state_, kPendingDemuxerRead) << state_; |
| DCHECK(!read_cb_.is_null()); |
| @@ -212,7 +217,7 @@ void DecryptingDemuxerStream::DecryptPendingBuffer() { |
| void DecryptingDemuxerStream::DeliverBuffer( |
| Decryptor::Status status, |
| const scoped_refptr<DecoderBuffer>& decrypted_buffer) { |
| - DVLOG(3) << "DeliverBuffer() - status: " << status; |
| + DVLOG(3) << __FUNCTION__ << " - status: " << status; |
| DCHECK(message_loop_->BelongsToCurrentThread()); |
| DCHECK_EQ(state_, kPendingDecrypt) << state_; |
| DCHECK_NE(status, Decryptor::kNeedMoreData); |