Bug 1504531 - P2. Add MozPromiseHolder::ResolveOrReject methods. r=gerald

Depends on D10833

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Jean-Yves Avenard 2018-11-04 22:36:43 +00:00
parent 6f99745b62
commit 91dbdb0a68

View File

@ -1256,6 +1256,29 @@ public:
}
}
template<typename ResolveOrRejectValueType_>
void ResolveOrReject(ResolveOrRejectValueType_&& aValue,
const char* aMethodName)
{
if (mMonitor) {
mMonitor->AssertCurrentThreadOwns();
}
MOZ_ASSERT(mPromise);
mPromise->ResolveOrReject(std::forward<ResolveOrRejectValueType_>(aValue),
aMethodName);
mPromise = nullptr;
}
template<typename ResolveOrRejectValueType_>
void ResolveOrRejectIfExists(ResolveOrRejectValueType_&& aValue,
const char* aMethodName)
{
if (!IsEmpty()) {
ResolveOrReject(std::forward<ResolveOrRejectValueType_>(aValue),
aMethodName);
}
}
private:
Monitor* mMonitor;
RefPtr<typename PromiseType::Private> mPromise;