Bug 1322801 part 4 - defer the logic of invoking seek operation to SeekingObject's subclasses; r=jwwang

MozReview-Commit-ID: JjugShNlLV

--HG--
extra : rebase_source : f06d968e01916753d2fc803734e1e2c53680064d
This commit is contained in:
Kaku Kuo 2016-11-29 18:37:27 +08:00
Родитель db4795578c
Коммит e34f6551e4
1 изменённых файлов: 30 добавлений и 15 удалений

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

@ -791,15 +791,7 @@ public:
ResetMDSM();
// Do the seek.
mSeekTaskRequest.Begin(mSeekTask->Seek(mMaster->Duration())
->Then(OwnerThread(), __func__,
[this] (const SeekTaskResolveValue& aValue) {
OnSeekTaskResolved(aValue);
},
[this] (const SeekTaskRejectValue& aValue) {
OnSeekTaskRejected(aValue);
}));
DoSeek();
return mSeekJob.mPromise.Ensure(__func__);
}
@ -860,8 +852,10 @@ public:
protected:
SeekJob mSeekJob;
RefPtr<SeekTask> mSeekTask;
MozPromiseRequestHolder<SeekTask::SeekTaskPromise> mSeekTaskRequest;
void SeekCompleted();
private:
void OnSeekTaskResolved(const SeekTaskResolveValue& aValue)
{
mSeekTaskRequest.Complete();
@ -904,13 +898,12 @@ private:
mMaster->DecodeError(aValue.mError);
}
void SeekCompleted();
private:
virtual void CreateSeekTask() = 0;
virtual void ResetMDSM() = 0;
MozPromiseRequestHolder<SeekTask::SeekTaskPromise> mSeekTaskRequest;
virtual void DoSeek() = 0;
};
class MediaDecoderStateMachine::AccurateSeekingState
@ -944,6 +937,18 @@ private:
mMaster->Reset();
}
}
void DoSeek() override
{
mSeekTaskRequest.Begin(mSeekTask->Seek(mMaster->Duration())
->Then(OwnerThread(), __func__,
[this] (const SeekTaskResolveValue& aValue) {
OnSeekTaskResolved(aValue);
},
[this] (const SeekTaskRejectValue& aValue) {
OnSeekTaskRejected(aValue);
}));
}
};
class MediaDecoderStateMachine::NextFrameSeekingState
@ -974,10 +979,20 @@ private:
{
// Do nothing.
}
void DoSeek() override
{
mSeekTaskRequest.Begin(mSeekTask->Seek(mMaster->Duration())
->Then(OwnerThread(), __func__,
[this] (const SeekTaskResolveValue& aValue) {
OnSeekTaskResolved(aValue);
},
[this] (const SeekTaskRejectValue& aValue) {
OnSeekTaskRejected(aValue);
}));
}
};
/**
* Purpose: stop playback until enough data is decoded to continue playback.
*