Part 2 - some code cleanup. draft
authorJW Wang <jwwang@mozilla.com>
Tue, 24 Jan 2017 16:24:10 +0800
changeset 479146 3fa87e2d7d4cdfa33058dae397b92ece01444b94
parent 479145 fdc74d3f567fef454f60eed3717aef796fe6fe66
child 479147 e7a08656b5578ef62922024fa1821d9fe99b205c
child 479154 adad3ceb414d692ae3035763ca3cf950123ab8a3
child 479210 4a8586e15654b342b0736fdb232bf7cadec1fe5e
child 479212 9e5a5750efb94a1e5321d190a0add4eb90630371
push id44158
push userjwwang@mozilla.com
push dateMon, 06 Feb 2017 02:30:28 +0000
milestone54.0a1
Part 2 - some code cleanup. MozReview-Commit-ID: 5h7Mv5joGHy
xpcom/threads/MozPromise.h
--- 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,27 +354,26 @@ 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_ASSERT(mResponseTarget->IsCurrentThreadIn());
       MOZ_DIAGNOSTIC_ASSERT(!Request::mComplete);
       Request::mDisconnected = true;