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

Side by Side Diff: third_party/WebKit/Source/bindings/templates/methods.cpp

Issue 2061113002: Remove ExceptionState::throwIfNeeded Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: temp Created 4 years, 5 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 {% from 'utilities.cpp' import declare_enum_validation_variable, v8_value_to_loc al_cpp_value %} 1 {% from 'utilities.cpp' import declare_enum_validation_variable, v8_value_to_loc al_cpp_value %}
2 2
3 {##############################################################################} 3 {##############################################################################}
4 {% macro generate_method(method, world_suffix) %} 4 {% macro generate_method(method, world_suffix) %}
5 {% if method.returns_promise and method.has_exception_state %} 5 {% if method.returns_promise and method.has_exception_state %}
6 static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}Promis e(const v8::FunctionCallbackInfo<v8::Value>& info, ExceptionState& exceptionStat e) 6 static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}Promis e(const v8::FunctionCallbackInfo<v8::Value>& info, ExceptionState& exceptionStat e)
7 {% else %} 7 {% else %}
8 static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const v8::FunctionCallbackInfo<v8::Value>& info) 8 static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const v8::FunctionCallbackInfo<v8::Value>& info)
9 {% endif %} 9 {% endif %}
10 { 10 {
(...skipping 15 matching lines...) Expand all
26 {% endif %} 26 {% endif %}
27 {# Security checks #} 27 {# Security checks #}
28 {% if method.is_check_security_for_receiver %} 28 {% if method.is_check_security_for_receiver %}
29 {% if interface_name == 'EventTarget' %} 29 {% if interface_name == 'EventTarget' %}
30 // Performance hack for EventTarget. Checking whether it's a Window or not 30 // Performance hack for EventTarget. Checking whether it's a Window or not
31 // prior to the call to BindingSecurity::shouldAllowAccessTo increases 30% 31 // prior to the call to BindingSecurity::shouldAllowAccessTo increases 30%
32 // of speed performance on Android Nexus 7 as of Dec 2015. ALWAYS_INLINE 32 // of speed performance on Android Nexus 7 as of Dec 2015. ALWAYS_INLINE
33 // didn't work in this case. 33 // didn't work in this case.
34 if (const DOMWindow* window = impl->toDOMWindow()) { 34 if (const DOMWindow* window = impl->toDOMWindow()) {
35 if (!BindingSecurity::shouldAllowAccessTo(info.GetIsolate(), currentDOMW indow(info.GetIsolate()), window, exceptionState)) { 35 if (!BindingSecurity::shouldAllowAccessTo(info.GetIsolate(), currentDOMW indow(info.GetIsolate()), window, exceptionState)) {
36 {% if not method.returns_promise %} 36 {% if method.returns_promise %}
37 exceptionState.throwIfNeeded(); 37 exceptionState.clearException();
38 {% endif %} 38 {% endif %}
39 return; 39 return;
40 } 40 }
41 } 41 }
42 {% else %}{# interface_name == 'EventTarget' #} 42 {% else %}{# interface_name == 'EventTarget' #}
43 if (!BindingSecurity::shouldAllowAccessTo(info.GetIsolate(), currentDOMWindo w(info.GetIsolate()), impl, exceptionState)) { 43 if (!BindingSecurity::shouldAllowAccessTo(info.GetIsolate(), currentDOMWindo w(info.GetIsolate()), impl, exceptionState)) {
44 {% if not method.returns_promise %} 44 {% if method.returns_promise %}
45 exceptionState.throwIfNeeded(); 45 exceptionState.clearException();
46 {% endif %} 46 {% endif %}
47 return; 47 return;
48 } 48 }
49 {% endif %}{# interface_name == 'EventTarget' #} 49 {% endif %}{# interface_name == 'EventTarget' #}
50 {% endif %} 50 {% endif %}
51 {% if method.is_check_security_for_return_value %} 51 {% if method.is_check_security_for_return_value %}
52 if (!BindingSecurity::shouldAllowAccessTo(info.GetIsolate(), currentDOMWindo w(info.GetIsolate()), {{method.cpp_value}}, exceptionState)) { 52 if (!BindingSecurity::shouldAllowAccessTo(info.GetIsolate(), currentDOMWindo w(info.GetIsolate()), {{method.cpp_value}}, exceptionState)) {
53 v8SetReturnValueNull(info); 53 v8SetReturnValueNull(info);
54 {% if not method.returns_promise %} 54 {% if method.returns_promise %}
55 exceptionState.throwIfNeeded(); 55 exceptionState.clearException();
56 {% endif %} 56 {% endif %}
57 return; 57 return;
58 } 58 }
59 {% endif %} 59 {% endif %}
60 {# Call method #} 60 {# Call method #}
61 {% if method.arguments %} 61 {% if method.arguments %}
62 {{generate_arguments(method, world_suffix) | indent}} 62 {{generate_arguments(method, world_suffix) | indent}}
63 {% endif %} 63 {% endif %}
64 {% if world_suffix %} 64 {% if world_suffix %}
65 {{cpp_method_call(method, method.v8_set_return_value_for_main_world, method. cpp_value) | indent}} 65 {{cpp_method_call(method, method.v8_set_return_value_for_main_world, method. cpp_value) | indent}}
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 Note: for variadic arguments, the type checking is done for each matched 201 Note: for variadic arguments, the type checking is done for each matched
202 argument instead; see argument.is_variadic_wrapper_type code-path above. #} 202 argument instead; see argument.is_variadic_wrapper_type code-path above. #}
203 if (!{{argument.name}}{% if argument.is_nullable %} && !isUndefinedOrNull(info[{ {argument.index}}]){% endif %}) { 203 if (!{{argument.name}}{% if argument.is_nullable %} && !isUndefinedOrNull(info[{ {argument.index}}]){% endif %}) {
204 {{throw_type_error(method, '"parameter %s is not of type \'%s\'."' % 204 {{throw_type_error(method, '"parameter %s is not of type \'%s\'."' %
205 (argument.index + 1, argument.idl_type)) | indent }} 205 (argument.index + 1, argument.idl_type)) | indent }}
206 } 206 }
207 {% elif argument.enum_values %} 207 {% elif argument.enum_values %}
208 {# Invalid enum values: http://www.w3.org/TR/WebIDL/#idl-enums #} 208 {# Invalid enum values: http://www.w3.org/TR/WebIDL/#idl-enums #}
209 {{declare_enum_validation_variable(argument.enum_values)}} 209 {{declare_enum_validation_variable(argument.enum_values)}}
210 if (!isValidEnum({{argument.name}}, validValues, WTF_ARRAY_LENGTH(validValues), "{{argument.enum_type}}", exceptionState)) { 210 if (!isValidEnum({{argument.name}}, validValues, WTF_ARRAY_LENGTH(validValues), "{{argument.enum_type}}", exceptionState)) {
211 exceptionState.throwIfNeeded();
212 return; 211 return;
213 } 212 }
214 {% elif argument.idl_type == 'Promise' %} 213 {% elif argument.idl_type == 'Promise' %}
215 {# We require this for our implementation of promises, though not in spec: 214 {# We require this for our implementation of promises, though not in spec:
216 http://heycam.github.io/webidl/#es-promise #} 215 http://heycam.github.io/webidl/#es-promise #}
217 if (!{{argument.name}}.isUndefinedOrNull() && !{{argument.name}}.isObject()) { 216 if (!{{argument.name}}.isUndefinedOrNull() && !{{argument.name}}.isObject()) {
218 {{throw_type_error(method, '"parameter %s (\'%s\') is not an object."' % 217 {{throw_type_error(method, '"parameter %s (\'%s\') is not an object."' %
219 (argument.index + 1, argument.name)) | indent}} 218 (argument.index + 1, argument.name)) | indent}}
220 } 219 }
221 {% endif %} 220 {% endif %}
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 {%- else %} 312 {%- else %}
314 ExceptionMessages::failedToExecute("{{method.name}}", "{{interface_name}}", {{er ror_message}}) 313 ExceptionMessages::failedToExecute("{{method.name}}", "{{interface_name}}", {{er ror_message}})
315 {%- endif %} 314 {%- endif %}
316 {%- endmacro %} 315 {%- endmacro %}
317 316
318 317
319 {######################################} 318 {######################################}
320 {% macro propagate_error_with_exception_state(method_or_overloads) %} 319 {% macro propagate_error_with_exception_state(method_or_overloads) %}
321 {% if method_or_overloads.returns_promise_all %} 320 {% if method_or_overloads.returns_promise_all %}
322 v8SetReturnValue(info, exceptionState.reject(ScriptState::current(info.GetIsolat e())).v8Value()); 321 v8SetReturnValue(info, exceptionState.reject(ScriptState::current(info.GetIsolat e())).v8Value());
323 {% elif not method_or_overloads.returns_promise %} 322 {% endif %}
324 exceptionState.throwIfNeeded(); 323 {% if method_or_overloads.returns_promise_all or method_or_overloads.returns_pro mise %}
324 exceptionState.clearException();
325 {% endif %} 325 {% endif %}
326 return; 326 return;
327 {%- endmacro %} 327 {%- endmacro %}
328 328
329 329
330 {######################################} 330 {######################################}
331 {% macro throw_minimum_arity_type_error(method, number_of_required_arguments) %} 331 {% macro throw_minimum_arity_type_error(method, number_of_required_arguments) %}
332 {% if method.has_exception_state %} 332 {% if method.has_exception_state %}
333 setMinimumArityTypeError(exceptionState, {{number_of_required_arguments}}, info. Length()); 333 setMinimumArityTypeError(exceptionState, {{number_of_required_arguments}}, info. Length());
334 {{propagate_error_with_exception_state(method)}} 334 {{propagate_error_with_exception_state(method)}}
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 {% endmacro %} 459 {% endmacro %}
460 460
461 461
462 {##############################################################################} 462 {##############################################################################}
463 {% macro generate_post_message_impl() %} 463 {% macro generate_post_message_impl() %}
464 void postMessageImpl(const char* interfaceName, {{cpp_class}}* instance, const v 8::FunctionCallbackInfo<v8::Value>& info) 464 void postMessageImpl(const char* interfaceName, {{cpp_class}}* instance, const v 8::FunctionCallbackInfo<v8::Value>& info)
465 { 465 {
466 ExceptionState exceptionState(ExceptionState::ExecutionContext, "postMessage ", interfaceName, info.Holder(), info.GetIsolate()); 466 ExceptionState exceptionState(ExceptionState::ExecutionContext, "postMessage ", interfaceName, info.Holder(), info.GetIsolate());
467 if (UNLIKELY(info.Length() < 1)) { 467 if (UNLIKELY(info.Length() < 1)) {
468 setMinimumArityTypeError(exceptionState, 1, info.Length()); 468 setMinimumArityTypeError(exceptionState, 1, info.Length());
469 exceptionState.throwIfNeeded();
470 return; 469 return;
471 } 470 }
472 Transferables transferables; 471 Transferables transferables;
473 if (info.Length() > 1) { 472 if (info.Length() > 1) {
474 const int transferablesArgIndex = 1; 473 const int transferablesArgIndex = 1;
475 if (!SerializedScriptValue::extractTransferables(info.GetIsolate(), info [transferablesArgIndex], transferablesArgIndex, transferables, exceptionState)) { 474 if (!SerializedScriptValue::extractTransferables(info.GetIsolate(), info [transferablesArgIndex], transferablesArgIndex, transferables, exceptionState)) {
476 exceptionState.throwIfNeeded();
477 return; 475 return;
478 } 476 }
479 } 477 }
480 RefPtr<SerializedScriptValue> message = SerializedScriptValue::serialize(inf o.GetIsolate(), info[0], &transferables, nullptr, exceptionState); 478 RefPtr<SerializedScriptValue> message = SerializedScriptValue::serialize(inf o.GetIsolate(), info[0], &transferables, nullptr, exceptionState);
481 if (exceptionState.throwIfNeeded()) 479 if (exceptionState.hadException())
482 return; 480 return;
483 // FIXME: Only pass context/exceptionState if instance really requires it. 481 // FIXME: Only pass context/exceptionState if instance really requires it.
484 ExecutionContext* context = currentExecutionContext(info.GetIsolate()); 482 ExecutionContext* context = currentExecutionContext(info.GetIsolate());
485 instance->postMessage(context, message.release(), transferables.messagePorts , exceptionState); 483 instance->postMessage(context, message.release(), transferables.messagePorts , exceptionState);
486 exceptionState.throwIfNeeded();
487 } 484 }
488 {% endmacro %} 485 {% endmacro %}
489 486
490 {##############################################################################} 487 {##############################################################################}
491 {% macro method_callback(method, world_suffix) %} 488 {% macro method_callback(method, world_suffix) %}
492 static void {{method.name}}MethodCallback{{world_suffix}}(const v8::FunctionCall backInfo<v8::Value>& info) 489 static void {{method.name}}MethodCallback{{world_suffix}}(const v8::FunctionCall backInfo<v8::Value>& info)
493 { 490 {
494 {% if not method.overloads %}{# Overloaded methods are measured in overload_ resolution_method() #} 491 {% if not method.overloads %}{# Overloaded methods are measured in overload_ resolution_method() #}
495 {% if method.measure_as %} 492 {% if method.measure_as %}
496 UseCounter::countIfNotPrivateScript(info.GetIsolate(), currentExecutionConte xt(info.GetIsolate()), UseCounter::{{method.measure_as('Method')}}); 493 UseCounter::countIfNotPrivateScript(info.GetIsolate(), currentExecutionConte xt(info.GetIsolate()), UseCounter::{{method.measure_as('Method')}});
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 {% filter runtime_enabled(method.overloads.runtime_enabled_function_all 680 {% filter runtime_enabled(method.overloads.runtime_enabled_function_all
684 if method.overloads else 681 if method.overloads else
685 method.runtime_enabled_function) %} 682 method.runtime_enabled_function) %}
686 const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfiguration = {{method_configuration(method)}}; 683 const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfiguration = {{method_configuration(method)}};
687 V8DOMConfiguration::installMethod(isolate, world, v8::Local<v8::Object>(), proto typeObject, interfaceObject, signature, {{method.name}}MethodConfiguration); 684 V8DOMConfiguration::installMethod(isolate, world, v8::Local<v8::Object>(), proto typeObject, interfaceObject, signature, {{method.name}}MethodConfiguration);
688 {% endfilter %}{# runtime_enabled() #} 685 {% endfilter %}{# runtime_enabled() #}
689 {% endfilter %}{# exposed() #} 686 {% endfilter %}{# exposed() #}
690 {% endfor %} 687 {% endfor %}
691 {% endif %} 688 {% endif %}
692 {%- endmacro %} 689 {%- endmacro %}
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/bindings/templates/interface.cpp ('k') | third_party/WebKit/Source/bindings/templates/utilities.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698