Bug 1333280 - Make ThenValueBase::mCompletionPromise a MozPromise::Private. r=gerald

MozReview-Commit-ID: E046bQoQN1

--HG--
extra : rebase_source : e8563000ac0ab452d703dd6e67878e8605f7acc9
extra : intermediate-source : 514e9122a222fba252f47673fbe3cf842c322790
extra : source : 7f2bf86df00cc33737da5a2aaa8052cc60c5d8cf
This commit is contained in:
JW Wang 2017-01-23 17:47:27 +08:00
Родитель df8974cb62
Коммит d7ec453920
1 изменённых файлов: 7 добавлений и 19 удалений

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

@ -402,33 +402,21 @@ protected:
}
// Invoke the resolve or reject method.
RefPtr<MozPromise> p = DoResolveOrRejectInternal(aValue);
RefPtr<MozPromise> result = DoResolveOrRejectInternal(aValue);
// If there's a completion promise, resolve it appropriately with the
// result of the method.
//
// We jump through some hoops to cast to MozPromise::Private here. This
// can go away when we can just declare mCompletionPromise as
// MozPromise::Private. See the declaration below.
RefPtr<MozPromise::Private> completionPromise =
dont_AddRef(static_cast<MozPromise::Private*>(mCompletionPromise.forget().take()));
if (completionPromise) {
if (p) {
p->ChainTo(completionPromise.forget(), "<chained completion promise>");
if (RefPtr<Private> p = mCompletionPromise.forget()) {
if (result) {
result->ChainTo(p.forget(), "<chained completion promise>");
} else {
completionPromise->ResolveOrReject(aValue, "<completion of non-promise-returning method>");
p->ResolveOrReject(aValue, "<completion of non-promise-returning method>");
}
}
}
RefPtr<AbstractThread> mResponseTarget; // May be released on any thread.
// Declaring RefPtr<MozPromise::Private> here causes build failures
// on MSVC because MozPromise::Private is only forward-declared at this
// point. This hack can go away when we inline-declare MozPromise::Private,
// which is blocked on the B2G ICS compiler being too old.
RefPtr<MozPromise> mCompletionPromise;
RefPtr<Private> mCompletionPromise;
const char* mCallSite;
};
@ -732,7 +720,7 @@ private:
{
RefPtr<ThenValueBase> thenValue = mThenValue.forget();
// mCompletionPromise must be created before ThenInternal() to avoid race.
RefPtr<MozPromise> p = new MozPromise::Private(
RefPtr<MozPromise::Private> p = new MozPromise::Private(
"<completion promise>", true /* aIsCompletionPromise */);
thenValue->mCompletionPromise = p;
// Note ThenInternal() might nullify mCompletionPromise before return.