Bug 1345711 - Ensure MediaDecoderStateMachine::InitializationTask() is the first task to run on the task queue. r=kaku

MozReview-Commit-ID: KCtXmckLkZr

--HG--
extra : rebase_source : 10e36d96f795084f2d9803e08092b7cfad034f35
extra : intermediate-source : 64bef3af2e55f579250c500c1760ea8c36caccb8
extra : source : b37cc5f40ac90d0c0d63ab4915238982033e5ca4
This commit is contained in:
JW Wang 2017-03-08 20:44:43 +08:00
Родитель 984929ffe1
Коммит 291e7ca6b4
1 изменённых файлов: 6 добавлений и 9 удалений

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

@ -2682,6 +2682,11 @@ MediaDecoderStateMachine::InitializationTask(MediaDecoder* aDecoder)
mWatchManager.Watch(mIsVisible,
&MediaDecoderStateMachine::VisibilityChanged);
}
MOZ_ASSERT(!mStateObj);
auto* s = new DecodeMetadataState(this);
mStateObj.reset(s);
s->Enter();
}
void
@ -2817,7 +2822,7 @@ nsresult MediaDecoderStateMachine::Init(MediaDecoder* aDecoder)
// Dispatch initialization that needs to happen on that task queue.
nsCOMPtr<nsIRunnable> r = NewRunnableMethod<RefPtr<MediaDecoder>>(
this, &MediaDecoderStateMachine::InitializationTask, aDecoder);
mTaskQueue->Dispatch(r.forget());
mTaskQueue->DispatchStateChange(r.forget());
mAudioQueueListener = AudioQueue().PopEvent().Connect(
mTaskQueue, this, &MediaDecoderStateMachine::OnAudioPopped);
@ -2840,14 +2845,6 @@ nsresult MediaDecoderStateMachine::Init(MediaDecoder* aDecoder)
nsresult rv = mReader->Init();
NS_ENSURE_SUCCESS(rv, rv);
RefPtr<MediaDecoderStateMachine> self = this;
OwnerThread()->Dispatch(NS_NewRunnableFunction([self] () {
MOZ_ASSERT(!self->mStateObj);
auto s = new DecodeMetadataState(self);
self->mStateObj.reset(s);
s->Enter();
}));
return NS_OK;
}