From 8ce157e06fbcb1ba21dc5c850fca53fd0aad3b5e Mon Sep 17 00:00:00 2001 From: JW Wang Date: Fri, 29 Jul 2016 14:44:22 +0800 Subject: [PATCH] Bug 1290364 - clear mOwner in Shutdown(). r=cpearce MozReview-Commit-ID: 2CsYKcSrEOJ --HG-- extra : rebase_source : 3fd60ea1dbbf57c168fa8cebb9bb5594ee8c19fb --- dom/media/MediaDecoder.cpp | 7 ++++--- dom/media/MediaDecoder.h | 6 +++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/dom/media/MediaDecoder.cpp b/dom/media/MediaDecoder.cpp index 74cd20fe2b67..499b953f33da 100644 --- a/dom/media/MediaDecoder.cpp +++ b/dom/media/MediaDecoder.cpp @@ -162,7 +162,7 @@ MediaDecoderOwner* MediaDecoder::ResourceCallback::GetMediaOwner() const { MOZ_ASSERT(NS_IsMainThread()); - return mDecoder ? mDecoder->GetOwner() : nullptr; + return mDecoder ? mDecoder->mOwner : nullptr; } void @@ -571,7 +571,7 @@ MediaDecoder::MediaDecoder(MediaDecoderOwner* aOwner) "MediaDecoder::mMediaSeekable (Canonical)") , mMediaSeekableOnlyInBufferedRanges(AbstractThread::MainThread(), false, "MediaDecoder::mMediaSeekableOnlyInBufferedRanges (Canonical)") - , mIsVisible(AbstractThread::MainThread(), !mOwner->IsHidden(), + , mIsVisible(AbstractThread::MainThread(), !aOwner->IsHidden(), "MediaDecoder::mIsVisible (Canonical)") , mTelemetryReported(false) { @@ -667,6 +667,7 @@ MediaDecoder::Shutdown() CancelDormantTimer(); ChangeState(PLAY_STATE_SHUTDOWN); + mOwner = nullptr; } MediaDecoder::~MediaDecoder() @@ -1857,7 +1858,7 @@ MediaDecoder::GetOwner() const { MOZ_ASSERT(NS_IsMainThread()); // mOwner is valid until shutdown. - return !IsShutdown() ? mOwner : nullptr; + return mOwner; } void diff --git a/dom/media/MediaDecoder.h b/dom/media/MediaDecoder.h index 9e5d1fe2b57d..d2763cfb5d36 100644 --- a/dom/media/MediaDecoder.h +++ b/dom/media/MediaDecoder.h @@ -673,9 +673,9 @@ protected: void OnMetadataUpdate(TimedMetadata&& aMetadata); // This should only ever be accessed from the main thread. - // It is set in Init and cleared in Shutdown when the element goes away. - // The decoder does not add a reference the element. - MediaDecoderOwner* const mOwner; + // It is set in the constructor and cleared in Shutdown when the element goes + // away. The decoder does not add a reference the element. + MediaDecoderOwner* mOwner; // Counters related to decode and presentation of frames. const RefPtr mFrameStats;