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

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

Issue 2809773003: [SharedArrayBuffer] Throw DataClone error if SharedArrayBuffer can't be sent (Closed)
Patch Set: Created 3 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 {% 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::kExecutionCon text, "{{interface_name}}", "{{method.name}}"); 10 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::kExecutionCon text, "{{interface_name}}", "{{method.name}}");
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 return; 440 return;
441 } else { 441 } else {
442 // This instance doesn't support sending array buffers and image bitmaps 442 // This instance doesn't support sending array buffers and image bitmaps
443 // by move semantics. Emulate it by copy-and-neuter semantics that sends 443 // by move semantics. Emulate it by copy-and-neuter semantics that sends
444 // array buffers and image bitmaps via structured clone and then neuters 444 // array buffers and image bitmaps via structured clone and then neuters
445 // the original objects 445 // the original objects
446 446
447 // Clear references to array buffers and image bitmaps from transferables 447 // Clear references to array buffers and image bitmaps from transferables
448 // so that the serializer can consider the array buffers as 448 // so that the serializer can consider the array buffers as
449 // non-transferable and serialize them into the message. 449 // non-transferable and serialize them into the message.
450 ArrayBufferArray transferableArrayBuffers = transferables.array_buffers; 450 ArrayBufferArray transferableArrayBuffers = SerializedScriptValue::ExtractNo nSharedArrayBuffers(transferables);
451 transferables.array_buffers.Clear();
452 ImageBitmapArray transferableImageBitmaps = transferables.image_bitmaps; 451 ImageBitmapArray transferableImageBitmaps = transferables.image_bitmaps;
453 transferables.image_bitmaps.Clear(); 452 transferables.image_bitmaps.Clear();
454 SerializedScriptValue::SerializeOptions options; 453 SerializedScriptValue::SerializeOptions options;
455 options.transferables = &transferables; 454 options.transferables = &transferables;
456 message = SerializedScriptValue::Serialize(info.GetIsolate(), info[0], optio ns, exceptionState); 455 message = SerializedScriptValue::Serialize(info.GetIsolate(), info[0], optio ns, exceptionState);
457 if (exceptionState.HadException()) 456 if (exceptionState.HadException())
458 return; 457 return;
459 458
459 // If the transferable array_buffer list is empty, then it must have been po pulated with SharedArrayBuffers. They can't be transfered, so throw.
460 if (!message->GetArrayBufferContentsArray()->IsEmpty()) {
461 exceptionState.ThrowDOMException(kDataCloneError, "SharedArrayBuffer can n ot be sent in this context.");
462 return;
463 }
464
460 // Neuter the original array buffers on the sender context. 465 // Neuter the original array buffers on the sender context.
461 SerializedScriptValue::TransferArrayBufferContents(info.GetIsolate(), transf erableArrayBuffers, exceptionState); 466 SerializedScriptValue::TransferArrayBufferContents(info.GetIsolate(), transf erableArrayBuffers, exceptionState);
462 if (exceptionState.HadException()) 467 if (exceptionState.HadException())
463 return; 468 return;
464 // Neuter the original image bitmaps on the sender context. 469 // Neuter the original image bitmaps on the sender context.
465 SerializedScriptValue::TransferImageBitmapContents(info.GetIsolate(), transf erableImageBitmaps, exceptionState); 470 SerializedScriptValue::TransferImageBitmapContents(info.GetIsolate(), transf erableImageBitmaps, exceptionState);
466 if (exceptionState.HadException()) 471 if (exceptionState.HadException())
467 return; 472 return;
468 } 473 }
469 474
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
650 {{method_configuration(method) | indent(2)}} 655 {{method_configuration(method) | indent(2)}}
651 }; 656 };
652 for (const auto& methodConfig : {{method.name}}MethodConfiguration) 657 for (const auto& methodConfig : {{method.name}}MethodConfiguration)
653 V8DOMConfiguration::InstallMethod(isolate, world, v8::Local<v8::Object>(), pro totypeObject, interfaceObject, signature, methodConfig); 658 V8DOMConfiguration::InstallMethod(isolate, world, v8::Local<v8::Object>(), pro totypeObject, interfaceObject, signature, methodConfig);
654 {% endfilter %}{# runtime_enabled() #} 659 {% endfilter %}{# runtime_enabled() #}
655 {% endfilter %}{# exposed() #} 660 {% endfilter %}{# exposed() #}
656 {% endfilter %}{# secure_context() #} 661 {% endfilter %}{# secure_context() #}
657 {% endfor %} 662 {% endfor %}
658 {% endif %} 663 {% endif %}
659 {%- endmacro %} 664 {%- endmacro %}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698