Bug 1346498 part 4 - remove mIsVisible cannonical-mirror pair; r=jwwang

The role of MDSM::mIsVisible and MDSM::VisibilityChanged() have been replaced by
the MDSM::mVideoDecodeMode and MDSM::VideoDecodeModeChanged() completely.

MozReview-Commit-ID: 8sW0s8ilF1E

--HG--
extra : rebase_source : 20f4b0c2e5a34018b3189b4d10dd55e68881c0e7
extra : source : 2eba9a76da70749583125176e8b7c6c959b74d38
This commit is contained in:
Kaku Kuo 2017-03-11 14:06:09 +08:00
parent c2f38bd02d
commit 68c95368f5
4 changed files with 4 additions and 44 deletions

View File

@ -415,7 +415,6 @@ MediaDecoder::MediaDecoder(MediaDecoderOwner* aOwner)
, INIT_CANONICAL(mPlaybackBytesPerSecond, 0.0)
, INIT_CANONICAL(mPlaybackRateReliable, true)
, INIT_CANONICAL(mDecoderPosition, 0)
, INIT_CANONICAL(mIsVisible, !aOwner->IsHidden())
, INIT_CANONICAL(mHasSuspendTaint, false)
, mTelemetryReported(false)
, mIsMediaElement(!!aOwner->GetMediaElement())

View File

@ -811,9 +811,6 @@ protected:
// back again.
Canonical<int64_t> mDecoderPosition;
// True if the decoder is visible.
Canonical<bool> mIsVisible;
// True if the decoder has a suspend taint - meaning suspend-video-decoder is
// disabled.
Canonical<bool> mHasSuspendTaint;
@ -859,7 +856,6 @@ public:
{
return &mDecoderPosition;
}
AbstractCanonical<bool>* CanonicalIsVisible() { return &mIsVisible; }
AbstractCanonical<bool>* CanonicalHasSuspendTaint() { return &mHasSuspendTaint; }
private:

View File

@ -2171,11 +2171,12 @@ DecodingState::Enter()
{
MOZ_ASSERT(mMaster->mSentFirstFrameLoadedEvent);
if (!mMaster->mIsVisible
if (mMaster->mVideoDecodeMode == VideoDecodeMode::Suspend
&& !mMaster->mVideoDecodeSuspendTimer.IsScheduled()
&& !mMaster->mVideoDecodeSuspended) {
// If we are not visible and the timer is not schedule, it means the timer
// has timed out and we should suspend video decoding now if necessary.
// If the VideoDecodeMode is Suspend and the timer is not schedule, it means
// the timer has timed out and we should suspend video decoding now if
// necessary.
HandleVideoSuspendTimeout();
}
@ -2556,7 +2557,6 @@ ShutdownState::Enter()
master->mPlaybackBytesPerSecond.DisconnectIfConnected();
master->mPlaybackRateReliable.DisconnectIfConnected();
master->mDecoderPosition.DisconnectIfConnected();
master->mIsVisible.DisconnectIfConnected();
master->mHasSuspendTaint.DisconnectIfConnected();
master->mDuration.DisconnectAll();
@ -2625,7 +2625,6 @@ MediaDecoderStateMachine::MediaDecoderStateMachine(MediaDecoder* aDecoder,
INIT_MIRROR(mPlaybackBytesPerSecond, 0.0),
INIT_MIRROR(mPlaybackRateReliable, true),
INIT_MIRROR(mDecoderPosition, 0),
INIT_MIRROR(mIsVisible, true),
INIT_MIRROR(mHasSuspendTaint, false),
INIT_CANONICAL(mDuration, NullableTimeUnit()),
INIT_CANONICAL(mIsShutdown, false),
@ -2697,10 +2696,7 @@ MediaDecoderStateMachine::InitializationTask(MediaDecoder* aDecoder)
mWatchManager.Watch(mPlayState, &MediaDecoderStateMachine::PlayStateChanged);
if (MediaPrefs::MDSMSuspendBackgroundVideoEnabled()) {
mIsVisible.Connect(aDecoder->CanonicalIsVisible());
mHasSuspendTaint.Connect(aDecoder->CanonicalHasSuspendTaint());
mWatchManager.Watch(mIsVisible,
&MediaDecoderStateMachine::VisibilityChanged);
mWatchManager.Watch(mHasSuspendTaint,
&MediaDecoderStateMachine::SuspendTaintChanged);
}
@ -3028,34 +3024,6 @@ void MediaDecoderStateMachine::PlayStateChanged()
mStateObj->HandlePlayStateChanged(mPlayState);
}
void MediaDecoderStateMachine::VisibilityChanged()
{
MOZ_ASSERT(OnTaskQueue());
DECODER_LOG("VisibilityChanged: mIsVisible=%d, mVideoDecodeSuspended=%c",
mIsVisible.Ref(), mVideoDecodeSuspended ? 'T' : 'F');
// Start timer to trigger suspended decoding state when going invisible.
if (!mIsVisible) {
TimeStamp target = TimeStamp::Now() + SuspendBackgroundVideoDelay();
RefPtr<MediaDecoderStateMachine> self = this;
mVideoDecodeSuspendTimer.Ensure(target,
[=]() { self->OnSuspendTimerResolved(); },
[] () { MOZ_DIAGNOSTIC_ASSERT(false); });
mOnPlaybackEvent.Notify(MediaEventType::StartVideoSuspendTimer);
return;
}
// Resuming from suspended decoding
// If suspend timer exists, destroy it.
CancelSuspendTimer();
if (mVideoDecodeSuspended) {
mStateObj->HandleResumeVideoDecoding();
}
}
void MediaDecoderStateMachine::SuspendTaintChanged()
{
MOZ_ASSERT(OnTaskQueue());

View File

@ -754,9 +754,6 @@ private:
// Current decoding position in the stream.
Mirror<int64_t> mDecoderPosition;
// IsVisible, mirrored from the media decoder.
Mirror<bool> mIsVisible;
// HasSuspendTaint, mirrored from the media decoder.
Mirror<bool> mHasSuspendTaint;