Chromium Code Reviews| Index: Source/bindings/core/v8/V8BindingMacros.h |
| diff --git a/Source/bindings/core/v8/V8BindingMacros.h b/Source/bindings/core/v8/V8BindingMacros.h |
| index 165d5b7b0144f1c7756a018f4110c2bc2a598063..16e6ba8a328d777e2506b9cf73987f6fdc287efd 100644 |
| --- a/Source/bindings/core/v8/V8BindingMacros.h |
| +++ b/Source/bindings/core/v8/V8BindingMacros.h |
| @@ -70,6 +70,24 @@ namespace blink { |
| } \ |
| } |
| +// We need to cancel the exception propergation when we return a rejected Promise. |
| +#define TONATIVE_VOID_ASYNC_INTERNAL(var, value, info) \ |
|
haraken
2014/08/01 17:04:24
Given that this logic is specific to Promise, shal
yhirano
2014/08/04 01:42:08
Done.
|
| + var = (value); \ |
| + if (UNLIKELY(block.HasCaught())) { \ |
| + v8SetReturnValue(info, ScriptPromise::rejectRaw(info.GetIsolate(), block.Exception())); \ |
| + rethrow.cancel(); \ |
| + return; \ |
| + } |
| + |
| +#define TONATIVE_VOID_ASYNC(type, var, value, info) \ |
| + type var; \ |
| + { \ |
| + v8::TryCatch block; \ |
| + V8RethrowTryCatchScope rethrow(block); \ |
| + TONATIVE_VOID_ASYNC_INTERNAL(var, value, info); \ |
| + } |
| + |
| + |
| #define TONATIVE_VOID_EXCEPTIONSTATE_INTERNAL(var, value, exceptionState) \ |
| var = (value); \ |
| if (UNLIKELY(block.HasCaught() || exceptionState.throwIfNeeded())) \ |
| @@ -93,6 +111,27 @@ namespace blink { |
| return retVal; \ |
| } |
| +// We need to cancel the exception propergation when we return a rejected Promise. |
| +#define TONATIVE_VOID_EXCEPTIONSTATE_ASYNC_INTERNAL(var, value, exceptionState, info, scriptState) \ |
| + var = (value); \ |
| + if (UNLIKELY(block.HasCaught())) { \ |
| + v8SetReturnValue(info, ScriptPromise::rejectRaw(info.GetIsolate(), block.Exception())); \ |
| + rethrow.cancel(); \ |
| + return; \ |
| + } \ |
| + if (UNLIKELY(exceptionState.hadException())) { \ |
| + v8SetReturnValue(info, exceptionState.reject(scriptState).v8Value()); \ |
| + return; \ |
| + } |
| + |
| +#define TONATIVE_VOID_EXCEPTIONSTATE_ASYNC(type, var, value, exceptionState, info, scriptState) \ |
| + type var; \ |
| + { \ |
| + v8::TryCatch block; \ |
| + V8RethrowTryCatchScope rethrow(block); \ |
| + TONATIVE_VOID_EXCEPTIONSTATE_ASYNC_INTERNAL(var, value, exceptionState, info, scriptState); \ |
| + } |
| + |
| // type is an instance of class template V8StringResource<>, |
| // but Mode argument varies; using type (not Mode) for consistency |
| // with other macros and ease of code generation |
| @@ -111,6 +150,23 @@ namespace blink { |
| if (UNLIKELY(!var.prepare())) \ |
| return retVal; |
| +// We need to cancel the exception propergation when we return a rejected Promise. |
| +#define TOSTRING_VOID_ASYNC_INTERNAL(var, value, info) \ |
| + var = (value); \ |
| + if (UNLIKELY(!var.prepare())) { \ |
| + info.GetReturnValue().Set(ScriptPromise::rejectRaw(info.GetIsolate(), block.Exception())); \ |
| + rethrow.cancel(); \ |
| + return; \ |
| + } |
| + |
| +#define TOSTRING_VOID_ASYNC(type, var, value, info) \ |
| + type var; \ |
| + { \ |
| + v8::TryCatch block; \ |
| + V8RethrowTryCatchScope rethrow(block); \ |
| + TOSTRING_VOID_ASYNC_INTERNAL(type, var, value, info); \ |
| + } |
| + |
| } // namespace blink |
| #endif // V8BindingMacros_h |