Bug 1339677. Part 1 - assert DoResolveOrReject() is called on the target thread and use stronger assertions.
MozReview-Commit-ID: I1wdNfjehTN
--- a/xpcom/threads/MozPromise.h
+++ b/xpcom/threads/MozPromise.h
@@ -374,32 +374,33 @@ protected:
// then shut down the thread or task queue that the promise result would
// be dispatched on. So we unfortunately can't assert that promise
// dispatch succeeds. :-(
mResponseTarget->Dispatch(runnable.forget(), AbstractThread::DontAssertDispatchSuccess);
}
void Disconnect() override
{
- MOZ_ASSERT(ThenValueBase::mResponseTarget->IsCurrentThreadIn());
+ MOZ_DIAGNOSTIC_ASSERT(ThenValueBase::mResponseTarget->IsCurrentThreadIn());
MOZ_DIAGNOSTIC_ASSERT(!Request::mComplete);
Request::mDisconnected = true;
// We could support rejecting the completion promise on disconnection, but
// then we'd need to have some sort of default reject value. The use cases
// of disconnection and completion promise chaining seem pretty orthogonal,
// so let's use assert against it.
MOZ_DIAGNOSTIC_ASSERT(!mCompletionPromise);
}
protected:
virtual already_AddRefed<MozPromise> DoResolveOrRejectInternal(const ResolveOrRejectValue& aValue) = 0;
void DoResolveOrReject(const ResolveOrRejectValue& aValue)
{
+ MOZ_DIAGNOSTIC_ASSERT(mResponseTarget->IsCurrentThreadIn());
Request::mComplete = true;
if (Request::mDisconnected) {
PROMISE_LOG("ThenValue::DoResolveOrReject disconnected - bailing out [this=%p]", this);
return;
}
// Invoke the resolve or reject method.
RefPtr<MozPromise> result = DoResolveOrRejectInternal(aValue);