Bug 1309142. Part 2 - add StateObject::HandleShutdown(). r=JamesCheng

MozReview-Commit-ID: 64VPA1fxLzF

--HG--
extra : rebase_source : 271d75f4766dda88b2da68db6061cafda1e76295
extra : source : 3f62381eb06918fb2e591c245e96c519967cc59b
This commit is contained in:
JW Wang 2016-10-11 16:20:23 +08:00
Родитель 93a211fec5
Коммит 6c6fc5896a
1 изменённых файлов: 23 добавлений и 10 удалений

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

@ -214,6 +214,8 @@ public:
virtual bool HandleAudioCaptured() { return false; } virtual bool HandleAudioCaptured() { return false; }
virtual RefPtr<ShutdownPromise> HandleShutdown();
virtual void DumpDebugInfo() {} virtual void DumpDebugInfo() {}
protected: protected:
@ -885,6 +887,12 @@ public:
MOZ_DIAGNOSTIC_ASSERT(false, "Can't seek in shutdown state."); MOZ_DIAGNOSTIC_ASSERT(false, "Can't seek in shutdown state.");
return MediaDecoder::SeekPromise::CreateAndReject(true, __func__); return MediaDecoder::SeekPromise::CreateAndReject(true, __func__);
} }
RefPtr<ShutdownPromise> HandleShutdown() override
{
MOZ_DIAGNOSTIC_ASSERT(false, "Already shutting down.");
return nullptr;
}
}; };
bool bool
@ -906,6 +914,20 @@ StateObject::HandleDormant(bool aDormant)
return true; return true;
} }
RefPtr<ShutdownPromise>
MediaDecoderStateMachine::
StateObject::HandleShutdown()
{
auto master = mMaster;
SetState<ShutdownState>();
return master->mReader->Shutdown()
->Then(master->OwnerThread(), __func__, master,
&MediaDecoderStateMachine::FinishShutdown,
&MediaDecoderStateMachine::FinishShutdown)
->CompletionPromise();
}
void void
MediaDecoderStateMachine:: MediaDecoderStateMachine::
DecodeMetadataState::OnMetadataRead(MetadataHolder* aMetadata) DecodeMetadataState::OnMetadataRead(MetadataHolder* aMetadata)
@ -2144,16 +2166,7 @@ RefPtr<ShutdownPromise>
MediaDecoderStateMachine::Shutdown() MediaDecoderStateMachine::Shutdown()
{ {
MOZ_ASSERT(OnTaskQueue()); MOZ_ASSERT(OnTaskQueue());
return mStateObj->HandleShutdown();
mStateObj->SetState<ShutdownState>();
// Put a task in the decode queue to shutdown the reader.
// the queue to spin down.
return mReader->Shutdown()
->Then(OwnerThread(), __func__, this,
&MediaDecoderStateMachine::FinishShutdown,
&MediaDecoderStateMachine::FinishShutdown)
->CompletionPromise();
} }
void MediaDecoderStateMachine::PlayStateChanged() void MediaDecoderStateMachine::PlayStateChanged()