Bug 1332544 - replace use of mOwner with GetOwner() which provides more checks. r=gerald

MozReview-Commit-ID: DUTO4vR2kjU

--HG--
extra : rebase_source : 5edfabb169efdc0be938ed85d68d42f8694280d1
This commit is contained in:
JW Wang 2017-01-20 11:47:53 +08:00
Родитель 4fd7502e78
Коммит e13e207c12
2 изменённых файлов: 30 добавлений и 30 удалений

Просмотреть файл

@ -163,7 +163,7 @@ MediaDecoderOwner*
MediaDecoder::ResourceCallback::GetMediaOwner() const
{
MOZ_ASSERT(NS_IsMainThread());
return mDecoder ? mDecoder->mOwner : nullptr;
return mDecoder ? mDecoder->GetOwner() : nullptr;
}
void
@ -540,10 +540,10 @@ MediaDecoder::OnPlaybackEvent(MediaEventType aEvent)
Invalidate();
break;
case MediaEventType::EnterVideoSuspend:
mOwner->DispatchAsyncEvent(NS_LITERAL_STRING("mozentervideosuspend"));
GetOwner()->DispatchAsyncEvent(NS_LITERAL_STRING("mozentervideosuspend"));
break;
case MediaEventType::ExitVideoSuspend:
mOwner->DispatchAsyncEvent(NS_LITERAL_STRING("mozexitvideosuspend"));
GetOwner()->DispatchAsyncEvent(NS_LITERAL_STRING("mozexitvideosuspend"));
break;
}
}
@ -560,7 +560,7 @@ MediaDecoder::OnDecoderDoctorEvent(DecoderDoctorEvent aEvent)
MOZ_ASSERT(NS_IsMainThread());
// OnDecoderDoctorEvent is disconnected at shutdown time.
MOZ_DIAGNOSTIC_ASSERT(!IsShutdown());
HTMLMediaElement* element = mOwner->GetMediaElement();
HTMLMediaElement* element = GetOwner()->GetMediaElement();
if (!element) {
return;
}
@ -704,7 +704,7 @@ MediaDecoder::Seek(double aTime, SeekTarget::Type aSeekType, dom::Promise* aProm
if (mPlayState == PLAY_STATE_ENDED) {
PinForSeek();
ChangeState(mOwner->GetPaused() ? PLAY_STATE_PAUSED : PLAY_STATE_PLAYING);
ChangeState(GetOwner()->GetPaused() ? PLAY_STATE_PAUSED : PLAY_STATE_PLAYING);
}
return NS_OK;
}
@ -805,12 +805,12 @@ MediaDecoder::MetadataLoaded(nsAutoPtr<MediaInfo> aInfo,
// our new size.
if (aEventVisibility != MediaDecoderEventVisibility::Suppressed) {
mFiredMetadataLoaded = true;
mOwner->MetadataLoaded(mInfo, nsAutoPtr<const MetadataTags>(aTags.forget()));
GetOwner()->MetadataLoaded(mInfo, nsAutoPtr<const MetadataTags>(aTags.forget()));
}
// Invalidate() will end up calling mOwner->UpdateMediaSize with the last
// Invalidate() will end up calling GetOwner()->UpdateMediaSize with the last
// dimensions retrieved from the video frame container. The video frame
// container contains more up to date dimensions than aInfo.
// So we call Invalidate() after calling mOwner->MetadataLoaded to ensure
// So we call Invalidate() after calling GetOwner()->MetadataLoaded to ensure
// the media element has the latest dimensions.
Invalidate();
@ -885,10 +885,10 @@ MediaDecoder::FirstFrameLoaded(nsAutoPtr<MediaInfo> aInfo,
// that autoplay should run.
NotifySuspendedStatusChanged();
// mOwner->FirstFrameLoaded() might call us back. Put it at the bottom of
// GetOwner()->FirstFrameLoaded() might call us back. Put it at the bottom of
// this function to avoid unexpected shutdown from reentrant calls.
if (aEventVisibility != MediaDecoderEventVisibility::Suppressed) {
mOwner->FirstFrameLoaded();
GetOwner()->FirstFrameLoaded();
}
}
@ -897,7 +897,7 @@ MediaDecoder::NetworkError()
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_DIAGNOSTIC_ASSERT(!IsShutdown());
mOwner->NetworkError();
GetOwner()->NetworkError();
}
void
@ -905,7 +905,7 @@ MediaDecoder::DecodeError(const MediaResult& aError)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_DIAGNOSTIC_ASSERT(!IsShutdown());
mOwner->DecodeError(aError);
GetOwner()->DecodeError(aError);
}
void
@ -927,7 +927,7 @@ MediaDecoder::OwnerHasError() const
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_DIAGNOSTIC_ASSERT(!IsShutdown());
return mOwner->HasError();
return GetOwner()->HasError();
}
class MediaElementGMPCrashHelper : public GMPCrashHelper
@ -954,8 +954,8 @@ already_AddRefed<GMPCrashHelper>
MediaDecoder::GetCrashHelper()
{
MOZ_ASSERT(NS_IsMainThread());
return mOwner->GetMediaElement() ?
MakeAndAddRef<MediaElementGMPCrashHelper>(mOwner->GetMediaElement()) : nullptr;
return GetOwner()->GetMediaElement() ?
MakeAndAddRef<MediaElementGMPCrashHelper>(GetOwner()->GetMediaElement()) : nullptr;
}
bool
@ -989,9 +989,9 @@ MediaDecoder::PlaybackEnded()
ChangeState(PLAY_STATE_ENDED);
InvalidateWithFlags(VideoFrameContainer::INVALIDATE_FORCE);
mOwner->PlaybackEnded();
GetOwner()->PlaybackEnded();
// This must be called after |mOwner->PlaybackEnded()| call above, in order
// This must be called after |GetOwner()->PlaybackEnded()| call above, in order
// to fire the required durationchange.
if (IsInfinite()) {
SetInfinite(false);
@ -1061,7 +1061,7 @@ MediaDecoder::NotifySuspendedStatusChanged()
MOZ_DIAGNOSTIC_ASSERT(!IsShutdown());
if (mResource) {
bool suspended = mResource->IsSuspendedByCache();
mOwner->NotifySuspendedByCache(suspended);
GetOwner()->NotifySuspendedByCache(suspended);
}
}
@ -1071,7 +1071,7 @@ MediaDecoder::NotifyBytesDownloaded()
MOZ_ASSERT(NS_IsMainThread());
MOZ_DIAGNOSTIC_ASSERT(!IsShutdown());
UpdatePlaybackRate();
mOwner->DownloadProgressed();
GetOwner()->DownloadProgressed();
}
void
@ -1084,7 +1084,7 @@ MediaDecoder::NotifyDownloadEnded(nsresult aStatus)
if (aStatus == NS_BINDING_ABORTED) {
// Download has been cancelled by user.
mOwner->LoadAborted();
GetOwner()->LoadAborted();
return;
}
@ -1107,7 +1107,7 @@ MediaDecoder::NotifyPrincipalChanged()
MOZ_DIAGNOSTIC_ASSERT(!IsShutdown());
nsCOMPtr<nsIPrincipal> newPrincipal = GetCurrentPrincipal();
mMediaPrincipalHandle = MakePrincipalHandle(newPrincipal);
mOwner->NotifyDecoderPrincipalChanged();
GetOwner()->NotifyDecoderPrincipalChanged();
}
void
@ -1144,7 +1144,7 @@ MediaDecoder::OnSeekResolved()
// Ensure logical position is updated after seek.
UpdateLogicalPositionInternal();
mOwner->SeekCompleted();
GetOwner()->SeekCompleted();
AsyncResolveSeekDOMPromiseIfExists();
}
@ -1162,7 +1162,7 @@ MediaDecoder::SeekingStarted()
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_DIAGNOSTIC_ASSERT(!IsShutdown());
mOwner->SeekStarted();
GetOwner()->SeekStarted();
}
void
@ -1237,7 +1237,7 @@ MediaDecoder::DurationChanged()
// of whether we should fire durationchange on explicit infinity.
if (mFiredMetadataLoaded &&
(!mozilla::IsInfinite<double>(mDuration) || mExplicitDuration.Ref().isSome())) {
mOwner->DispatchAsyncEvent(NS_LITERAL_STRING("durationchange"));
GetOwner()->DispatchAsyncEvent(NS_LITERAL_STRING("durationchange"));
}
if (CurrentPosition() > TimeUnit::FromSeconds(mDuration).ToMicroseconds()) {
@ -1374,7 +1374,7 @@ MediaDecoder::SetPlaybackRate(double aPlaybackRate)
}
if (oldRate == 0 && !mOwner->GetPaused()) {
if (oldRate == 0 && !GetOwner()->GetPaused()) {
// PlaybackRate is no longer null.
// Restart the playback if the media was playing.
Play();
@ -1506,7 +1506,7 @@ MediaDecoder::FireTimeUpdate()
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_DIAGNOSTIC_ASSERT(!IsShutdown());
mOwner->FireTimeUpdate(true);
GetOwner()->FireTimeUpdate(true);
}
void
@ -1662,7 +1662,7 @@ MediaDecoder::ConstructMediaTracks()
return;
}
HTMLMediaElement* element = mOwner->GetMediaElement();
HTMLMediaElement* element = GetOwner()->GetMediaElement();
if (!element) {
return;
}
@ -1695,7 +1695,7 @@ MediaDecoder::RemoveMediaTracks()
MOZ_ASSERT(NS_IsMainThread());
MOZ_DIAGNOSTIC_ASSERT(!IsShutdown());
HTMLMediaElement* element = mOwner->GetMediaElement();
HTMLMediaElement* element = GetOwner()->GetMediaElement();
if (!element) {
return;
}
@ -1792,7 +1792,7 @@ void
MediaDecoder::NotifyAudibleStateChanged()
{
MOZ_DIAGNOSTIC_ASSERT(!IsShutdown());
mOwner->SetAudibleState(mIsAudioDataAudible);
GetOwner()->SetAudibleState(mIsAudioDataAudible);
}
MediaMemoryTracker::MediaMemoryTracker()

Просмотреть файл

@ -465,7 +465,7 @@ private:
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_DIAGNOSTIC_ASSERT(!IsShutdown());
mOwner->UpdateReadyState();
GetOwner()->UpdateReadyState();
}
virtual MediaDecoderOwner::NextFrameStatus NextFrameStatus() { return mNextFrameStatus; }