Bug 1339677. Part 2 - some code cleanup and remove unnecessary scope qualifiers.
MozReview-Commit-ID: 5h7Mv5joGHy
--- a/xpcom/threads/MozPromise.h
+++ b/xpcom/threads/MozPromise.h
@@ -273,21 +273,16 @@ public:
}
return holder->Promise();
}
class Request : public MozPromiseRefcountable
{
public:
virtual void Disconnect() = 0;
-
- // MSVC complains when an inner class (ThenValueBase::{Resolve,Reject}Runnable)
- // tries to access an inherited protected member.
- bool IsDisconnected() const { return mDisconnected; }
-
virtual void AssertIsDead() = 0;
protected:
Request() : mComplete(false), mDisconnected(false) {}
virtual ~Request() {}
bool mComplete;
bool mDisconnected;
@@ -359,32 +354,31 @@ protected:
}
}
void Dispatch(MozPromise *aPromise)
{
aPromise->mMutex.AssertCurrentThreadOwns();
MOZ_ASSERT(!aPromise->IsPending());
- RefPtr<Runnable> runnable =
- static_cast<Runnable*>(new (typename ThenValueBase::ResolveOrRejectRunnable)(this, aPromise));
+ nsCOMPtr<nsIRunnable> r = new ResolveOrRejectRunnable(this, aPromise);
PROMISE_LOG("%s Then() call made from %s [Runnable=%p, Promise=%p, ThenValue=%p]",
- aPromise->mValue.IsResolve() ? "Resolving" : "Rejecting", ThenValueBase::mCallSite,
- runnable.get(), aPromise, this);
+ aPromise->mValue.IsResolve() ? "Resolving" : "Rejecting", mCallSite,
+ r.get(), aPromise, this);
// Promise consumers are allowed to disconnect the Request object and
// 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);
+ mResponseTarget->Dispatch(r.forget(), AbstractThread::DontAssertDispatchSuccess);
}
void Disconnect() override
{
- MOZ_DIAGNOSTIC_ASSERT(ThenValueBase::mResponseTarget->IsCurrentThreadIn());
+ MOZ_DIAGNOSTIC_ASSERT(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);