Index: Source/bindings/v8/custom/V8PromiseCustom.h |
diff --git a/Source/bindings/v8/custom/V8PromiseCustom.h b/Source/bindings/v8/custom/V8PromiseCustom.h |
index 47b64a45ee42e9367b979e579008b06193acb5ec..fd55cace4220f8ba37b7dbbeefffd56a69487358 100644 |
--- a/Source/bindings/v8/custom/V8PromiseCustom.h |
+++ b/Source/bindings/v8/custom/V8PromiseCustom.h |
@@ -39,11 +39,54 @@ public: |
InternalFieldCount, // This entry must always be at the bottom. |
}; |
- enum PromiseStatus { |
+ enum PromiseState { |
Pending, |
Fulfilled, |
Rejected, |
}; |
+ |
+ enum SynchronousMode { |
+ Synchronous, |
+ Asynchronous, |
+ }; |
+ |
+ // Create Promise and PromiseResolver instances and set them to |promise| and |resolver| respectively. |
+ static void createPromise(v8::Handle<v8::Object> creationContext, v8::Local<v8::Object>* promise, v8::Local<v8::Object>* resolver, v8::Isolate*); |
+ |
+ // |resolver| must be a PromiseResolver instance. |
+ static void fulfillResolver(v8::Handle<v8::Object> resolver, v8::Handle<v8::Value> result, SynchronousMode, v8::Isolate*); |
+ // |resolver| must be a PromiseResolver instance. |
+ static void rejectResolver(v8::Handle<v8::Object> resolver, v8::Handle<v8::Value> result, SynchronousMode, v8::Isolate*); |
+ |
+ // |promise| must be a Promise instance. |
+ // |fulfillCallback| and |rejectCallback| can be an empty function respectively. |
+ static void append(v8::Handle<v8::Object> promise, v8::Handle<v8::Function> fulfillCallback, v8::Handle<v8::Function> rejectCallback, v8::Isolate*); |
+ |
+ // This function can take either Promise or PromiseResolver objects. |
+ // This function cannot be called when the internal object is detached from |promiseOrResolver|. |
+ // Note that internal object can be detached only from PromiseResolver. |
+ static v8::Local<v8::Object> getInternal(v8::Handle<v8::Object> promiseOrResolver); |
+ |
+ // Return true if the internal object is detached from |resolver|. |
+ // |resolver| must be a PromiseResolver instance. |
+ static bool isInternalDetached(v8::Handle<v8::Object> resolver); |
+ |
+ // Detach the internal object from |resolver|. |
+ // |resolver| must be a PromiseResolver instance. |
+ static void detachInternal(v8::Handle<v8::Object> resolver, v8::Isolate*); |
+ |
+ // Clear the Promise / PromiseResolver internal object with the given state and result. |
+ // This function clears callbacks in the object. |
+ static void clearInternal(v8::Handle<v8::Object> internal, PromiseState, v8::Handle<v8::Value> result); |
+ |
+ // |internal| must be an Promise / PromiseResolver internal object. |
+ static PromiseState getState(v8::Handle<v8::Object> internal); |
+ // |internal| must be an Promise / PromiseResolver internal object. |
+ static void setState(v8::Handle<v8::Object> internal, PromiseState); |
+ |
+ // Call |function| synchronously or asynchronously, depending on |mode|. |
+ // If |function| throws an exception, this function catches it and does not rethrow. |
+ static void call(v8::Handle<v8::Function> /* function */, v8::Handle<v8::Object> receiver, v8::Handle<v8::Value> result, SynchronousMode /* mode */, v8::Isolate*); |
}; |
} // namespace WebCore |