Commit 91e1b9f6 authored by littledan's avatar littledan Committed by Commit bot

Deprecate Promise::Chain from V8 APIs

The Promise::Chain logic is moved to a helper function to avoid
a violation of deprecated function usage.

R=rossberg,jochen
BUG=v8:3237
LOG=Y

Review URL: https://codereview.chromium.org/1477023002

Cr-Commit-Position: refs/heads/master@{#32670}
parent d67756a7
......@@ -3349,10 +3349,11 @@ class V8_EXPORT Promise : public Object {
* an argument. If the promise is already resolved/rejected, the handler is
* invoked at the end of turn.
*/
V8_DEPRECATE_SOON("Use maybe version",
V8_DEPRECATE_SOON("Use maybe version of Then",
Local<Promise> Chain(Local<Function> handler));
V8_WARN_UNUSED_RESULT MaybeLocal<Promise> Chain(Local<Context> context,
Local<Function> handler);
V8_DEPRECATE_SOON("Use Then",
V8_WARN_UNUSED_RESULT MaybeLocal<Promise> Chain(
Local<Context> context, Local<Function> handler));
V8_DEPRECATE_SOON("Use maybe version",
Local<Promise> Catch(Local<Function> handler));
......
......@@ -6461,10 +6461,12 @@ void Promise::Resolver::Reject(Local<Value> value) {
}
MaybeLocal<Promise> Promise::Chain(Local<Context> context,
Local<Function> handler) {
namespace {
MaybeLocal<Promise> DoChain(Value* value, Local<Context> context,
Local<Function> handler) {
PREPARE_FOR_EXECUTION(context, "Promise::Chain", Promise);
auto self = Utils::OpenHandle(this);
auto self = Utils::OpenHandle(value);
i::Handle<i::Object> argv[] = {Utils::OpenHandle(*handler)};
i::Handle<i::Object> result;
has_pending_exception = !i::Execution::Call(isolate, isolate->promise_chain(),
......@@ -6474,10 +6476,18 @@ MaybeLocal<Promise> Promise::Chain(Local<Context> context,
RETURN_ESCAPED(Local<Promise>::Cast(Utils::ToLocal(result)));
}
} // namespace
MaybeLocal<Promise> Promise::Chain(Local<Context> context,
Local<Function> handler) {
return DoChain(this, context, handler);
}
Local<Promise> Promise::Chain(Local<Function> handler) {
auto context = ContextFromHeapObject(Utils::OpenHandle(this));
RETURN_TO_LOCAL_UNCHECKED(Chain(context, handler), Promise);
RETURN_TO_LOCAL_UNCHECKED(DoChain(this, context, handler), Promise);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment