Bug 1368382. P3 - remove 2 overloads of Then() using variadic template. draft
authorJW Wang <jwwang@mozilla.com>
Wed, 31 May 2017 16:10:17 +0800
changeset 587508 886e4dbe7444aa4cef2705b9ec44158d9aae2502
parent 587507 daee28588ca865f4141244edc1759657bdf83ea0
child 587509 b80d7b22f0983ef1d6fd437fea4f6430f7065c98
push id61734
push userjwwang@mozilla.com
push dateThu, 01 Jun 2017 06:57:58 +0000
bugs1368382
milestone55.0a1
Bug 1368382. P3 - remove 2 overloads of Then() using variadic template. MozReview-Commit-ID: 9KzYGnrFoQN
xpcom/threads/MozPromise.h
--- a/xpcom/threads/MozPromise.h
+++ b/xpcom/threads/MozPromise.h
@@ -879,72 +879,38 @@ protected:
     AbstractThread* mResponseThread;
     const char* mCallSite;
     RefPtr<ThenValueType> mThenValue;
     MozPromise* mReceiver;
   };
 
 public:
   template<typename ThisType,
-           typename ResolveMethodType,
-           typename RejectMethodType,
-           typename ThenValueType =
-             ThenValue<ThisType*, ResolveMethodType, RejectMethodType>,
+           typename... Methods,
+           typename ThenValueType = ThenValue<ThisType*, Methods...>,
            typename ReturnType = ThenCommand<ThenValueType>>
   ReturnType Then(AbstractThread* aResponseThread,
                   const char* aCallSite,
                   ThisType* aThisVal,
-                  ResolveMethodType aResolveMethod,
-                  RejectMethodType aRejectMethod)
+                  Methods... aMethods)
   {
-    RefPtr<ThenValueType> thenValue = new ThenValueType(
-      aResponseThread, aThisVal, aResolveMethod, aRejectMethod, aCallSite);
-    return ReturnType(aResponseThread, aCallSite, thenValue.forget(), this);
-  }
-
-  template<
-    typename ThisType,
-    typename ResolveRejectMethodType,
-    typename ThenValueType = ThenValue<ThisType*, ResolveRejectMethodType>,
-    typename ReturnType = ThenCommand<ThenValueType>>
-  ReturnType Then(AbstractThread* aResponseThread,
-                  const char* aCallSite,
-                  ThisType* aThisVal,
-                  ResolveRejectMethodType aResolveRejectMethod)
-  {
-    RefPtr<ThenValueType> thenValue = new ThenValueType(
-      aResponseThread, aThisVal, aResolveRejectMethod, aCallSite);
+    RefPtr<ThenValueType> thenValue =
+      new ThenValueType(aResponseThread, aThisVal, aMethods..., aCallSite);
     return ReturnType(aResponseThread, aCallSite, thenValue.forget(), this);
   }
 
-  template<typename ResolveFunction,
-           typename RejectFunction,
-           typename ThenValueType = ThenValue<ResolveFunction, RejectFunction>,
+  template<typename... Functions,
+           typename ThenValueType = ThenValue<Functions...>,
            typename ReturnType = ThenCommand<ThenValueType>>
   ReturnType Then(AbstractThread* aResponseThread,
                   const char* aCallSite,
-                  ResolveFunction&& aResolveFunction,
-                  RejectFunction&& aRejectFunction)
+                  Functions&&... aFunctions)
   {
-    RefPtr<ThenValueType> thenValue = new ThenValueType(aResponseThread,
-                                                        Move(aResolveFunction),
-                                                        Move(aRejectFunction),
-                                                        aCallSite);
-    return ReturnType(aResponseThread, aCallSite, thenValue.forget(), this);
-  }
-
-  template<typename ResolveRejectFunction,
-           typename ThenValueType = ThenValue<ResolveRejectFunction>,
-           typename ReturnType = ThenCommand<ThenValueType>>
-  ReturnType Then(AbstractThread* aResponseThread,
-                  const char* aCallSite,
-                  ResolveRejectFunction&& aResolveRejectFunction)
-  {
-    RefPtr<ThenValueType> thenValue = new ThenValueType(
-      aResponseThread, Move(aResolveRejectFunction), aCallSite);
+    RefPtr<ThenValueType> thenValue =
+      new ThenValueType(aResponseThread, Move(aFunctions)..., aCallSite);
     return ReturnType(aResponseThread, aCallSite, thenValue.forget(), this);
   }
 
   void ChainTo(already_AddRefed<Private> aChainedPromise, const char* aCallSite)
   {
     MutexAutoLock lock(mMutex);
     MOZ_DIAGNOSTIC_ASSERT(!IsExclusive || !mHaveRequest);
     mHaveRequest = true;