Bug 1468241 - P1. Add MozPromise::CreateAndResolveOrReject method r=gerald
authorJean-Yves Avenard <jyavenard@mozilla.com>
Wed, 20 Jun 2018 22:14:05 +0000
changeset 477470 3d039520dd5abfc686a47ec447624ee4f3072156
parent 477469 cbb4ecbebc5e997283ea5beca43322865ee6e7bd
child 477471 686fc84d4ffbe8d1bef16767fdd8c867479258a0
push id9385
push userdluca@mozilla.com
push dateFri, 22 Jun 2018 15:47:18 +0000
treeherdermozilla-beta@82a9a1027e2b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgerald
bugs1468241
milestone62.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1468241 - P1. Add MozPromise::CreateAndResolveOrReject method r=gerald Useful when using promise chaining in combination with MozPromise::ResolveOrRejectValue parameter. MozReview-Commit-ID: F8qMh7yFnHQ Differential Revision: https://phabricator.services.mozilla.com/D1726
xpcom/threads/MozPromise.h
--- a/xpcom/threads/MozPromise.h
+++ b/xpcom/threads/MozPromise.h
@@ -273,16 +273,25 @@ public:
   static RefPtr<MozPromise>
   CreateAndReject(RejectValueType_&& aRejectValue, const char* aRejectSite)
   {
     RefPtr<typename MozPromise::Private> p = new MozPromise::Private(aRejectSite);
     p->Reject(std::forward<RejectValueType_>(aRejectValue), aRejectSite);
     return p.forget();
   }
 
+  template<typename ResolveOrRejectValueType_>
+  static RefPtr<MozPromise>
+  CreateAndResolveOrReject(ResolveOrRejectValueType_&& aValue, const char* aSite)
+  {
+    RefPtr<typename MozPromise::Private> p = new MozPromise::Private(aSite);
+    p->ResolveOrReject(std::forward<ResolveOrRejectValueType_>(aValue), aSite);
+    return p.forget();
+  }
+
   typedef MozPromise<nsTArray<ResolveValueType>, RejectValueType, IsExclusive> AllPromiseType;
 private:
   class AllPromiseHolder : public MozPromiseRefcountable
   {
   public:
     explicit AllPromiseHolder(size_t aDependentPromises)
       : mPromise(new typename AllPromiseType::Private(__func__))
       , mOutstandingPromises(aDependentPromises)