Bug 1328130. Part 3 - remove unused functions and fix comments. draft
authorJW Wang <jwwang@mozilla.com>
Wed, 11 Jan 2017 23:52:24 +0800
changeset 460532 27d73e7fdfb66dbfef6847999737199ec23eca3a
parent 460531 b70a8842085baa6c0a67774f88ba116dcc02ba8f
child 460622 b3e90ea3ad55ccd19150adf48d2b2319b45ad57b
push id41407
push userjwwang@mozilla.com
push dateFri, 13 Jan 2017 06:45:41 +0000
bugs1328130
milestone53.0a1
Bug 1328130. Part 3 - remove unused functions and fix comments. MozReview-Commit-ID: JURmHasmhOU
xpcom/threads/MozPromise.h
--- a/xpcom/threads/MozPromise.h
+++ b/xpcom/threads/MozPromise.h
@@ -690,19 +690,18 @@ public:
       mThenValues.AppendElement(aThenValue);
     }
   }
 
 private:
   /*
    * A command object to store all information needed to make a request to
    * the promise. This allows us to delay the request until further use is
-   * known (whether it is ->Then() again for more promise chaining or passed
-   * to MozPromiseRequestHolder::Begin() to terminate chaining and issue
-   * the request).
+   * known (whether it is ->Then() again for more promise chaining or ->Track()
+   * to terminate chaining and issue the request).
    *
    * This allows a unified syntax for promise chaining and disconnection
    * and feels more like its JS counterpart.
    */
   class ThenCommand
   {
     friend class MozPromise;
 
@@ -721,24 +720,16 @@ private:
     ~ThenCommand()
     {
       // Issue the request now if the return value of Then() is not used.
       if (mThenValue) {
         mReceiver->ThenInternal(mResponseThread, mThenValue, mCallSite);
       }
     }
 
-    // Allow passing Then() to MozPromiseRequestHolder::Begin().
-    operator RefPtr<Request>()
-    {
-      RefPtr<ThenValueBase> thenValue = mThenValue.forget();
-      mReceiver->ThenInternal(mResponseThread, thenValue, mCallSite);
-      return thenValue.forget();
-    }
-
     // Allow RefPtr<MozPromise> p = somePromise->Then();
     //       p->Then(thread1, ...);
     //       p->Then(thread2, ...);
     operator RefPtr<MozPromise>()
     {
       RefPtr<ThenValueBase> thenValue = mThenValue.forget();
       // mCompletionPromise must be created before ThenInternal() to avoid race.
       RefPtr<MozPromise> p = new MozPromise::Private(
@@ -754,17 +745,19 @@ private:
     auto Then(Ts&&... aArgs)
       -> decltype(DeclVal<MozPromise>().Then(Forward<Ts>(aArgs)...))
     {
       return static_cast<RefPtr<MozPromise>>(*this)->Then(Forward<Ts>(aArgs)...);
     }
 
     void Track(MozPromiseRequestHolder<MozPromise>& aRequestHolder)
     {
-      aRequestHolder.Track(*this);
+      RefPtr<ThenValueBase> thenValue = mThenValue.forget();
+      mReceiver->ThenInternal(mResponseThread, thenValue, mCallSite);
+      aRequestHolder.Track(thenValue.forget());
     }
 
     // Allow calling ->Then() again for more promise chaining or ->Track() to
     // end chaining and track the request for future disconnection.
     ThenCommand* operator->()
     {
       return this;
     }