Bug 1276272 part 1 - add Promise::MaybeRejectWithVode() utility method; r?ehsan draft
authorKaku Kuo <tkuo@mozilla.com>
Sun, 05 Jun 2016 22:16:12 +0800
changeset 375491 3f53f469c2533f8c80fd1c5e5915700ff206a6a9
parent 375369 3e8ee3599a67edd971770af4982ad4b0fe77f073
child 375492 04473367211c18c5ab42618183a6433b4e35a52c
push id20281
push usertkuo@mozilla.com
push dateSun, 05 Jun 2016 16:03:37 +0000
reviewersehsan
bugs1276272
milestone49.0a1
Bug 1276272 part 1 - add Promise::MaybeRejectWithVode() utility method; r?ehsan MozReview-Commit-ID: 4bBGsUNKbQS
dom/promise/Promise.cpp
dom/promise/Promise.h
--- a/dom/promise/Promise.cpp
+++ b/dom/promise/Promise.cpp
@@ -935,16 +935,24 @@ Promise::MaybeReject(const RefPtr<MediaS
 void
 Promise::MaybeRejectWithNull()
 {
   NS_ASSERT_OWNINGTHREAD(Promise);
 
   MaybeSomething(JS::NullHandleValue, &Promise::MaybeReject);
 }
 
+void
+Promise::MaybeRejectWithVoid()
+{
+  NS_ASSERT_OWNINGTHREAD(Promise);
+
+  MaybeSomething(JS::UndefinedHandleValue, &Promise::MaybeReject);
+}
+
 bool
 Promise::PerformMicroTaskCheckpoint()
 {
   MOZ_ASSERT(NS_IsMainThread(), "Wrong thread!");
 
   CycleCollectedJSRuntime* runtime = CycleCollectedJSRuntime::Get();
 
   // On the main thread, we always use the main promise micro task queue.
--- a/dom/promise/Promise.h
+++ b/dom/promise/Promise.h
@@ -145,16 +145,18 @@ public:
     MOZ_ASSERT(aArg.Failed());
     MaybeSomething(aArg, &Promise::MaybeReject);
   }
 
   void MaybeReject(const RefPtr<MediaStreamError>& aArg);
 
   void MaybeRejectWithNull();
 
+  void MaybeRejectWithVoid();
+
   // DO NOT USE MaybeRejectBrokenly with in new code.  Promises should be
   // rejected with Error instances.
   // Note: MaybeRejectBrokenly is a template so we can use it with DOMError
   // without instantiating the DOMError specialization of MaybeSomething in
   // every translation unit that includes this header, because that would
   // require use to include DOMError.h either here or in all those translation
   // units.
   template<typename T>