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

Unified Diff: media/filters/decrypting_audio_decoder.cc

Issue 167523004: Invalidate all weak pointers during Decrypting{Audio|Video}Decoder::Stop(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | media/filters/decrypting_video_decoder.cc » ('j') | media/filters/decrypting_video_decoder.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/filters/decrypting_audio_decoder.cc
diff --git a/media/filters/decrypting_audio_decoder.cc b/media/filters/decrypting_audio_decoder.cc
index 6a2dd3b7b741e45c0bc8a7ae12adec4b935e944d..b3114468d441fce8324cd6156c8e0f0deb07ec9e 100644
--- a/media/filters/decrypting_audio_decoder.cc
+++ b/media/filters/decrypting_audio_decoder.cc
@@ -149,6 +149,10 @@ void DecryptingAudioDecoder::Stop(const base::Closure& closure) {
DVLOG(2) << "Stop() - state: " << state_;
DCHECK(task_runner_->BelongsToCurrentThread());
+ // Invalidate all weak pointers so that pending callbacks won't be fired into
+ // this object.
+ weak_factory_.InvalidateWeakPtrs();
+
if (decryptor_) {
decryptor_->RegisterNewKeyCB(Decryptor::kAudio, Decryptor::NewKeyCB());
decryptor_->DeinitializeDecoder(Decryptor::kAudio);
@@ -163,6 +167,7 @@ void DecryptingAudioDecoder::Stop(const base::Closure& closure) {
base::ResetAndReturn(&read_cb_).Run(kAborted, NULL);
if (!reset_cb_.is_null())
base::ResetAndReturn(&reset_cb_).Run();
+
state_ = kStopped;
task_runner_->PostTask(FROM_HERE, closure);
}
@@ -189,10 +194,6 @@ DecryptingAudioDecoder::~DecryptingAudioDecoder() {
void DecryptingAudioDecoder::SetDecryptor(Decryptor* decryptor) {
DVLOG(2) << "SetDecryptor()";
DCHECK(task_runner_->BelongsToCurrentThread());
-
- if (state_ == kStopped)
acolwell GONE FROM CHROMIUM 2014/02/18 18:07:24 nit: DCHECK_NE(state_, kStopped) here and below to
xhwang 2014/02/18 18:46:11 We check below that DCHECK_EQ(state_, kDecryptorR
- return;
-
DCHECK_EQ(state_, kDecryptorRequested) << state_;
DCHECK(!init_cb_.is_null());
DCHECK(!set_decryptor_ready_cb_.is_null());
@@ -232,10 +233,6 @@ void DecryptingAudioDecoder::SetDecryptor(Decryptor* decryptor) {
void DecryptingAudioDecoder::FinishInitialization(bool success) {
DVLOG(2) << "FinishInitialization()";
DCHECK(task_runner_->BelongsToCurrentThread());
-
- if (state_ == kStopped)
- return;
-
DCHECK_EQ(state_, kPendingDecoderInit) << state_;
DCHECK(!init_cb_.is_null());
DCHECK(reset_cb_.is_null()); // No Reset() before initialization finished.
@@ -375,10 +372,6 @@ void DecryptingAudioDecoder::DeliverFrame(
const Decryptor::AudioBuffers& frames) {
DVLOG(3) << "DeliverFrame() - status: " << status;
DCHECK(task_runner_->BelongsToCurrentThread());
-
- if (state_ == kStopped)
- return;
-
DCHECK_EQ(state_, kPendingDecode) << state_;
DCHECK(!read_cb_.is_null());
DCHECK(pending_buffer_to_decode_.get());
« no previous file with comments | « no previous file | media/filters/decrypting_video_decoder.cc » ('j') | media/filters/decrypting_video_decoder.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698