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

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

Issue 2541683002: Make ImageBitmap transfers work in cases that require serialization (Closed)
Patch Set: Created 4 years 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 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 440
441 Transferables transferables; 441 Transferables transferables;
442 if (info.Length() > 1) { 442 if (info.Length() > 1) {
443 const int transferablesArgIndex = 1; 443 const int transferablesArgIndex = 1;
444 if (!SerializedScriptValue::extractTransferables(info.GetIsolate(), info[tra nsferablesArgIndex], transferablesArgIndex, transferables, exceptionState)) { 444 if (!SerializedScriptValue::extractTransferables(info.GetIsolate(), info[tra nsferablesArgIndex], transferablesArgIndex, transferables, exceptionState)) {
445 return; 445 return;
446 } 446 }
447 } 447 }
448 448
449 RefPtr<SerializedScriptValue> message; 449 RefPtr<SerializedScriptValue> message;
450 if (instance->canTransferArrayBuffer()) { 450 if (instance->canTransferArrayBuffersAndImageBitmaps()) {
451 // This instance supports sending array buffers by move semantics. 451 // This instance supports sending array buffers by move semantics.
452 message = SerializedScriptValue::serialize(info.GetIsolate(), info[0], &tran sferables, nullptr, exceptionState); 452 message = SerializedScriptValue::serialize(info.GetIsolate(), info[0], &tran sferables, nullptr, exceptionState);
453 if (exceptionState.hadException()) 453 if (exceptionState.hadException())
454 return; 454 return;
455 } else { 455 } else {
456 // This instance doesn't support sending array buffers by move 456 // This instance doesn't support sending array buffers and image bitmaps
457 // semantics. Emulate it by copy-and-neuter semantics that sends array 457 // by move semantics. Emulate it by copy-and-neuter semantics that sends
458 // buffers by copy semantics and then neuters the original array 458 // array buffers and image bitmaps via structured clone and then neuters
459 // buffers. 459 // the original objects
460 460
461 // Clear references to array buffers from transferables so that the 461 // Clear references to array buffers and image bitmaps from transferables
462 // serializer can consider the array buffers as non-transferable and 462 // so that the serializer can consider the array buffers as
463 // copy them into the message. 463 // non-transferable and serialize them into the message.
464 ArrayBufferArray transferableArrayBuffers = transferables.arrayBuffers; 464 ArrayBufferArray transferableArrayBuffers = transferables.arrayBuffers;
465 transferables.arrayBuffers.clear(); 465 transferables.arrayBuffers.clear();
466 ImageBitmapArray transferableImageBitmaps = transferables.imageBitmaps;
467 transferables.imageBitmaps.clear();
466 message = SerializedScriptValue::serialize(info.GetIsolate(), info[0], &tran sferables, nullptr, exceptionState); 468 message = SerializedScriptValue::serialize(info.GetIsolate(), info[0], &tran sferables, nullptr, exceptionState);
467 if (exceptionState.hadException()) 469 if (exceptionState.hadException())
468 return; 470 return;
469 471
470 // Neuter the original array buffers on the sender context. 472 // Neuter the original array buffers on the sender context.
471 SerializedScriptValue::transferArrayBufferContents(info.GetIsolate(), transf erableArrayBuffers, exceptionState); 473 SerializedScriptValue::transferArrayBufferContents(info.GetIsolate(), transf erableArrayBuffers, exceptionState);
472 if (exceptionState.hadException()) 474 if (exceptionState.hadException())
473 return; 475 return;
476 // Neuter the original image bitmaps on the sender context.
477 SerializedScriptValue::transferImageBitmapContents(info.GetIsolate(), transf erableImageBitmaps, exceptionState);
478 if (exceptionState.hadException())
479 return;
474 } 480 }
475 481
476 // FIXME: Only pass context/exceptionState if instance really requires it. 482 // FIXME: Only pass context/exceptionState if instance really requires it.
477 ExecutionContext* context = currentExecutionContext(info.GetIsolate()); 483 ExecutionContext* context = currentExecutionContext(info.GetIsolate());
478 instance->postMessage(context, message.release(), transferables.messagePorts, exceptionState); 484 instance->postMessage(context, message.release(), transferables.messagePorts, exceptionState);
479 } 485 }
480 {% endmacro %} 486 {% endmacro %}
481 487
482 488
483 {##############################################################################} 489 {##############################################################################}
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 if method.overloads else 679 if method.overloads else
674 method.runtime_enabled_function) %} 680 method.runtime_enabled_function) %}
675 const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfiguration = {{method_configuration(method)}}; 681 const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfiguration = {{method_configuration(method)}};
676 V8DOMConfiguration::installMethod(isolate, world, v8::Local<v8::Object>(), proto typeObject, interfaceObject, signature, {{method.name}}MethodConfiguration); 682 V8DOMConfiguration::installMethod(isolate, world, v8::Local<v8::Object>(), proto typeObject, interfaceObject, signature, {{method.name}}MethodConfiguration);
677 {% endfilter %}{# runtime_enabled() #} 683 {% endfilter %}{# runtime_enabled() #}
678 {% endfilter %}{# exposed() #} 684 {% endfilter %}{# exposed() #}
679 {% endfilter %}{# secure_context() #} 685 {% endfilter %}{# secure_context() #}
680 {% endfor %} 686 {% endfor %}
681 {% endif %} 687 {% endif %}
682 {%- endmacro %} 688 {%- endmacro %}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698