Chromium Code Reviews| 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..ab32f839caafc7c8b0a365089eea0e0c3416568b 100644 |
| --- a/Source/bindings/v8/custom/V8PromiseCustom.h |
| +++ b/Source/bindings/v8/custom/V8PromiseCustom.h |
| @@ -39,11 +39,55 @@ public: |
| InternalFieldCount, // This entry must always be at the bottom. |
| }; |
| - enum PromiseStatus { |
| + enum WrapperCallbackEnvironmentFieldIndex { |
| + WrapperCallbackEnvironmentPromiseIndex, |
| + WrapperCallbackEnvironmentPromiseResolverIndex, |
| + WrapperCallbackEnvironmentCallbackIndex, |
| + WrapperCallbackEnvironmentFieldCount, // This entry must always be at the bottom. |
| + }; |
| + |
| + enum PromiseAlgorithm { |
| + FulfillAlgorithm, |
| + ResolveAlgorithm, |
| + RejectAlgorithm, |
| + }; |
| + |
| + enum PromiseState { |
| Pending, |
| Fulfilled, |
| Rejected, |
| }; |
| + |
| + // 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, bool synchronous, v8::Isolate*); |
|
abarth-chromium
2013/06/27 03:25:16
Should we use an enum rather than a bool for |sync
yhirano
2013/06/27 05:40:34
Done.
|
| + // |resolver| must be a PromiseResolver instance. |
| + static void resolveResolver(v8::Handle<v8::Object> resolver, v8::Handle<v8::Value> result, bool synchronous, v8::Isolate*); |
| + // |resolver| must be a PromiseResolver instance. |
| + static void rejectResolver(v8::Handle<v8::Object> resolver, v8::Handle<v8::Value> result, bool synchronous, 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. |
| + // If the internal object of a PromiseResolver was set to null, this function returns an empty object. |
| + static v8::Local<v8::Object> getInternal(v8::Handle<v8::Object> promiseOrPromiseResolver); |
| + |
| + // 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 |synchronous|. |
| + // 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, bool synchronous, v8::Isolate*); |
| }; |
| } // namespace WebCore |