Bug 1522773 - Reject any outstanding DOMMediaStream::TrackPort::BlockSourceTrackId() promise on teardown to avoid recent debug assert permafail. r=bwc

Differential Revision: https://phabricator.services.mozilla.com/D18590

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Jan-Ivar Bruaroey 2019-02-05 20:59:52 +00:00
Родитель 3d0a38d817
Коммит a35b931962
1 изменённых файлов: 21 добавлений и 6 удалений

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

@ -3062,12 +3062,27 @@ RefPtr<GenericPromise> MediaInputPort::BlockSourceTrackId(
MozPromiseHolder<GenericPromise> holder;
RefPtr<GenericPromise> p = holder.Ensure(__func__);
nsCOMPtr<nsIRunnable> runnable =
NewRunnableFrom([h = std::move(holder)]() mutable {
class HolderRunnable : public Runnable {
public:
explicit HolderRunnable(MozPromiseHolder<GenericPromise>&& aHolder)
: Runnable("MediaInputPort::HolderRunnable"),
mHolder(std::move(aHolder)) {}
NS_IMETHOD Run() override {
MOZ_ASSERT(NS_IsMainThread());
h.Resolve(true, __func__);
mHolder.Resolve(true, __func__);
return NS_OK;
});
}
private:
~HolderRunnable() {
mHolder.RejectIfExists(NS_ERROR_DOM_MEDIA_CANCELED, __func__);
}
MozPromiseHolder<GenericPromise> mHolder;
};
auto runnable = MakeRefPtr<HolderRunnable>(std::move(holder));
GraphImpl()->AppendMessage(
MakeUnique<Message>(this, aTrackId, aBlockingMode, runnable.forget()));
return p;