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

Side by Side Diff: Source/bindings/templates/interface.cpp

Issue 1097773004: Sharing of SharedArrayBuffer via PostMessage transfer (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add worker global interface listing expectations Created 5 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 {% extends 'interface_base.cpp' %} 1 {% extends 'interface_base.cpp' %}
2 2
3 3
4 {##############################################################################} 4 {##############################################################################}
5 {% block indexed_property_getter %} 5 {% block indexed_property_getter %}
6 {% if indexed_property_getter and not indexed_property_getter.is_custom %} 6 {% if indexed_property_getter and not indexed_property_getter.is_custom %}
7 {% set getter = indexed_property_getter %} 7 {% set getter = indexed_property_getter %}
8 static void indexedPropertyGetter(uint32_t index, const v8::PropertyCallbackInfo <v8::Value>& info) 8 static void indexedPropertyGetter(uint32_t index, const v8::PropertyCallbackInfo <v8::Value>& info)
9 { 9 {
10 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); 10 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder());
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after
739 // Transfer the ownership of the allocated memory to an ArrayBuffer without 739 // Transfer the ownership of the allocated memory to an ArrayBuffer without
740 // copying. 740 // copying.
741 v8::ArrayBuffer::Contents v8Contents = v8buffer->Externalize(); 741 v8::ArrayBuffer::Contents v8Contents = v8buffer->Externalize();
742 WTF::ArrayBufferContents contents(v8Contents.Data(), v8Contents.ByteLength() , WTF::ArrayBufferContents::NotShared); 742 WTF::ArrayBufferContents contents(v8Contents.Data(), v8Contents.ByteLength() , WTF::ArrayBufferContents::NotShared);
743 RefPtr<{{cpp_class}}> buffer = {{cpp_class}}::create(contents); 743 RefPtr<{{cpp_class}}> buffer = {{cpp_class}}::create(contents);
744 buffer->associateWithWrapper(v8::Isolate::GetCurrent(), buffer->wrapperTypeI nfo(), object); 744 buffer->associateWithWrapper(v8::Isolate::GetCurrent(), buffer->wrapperTypeI nfo(), object);
745 745
746 return buffer.get(); 746 return buffer.get();
747 } 747 }
748 748
749 {% elif interface_name == 'SharedArrayBuffer' %}
750 {{cpp_class}}* V8SharedArrayBuffer::toImpl(v8::Local<v8::Object> object)
751 {
752 ASSERT(object->IsSharedArrayBuffer());
753 v8::Local<v8::SharedArrayBuffer> v8buffer = object.As<v8::SharedArrayBuffer> ();
754 if (v8buffer->IsExternal()) {
755 const WrapperTypeInfo* wrapperTypeInfo = toWrapperTypeInfo(object);
756 RELEASE_ASSERT(wrapperTypeInfo);
757 RELEASE_ASSERT(wrapperTypeInfo->ginEmbedder == gin::kEmbedderBlink);
758 return toScriptWrappable(object)->toImpl<{{cpp_class}}>();
759 }
760
761 // Transfer the ownership of the allocated memory to a SharedArrayBuffer
762 // without copying.
763 v8::SharedArrayBuffer::Contents v8Contents = v8buffer->Externalize();
764 WTF::ArrayBufferContents contents(v8Contents.Data(), v8Contents.ByteLength() , WTF::ArrayBufferContents::Shared);
765 RefPtr<{{cpp_class}}> buffer = {{cpp_class}}::create(contents);
766 buffer->associateWithWrapper(v8::Isolate::GetCurrent(), buffer->wrapperTypeI nfo(), object);
767
768 return buffer.get();
769 }
770
749 {% elif interface_name == 'ArrayBufferView' %} 771 {% elif interface_name == 'ArrayBufferView' %}
750 {{cpp_class}}* V8ArrayBufferView::toImpl(v8::Local<v8::Object> object) 772 {{cpp_class}}* V8ArrayBufferView::toImpl(v8::Local<v8::Object> object)
751 { 773 {
752 ASSERT(object->IsArrayBufferView()); 774 ASSERT(object->IsArrayBufferView());
753 ScriptWrappable* scriptWrappable = toScriptWrappable(object); 775 ScriptWrappable* scriptWrappable = toScriptWrappable(object);
754 if (scriptWrappable) 776 if (scriptWrappable)
755 return scriptWrappable->toImpl<{{cpp_class}}>(); 777 return scriptWrappable->toImpl<{{cpp_class}}>();
756 778
757 if (object->IsInt8Array()) 779 if (object->IsInt8Array())
758 return V8Int8Array::toImpl(object); 780 return V8Int8Array::toImpl(object);
(...skipping 22 matching lines...) Expand all
781 803
782 {% elif is_array_buffer_or_view %} 804 {% elif is_array_buffer_or_view %}
783 {{cpp_class}}* {{v8_class}}::toImpl(v8::Local<v8::Object> object) 805 {{cpp_class}}* {{v8_class}}::toImpl(v8::Local<v8::Object> object)
784 { 806 {
785 ASSERT(object->Is{{interface_name}}()); 807 ASSERT(object->Is{{interface_name}}());
786 ScriptWrappable* scriptWrappable = toScriptWrappable(object); 808 ScriptWrappable* scriptWrappable = toScriptWrappable(object);
787 if (scriptWrappable) 809 if (scriptWrappable)
788 return scriptWrappable->toImpl<{{cpp_class}}>(); 810 return scriptWrappable->toImpl<{{cpp_class}}>();
789 811
790 v8::Local<v8::{{interface_name}}> v8View = object.As<v8::{{interface_name}}> (); 812 v8::Local<v8::{{interface_name}}> v8View = object.As<v8::{{interface_name}}> ();
791 RefPtr<{{cpp_class}}> typedArray = {{cpp_class}}::create(V8ArrayBuffer::toIm pl(v8View->Buffer()), v8View->ByteOffset(), v8View->{% if interface_name == 'Dat aView' %}Byte{% endif %}Length()); 813 v8::Local<v8::Object> arrayBuffer = v8View->Buffer();
814 RefPtr<{{cpp_class}}> typedArray;
815 {% if interface_name == 'DataView' %}
816 if (arrayBuffer->IsArrayBuffer()) {
817 typedArray = {{cpp_class}}::create(V8ArrayBuffer::toImpl(arrayBuffer), v 8View->ByteOffset(), v8View->ByteLength());
818 } else if (arrayBuffer->IsSharedArrayBuffer()) {
819 typedArray = {{cpp_class}}::create(V8SharedArrayBuffer::toImpl(arrayBuff er), v8View->ByteOffset(), v8View->ByteLength());
820 } else {
821 ASSERT_NOT_REACHED();
822 }
823 {% else %}
824 if (arrayBuffer->IsArrayBuffer()) {
825 typedArray = {{cpp_class}}::create(V8ArrayBuffer::toImpl(arrayBuffer), v 8View->ByteOffset(), v8View->Length());
826 } else if (arrayBuffer->IsSharedArrayBuffer()) {
827 typedArray = {{cpp_class}}::create(V8SharedArrayBuffer::toImpl(arrayBuff er), v8View->ByteOffset(), v8View->Length());
828 } else {
829 ASSERT_NOT_REACHED();
830 }
831 {% endif %}
792 typedArray->associateWithWrapper(v8::Isolate::GetCurrent(), typedArray->wrap perTypeInfo(), object); 832 typedArray->associateWithWrapper(v8::Isolate::GetCurrent(), typedArray->wrap perTypeInfo(), object);
793 833
794 return typedArray->toImpl<{{cpp_class}}>(); 834 return typedArray->toImpl<{{cpp_class}}>();
795 } 835 }
796 836
797 {% endif %} 837 {% endif %}
798 {% endblock %} 838 {% endblock %}
799 839
800 840
801 {##############################################################################} 841 {##############################################################################}
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
957 } 997 }
958 998
959 {% for method in methods if method.overloads and method.overloads.has_partial_ov erloads %} 999 {% for method in methods if method.overloads and method.overloads.has_partial_ov erloads %}
960 void {{v8_class}}::register{{method.name | blink_capitalize}}MethodForPartialInt erface(void (*method)(const v8::FunctionCallbackInfo<v8::Value>&)) 1000 void {{v8_class}}::register{{method.name | blink_capitalize}}MethodForPartialInt erface(void (*method)(const v8::FunctionCallbackInfo<v8::Value>&))
961 { 1001 {
962 {{cpp_class}}V8Internal::{{method.name}}MethodForPartialInterface = method; 1002 {{cpp_class}}V8Internal::{{method.name}}MethodForPartialInterface = method;
963 } 1003 }
964 {% endfor %} 1004 {% endfor %}
965 {% endif %} 1005 {% endif %}
966 {% endblock %} 1006 {% endblock %}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698