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

Unified Diff: src/api.cc

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 | « include/v8.h ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index 8269fd9fd7057765a92bb89a0e9627425b460aba..e0eaff5c0fce89ee86bdfc01e9c5e66ed3f28f88 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -2658,6 +2658,13 @@ void v8::Promise::CheckCast(Value* that) {
}
+void v8::Promise::Resolver::CheckCast(Value* that) {
+ Utils::ApiCheck(that->IsPromise(),
+ "v8::Promise::Resolver::Cast()",
+ "Could not convert to promise resolver");
+}
+
+
void v8::ArrayBuffer::CheckCast(Value* that) {
i::Handle<i::Object> obj = Utils::OpenHandle(that);
Utils::ApiCheck(obj->IsJSArrayBuffer(),
@@ -5761,9 +5768,9 @@ bool Value::IsPromise() const {
}
-Local<Promise> Promise::New(Isolate* v8_isolate) {
+Local<Promise::Resolver> Promise::Resolver::New(Isolate* v8_isolate) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
- LOG_API(isolate, "Promise::New");
+ LOG_API(isolate, "Promise::Resolver::New");
ENTER_V8(isolate);
EXCEPTION_PREAMBLE(isolate);
i::Handle<i::Object> result = i::Execution::Call(
@@ -5774,15 +5781,21 @@ Local<Promise> Promise::New(Isolate* v8_isolate) {
0, NULL,
&has_pending_exception,
false);
- EXCEPTION_BAILOUT_CHECK(isolate, Local<Promise>());
- return Local<Promise>::Cast(Utils::ToLocal(result));
+ EXCEPTION_BAILOUT_CHECK(isolate, Local<Promise::Resolver>());
+ return Local<Promise::Resolver>::Cast(Utils::ToLocal(result));
+}
+
+
+Local<Promise> Promise::Resolver::GetPromise() {
+ i::Handle<i::JSObject> promise = Utils::OpenHandle(this);
+ return Local<Promise>::Cast(Utils::ToLocal(promise));
}
-void Promise::Resolve(Handle<Value> value) {
+void Promise::Resolver::Resolve(Handle<Value> value) {
i::Handle<i::JSObject> promise = Utils::OpenHandle(this);
i::Isolate* isolate = promise->GetIsolate();
- LOG_API(isolate, "Promise::Resolve");
+ LOG_API(isolate, "Promise::Resolver::Resolve");
ENTER_V8(isolate);
EXCEPTION_PREAMBLE(isolate);
i::Handle<i::Object> argv[] = { promise, Utils::OpenHandle(*value) };
@@ -5798,10 +5811,10 @@ void Promise::Resolve(Handle<Value> value) {
}
-void Promise::Reject(Handle<Value> value) {
+void Promise::Resolver::Reject(Handle<Value> value) {
i::Handle<i::JSObject> promise = Utils::OpenHandle(this);
i::Isolate* isolate = promise->GetIsolate();
- LOG_API(isolate, "Promise::Reject");
+ LOG_API(isolate, "Promise::Resolver::Reject");
ENTER_V8(isolate);
EXCEPTION_PREAMBLE(isolate);
i::Handle<i::Object> argv[] = { promise, Utils::OpenHandle(*value) };
« no previous file with comments | « include/v8.h ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698