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

Side by Side Diff: Source/bindings/v8/V8BindingMacros.h

Issue 232563003: API functions returning Promises should not throw exceptions. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 8 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 type var; \ 79 type var; \
80 { \ 80 { \
81 v8::TryCatch block; \ 81 v8::TryCatch block; \
82 var = (value); \ 82 var = (value); \
83 if (UNLIKELY(block.HasCaught())) \ 83 if (UNLIKELY(block.HasCaught())) \
84 exceptionState.rethrowV8Exception(block.Exception()); \ 84 exceptionState.rethrowV8Exception(block.Exception()); \
85 if (UNLIKELY(exceptionState.throwIfNeeded())) \ 85 if (UNLIKELY(exceptionState.throwIfNeeded())) \
86 return; \ 86 return; \
87 } 87 }
88 88
89 #define V8TRYCATCH_VOID_PROMISE(type, var, value, info) \
90 type var; \
91 { \
92 v8::TryCatch block; \
93 var = (value); \
94 if (UNLIKELY(block.HasCaught())) { \
95 v8::Isolate* isolate = info.GetIsolate(); \
96 ScriptPromise promise = ScriptPromise::reject(block.Exception(), iso late); \
97 v8SetReturnValue(info, promise.v8Value()); \
98 return; \
99 } \
100 }
101
102 #define V8TRYCATCH_EXCEPTION_VOID_PROMISE(type, var, value, info, exceptionState ) \
haraken 2014/04/10 12:09:17 The macro names in this file are getting broken...
Nils Barth (inactive) 2014/04/11 01:03:41 I'll grab this. My suggestion: V8TRYCATCH[_TYPE][
Nils Barth (inactive) 2014/04/11 02:19:38 Posted: Rename V8TRYCATCH_* macros in v8/V8Binding
yhirano 2014/04/11 10:19:04 Done.
103 type var; \
104 { \
105 v8::TryCatch block; \
106 var = (value); \
107 v8::Isolate* isolate = info.GetIsolate(); \
108 if (UNLIKELY(block.HasCaught())) \
109 exceptionState.rethrowV8Exception(block.Exception()); \
110 if (UNLIKELY(exceptionState.hadException())) { \
haraken 2014/04/10 12:09:17 Shouldn't this be exceptionState.throwIfNeeded()?
yhirano 2014/04/11 10:19:04 What I want to do is returning a Promise rejected
111 v8SetReturnValue(info, exceptionState.rejectedPromise().v8Value()); \
112 return; \
113 } \
114 }
115
89 #define V8TRYCATCH_FOR_V8STRINGRESOURCE_RETURN(type, var, value, retVal) \ 116 #define V8TRYCATCH_FOR_V8STRINGRESOURCE_RETURN(type, var, value, retVal) \
90 type var(value); \ 117 type var(value); \
91 if (UNLIKELY(!var.prepare())) \ 118 if (UNLIKELY(!var.prepare())) \
92 return retVal; 119 return retVal;
93 120
94 #define V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(type, var, value) \ 121 #define V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(type, var, value) \
95 type var(value); \ 122 type var(value); \
96 if (UNLIKELY(!var.prepare())) \ 123 if (UNLIKELY(!var.prepare())) \
97 return; 124 return;
98 125
126 #define V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID_PROMISE(type, var, value, info) \
127 type var(value); \
128 { \
129 v8::TryCatch block; \
130 var.prepare(); \
131 if (UNLIKELY(block.HasCaught())) { \
132 v8::Isolate* isolate = info.GetIsolate(); \
133 ScriptPromise promise = ScriptPromise::reject(block.Exception(), iso late); \
134 v8SetReturnValue(info, promise.v8Value()); \
135 return; \
136 } \
137 }
138
99 } // namespace WebCore 139 } // namespace WebCore
100 140
101 #endif // V8BindingMacros_h 141 #endif // V8BindingMacros_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698