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

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

Issue 1526183004: Prevent SharedArrayBuffer views from being used in bindings (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: some tests Created 3 years, 11 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.tmpl' import declare_enum_validation_variable, v8_value_t o_local_cpp_value %} 1 {% from 'utilities.cpp.tmpl' import declare_enum_validation_variable, v8_value_t o_local_cpp_value %}
2 2
3 {##############################################################################} 3 {##############################################################################}
4 {% macro generate_method(method, world_suffix) %} 4 {% macro generate_method(method, world_suffix) %}
5 static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const v8::FunctionCallbackInfo<v8::Value>& info) { 5 static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const v8::FunctionCallbackInfo<v8::Value>& info) {
6 {% filter format_remove_duplicates([ 6 {% filter format_remove_duplicates([
7 'ExceptionState exceptionState', 7 'ExceptionState exceptionState',
8 'ScriptState* scriptState = ']) %} 8 'ScriptState* scriptState = ']) %}
9 {% set define_exception_state -%} 9 {% set define_exception_state -%}
10 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::ExecutionCont ext, "{{interface_name}}", "{{method.name}}"); 10 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::ExecutionCont ext, "{{interface_name}}", "{{method.name}}");
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 return; 226 return;
227 } 227 }
228 {% elif argument.idl_type == 'Promise' %} 228 {% elif argument.idl_type == 'Promise' %}
229 {# We require this for our implementation of promises, though not in spec: 229 {# We require this for our implementation of promises, though not in spec:
230 http://heycam.github.io/webidl/#es-promise #} 230 http://heycam.github.io/webidl/#es-promise #}
231 if (!{{argument.name}}.isUndefinedOrNull() && !{{argument.name}}.isObject()) { 231 if (!{{argument.name}}.isUndefinedOrNull() && !{{argument.name}}.isObject()) {
232 {{throw_argument_error(method, argument, "parameter %(index)d ('%(name)s') is not an object.")}} 232 {{throw_argument_error(method, argument, "parameter %(index)d ('%(name)s') is not an object.")}}
233 return; 233 return;
234 } 234 }
235 {% endif %} 235 {% endif %}
236 {% if argument.is_array_buffer_view %}
237 if ({{argument.name}}{% if argument.is_flexible_array_buffer_view %}.{% else %}- >{% endif %}isShared()) {
238 {{throw_type_error(method,
239 '"parameter %s is a view of a SharedArrayBuffer."' %
240 (argument.index + 1)) | indent}}
241 return;
242 }
243 {% elif argument.is_union_with_array_buffer_view %}
244 if ({{argument.name}}.isArrayBufferView() && {{argument.name}}.getAsArrayBufferV iew()->isShared()) {
245 {{throw_type_error(method,
246 '"parameter %s is a view of a SharedArrayBuffer."' %
247 (argument.index + 1)) | indent}}
248 return;
249 }
250 {% elif argument.is_sequence_of_union_with_array_buffer_view %}
251 for (size_t i= 0; i < {{argument.name}}.size(); ++i) {
252 if ({{argument.name}}[i].isArrayBufferView() && {{argument.name}}[i].getAsAr rayBufferView()->isShared()) {
253 {{throw_type_error(method,
254 '"sequence parameter %s contains a view of a SharedArrayBuffer."' %
255 (argument.index + 1)) | indent(8)}}
256 return;
257 }
258 }
259 {% endif %}
236 {% endmacro %} 260 {% endmacro %}
237 261
238 262
239 {######################################} 263 {######################################}
240 {% macro cpp_method_call(method, v8_set_return_value, cpp_value) %} 264 {% macro cpp_method_call(method, v8_set_return_value, cpp_value) %}
241 {% if method.is_custom_call_prologue %} 265 {% if method.is_custom_call_prologue %}
242 {{v8_class}}::{{method.name}}MethodPrologueCustom(info, impl); 266 {{v8_class}}::{{method.name}}MethodPrologueCustom(info, impl);
243 {% endif %} 267 {% endif %}
244 {# Local variables #} 268 {# Local variables #}
245 {% if method.is_call_with_execution_context %} 269 {% if method.is_call_with_execution_context %}
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 if method.overloads else 661 if method.overloads else
638 method.runtime_enabled_feature_name) %} 662 method.runtime_enabled_feature_name) %}
639 const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfiguration = {{method_configuration(method)}}; 663 const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfiguration = {{method_configuration(method)}};
640 V8DOMConfiguration::installMethod(isolate, world, v8::Local<v8::Object>(), proto typeObject, interfaceObject, signature, {{method.name}}MethodConfiguration); 664 V8DOMConfiguration::installMethod(isolate, world, v8::Local<v8::Object>(), proto typeObject, interfaceObject, signature, {{method.name}}MethodConfiguration);
641 {% endfilter %}{# runtime_enabled() #} 665 {% endfilter %}{# runtime_enabled() #}
642 {% endfilter %}{# exposed() #} 666 {% endfilter %}{# exposed() #}
643 {% endfilter %}{# secure_context() #} 667 {% endfilter %}{# secure_context() #}
644 {% endfor %} 668 {% endfor %}
645 {% endif %} 669 {% endif %}
646 {%- endmacro %} 670 {%- endmacro %}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698