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

Unified Diff: include/v8.h

Issue 196943014: Split Promise API into Promise/Resolver (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 9 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 | src/api.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/v8.h
diff --git a/include/v8.h b/include/v8.h
index 9bda3dc9faa7bfa79190c1483345d93057120349..ca0d5c0d51c2aefb2215ac76a1ea03867684e705 100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -2697,17 +2697,31 @@ class V8_EXPORT Function : public Object {
*/
class V8_EXPORT Promise : public Object {
public:
- /**
- * Create a new Promise in pending state.
- */
- static Local<Promise> New(Isolate* isolate);
+ class V8_EXPORT Resolver : public Object {
+ public:
+ /**
+ * Create a new resolver, along with an associated promise in pending state.
+ */
+ static Local<Resolver> New(Isolate* isolate);
- /**
- * Resolve/reject a promise with a given value.
- * Ignored if the promise is not unresolved.
- */
- void Resolve(Handle<Value> value);
- void Reject(Handle<Value> value);
+ /**
+ * Extract the associated promise.
+ */
+ Local<Promise> GetPromise();
+
+ /**
+ * Resolve/reject the associated promise with a given value.
+ * Ignored if the promise is no longer pending.
+ */
+ void Resolve(Handle<Value> value);
+ void Reject(Handle<Value> value);
+
+ V8_INLINE static Resolver* Cast(Value* obj);
+
+ private:
+ Resolver();
+ static void CheckCast(Value* obj);
+ };
/**
* Register a resolution/rejection handler with a promise.
@@ -6429,6 +6443,14 @@ Promise* Promise::Cast(v8::Value* value) {
}
+Promise::Resolver* Promise::Resolver::Cast(v8::Value* value) {
+#ifdef V8_ENABLE_CHECKS
+ CheckCast(value);
+#endif
+ return static_cast<Promise::Resolver*>(value);
+}
+
+
ArrayBuffer* ArrayBuffer::Cast(v8::Value* value) {
#ifdef V8_ENABLE_CHECKS
CheckCast(value);
« no previous file with comments | « no previous file | src/api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698