Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(429)

Unified Diff: Source/bindings/v8/custom/V8PromiseCustom.h

Issue 17993004: Implement PromiseResolver.prototype.{fulfill, reject} (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Source/bindings/v8/custom/V8PromiseCustom.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « no previous file | Source/bindings/v8/custom/V8PromiseCustom.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698