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

Side by Side Diff: src/api.cc

Issue 314553002: Add v8::Promise::Then. (Closed) Base URL: https://chromium.googlesource.com/external/v8.git@master
Patch Set: Created 6 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 unified diff | Download patch
« no previous file with comments | « include/v8.h ('k') | src/bootstrapper.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "api.h" 5 #include "api.h"
6 6
7 #include <string.h> // For memcpy, strlen. 7 #include <string.h> // For memcpy, strlen.
8 #ifdef V8_USE_ADDRESS_SANITIZER 8 #ifdef V8_USE_ADDRESS_SANITIZER
9 #include <sanitizer/asan_interface.h> 9 #include <sanitizer/asan_interface.h>
10 #endif // V8_USE_ADDRESS_SANITIZER 10 #endif // V8_USE_ADDRESS_SANITIZER
(...skipping 5892 matching lines...) Expand 10 before | Expand all | Expand 10 after
5903 handle(isolate->context()->global_object()->native_context()-> 5903 handle(isolate->context()->global_object()->native_context()->
5904 promise_catch()), 5904 promise_catch()),
5905 promise, 5905 promise,
5906 ARRAY_SIZE(argv), argv, 5906 ARRAY_SIZE(argv), argv,
5907 false).ToHandle(&result); 5907 false).ToHandle(&result);
5908 EXCEPTION_BAILOUT_CHECK(isolate, Local<Promise>()); 5908 EXCEPTION_BAILOUT_CHECK(isolate, Local<Promise>());
5909 return Local<Promise>::Cast(Utils::ToLocal(result)); 5909 return Local<Promise>::Cast(Utils::ToLocal(result));
5910 } 5910 }
5911 5911
5912 5912
5913 Local<Promise> Promise::Then(Handle<Function> handler) {
5914 i::Handle<i::JSObject> promise = Utils::OpenHandle(this);
5915 i::Isolate* isolate = promise->GetIsolate();
5916 LOG_API(isolate, "Promise::Then");
5917 ENTER_V8(isolate);
5918 EXCEPTION_PREAMBLE(isolate);
5919 i::Handle<i::Object> argv[] = { Utils::OpenHandle(*handler) };
5920 i::Handle<i::Object> result;
5921 has_pending_exception = !i::Execution::Call(
5922 isolate,
5923 handle(isolate->context()->global_object()->native_context()->
5924 promise_then()),
5925 promise,
5926 ARRAY_SIZE(argv), argv,
5927 false).ToHandle(&result);
5928 EXCEPTION_BAILOUT_CHECK(isolate, Local<Promise>());
5929 return Local<Promise>::Cast(Utils::ToLocal(result));
5930 }
5931
5932
5913 bool v8::ArrayBuffer::IsExternal() const { 5933 bool v8::ArrayBuffer::IsExternal() const {
5914 return Utils::OpenHandle(this)->is_external(); 5934 return Utils::OpenHandle(this)->is_external();
5915 } 5935 }
5916 5936
5917 5937
5918 v8::ArrayBuffer::Contents v8::ArrayBuffer::Externalize() { 5938 v8::ArrayBuffer::Contents v8::ArrayBuffer::Externalize() {
5919 i::Handle<i::JSArrayBuffer> obj = Utils::OpenHandle(this); 5939 i::Handle<i::JSArrayBuffer> obj = Utils::OpenHandle(this);
5920 Utils::ApiCheck(!obj->is_external(), 5940 Utils::ApiCheck(!obj->is_external(),
5921 "v8::ArrayBuffer::Externalize", 5941 "v8::ArrayBuffer::Externalize",
5922 "ArrayBuffer already externalized"); 5942 "ArrayBuffer already externalized");
(...skipping 1643 matching lines...) Expand 10 before | Expand all | Expand 10 after
7566 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 7586 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
7567 Address callback_address = 7587 Address callback_address =
7568 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 7588 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
7569 VMState<EXTERNAL> state(isolate); 7589 VMState<EXTERNAL> state(isolate);
7570 ExternalCallbackScope call_scope(isolate, callback_address); 7590 ExternalCallbackScope call_scope(isolate, callback_address);
7571 callback(info); 7591 callback(info);
7572 } 7592 }
7573 7593
7574 7594
7575 } } // namespace v8::internal 7595 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « include/v8.h ('k') | src/bootstrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698