| Index: Source/bindings/templates/interface.cpp
|
| diff --git a/Source/bindings/templates/interface.cpp b/Source/bindings/templates/interface.cpp
|
| index c736a026d980b26815bb35978f8932c83643e13c..edac6aa1df80a81aa6098ae76d8b8088c54e3cf7 100644
|
| --- a/Source/bindings/templates/interface.cpp
|
| +++ b/Source/bindings/templates/interface.cpp
|
| @@ -725,7 +725,33 @@ v8::Local<v8::Object> {{v8_class}}::findInstanceInPrototypeChain(v8::Local<v8::V
|
| // Transfer the ownership of the allocated memory to an ArrayBuffer without
|
| // copying.
|
| v8::ArrayBuffer::Contents v8Contents = v8buffer->Externalize();
|
| - WTF::ArrayBufferContents contents(v8Contents.Data(), v8Contents.ByteLength(), 0);
|
| + WTF::ArrayBufferContents contents(v8Contents.Data(), v8Contents.ByteLength(), false, 0);
|
| + RefPtr<{{cpp_class}}> buffer = {{cpp_class}}::create(contents);
|
| + // Since this transfer doesn't allocate new memory, do not call
|
| + // DOMArrayBufferDeallocationObserver::blinkAllocatedMemory.
|
| + buffer->buffer()->setDeallocationObserverWithoutAllocationNotification(
|
| + DOMArrayBufferDeallocationObserver::instance());
|
| + buffer->associateWithWrapper(v8::Isolate::GetCurrent(), buffer->wrapperTypeInfo(), object);
|
| +
|
| + return buffer.get();
|
| +}
|
| +
|
| +{% elif interface_name == 'SharedArrayBuffer' %}
|
| +{{cpp_class}}* V8SharedArrayBuffer::toImpl(v8::Local<v8::Object> object)
|
| +{
|
| + ASSERT(object->IsSharedArrayBuffer());
|
| + v8::Local<v8::SharedArrayBuffer> v8buffer = object.As<v8::SharedArrayBuffer>();
|
| + if (v8buffer->IsExternal()) {
|
| + const WrapperTypeInfo* wrapperTypeInfo = toWrapperTypeInfo(object);
|
| + RELEASE_ASSERT(wrapperTypeInfo);
|
| + RELEASE_ASSERT(wrapperTypeInfo->ginEmbedder == gin::kEmbedderBlink);
|
| + return toScriptWrappable(object)->toImpl<{{cpp_class}}>();
|
| + }
|
| +
|
| + // Transfer the ownership of the allocated memory to a SharedArrayBuffer
|
| + // without copying.
|
| + v8::SharedArrayBuffer::Contents v8Contents = v8buffer->Externalize();
|
| + WTF::ArrayBufferContents contents(v8Contents.Data(), v8Contents.ByteLength(), true, 0);
|
| RefPtr<{{cpp_class}}> buffer = {{cpp_class}}::create(contents);
|
| // Since this transfer doesn't allocate new memory, do not call
|
| // DOMArrayBufferDeallocationObserver::blinkAllocatedMemory.
|
| @@ -778,7 +804,19 @@ v8::Local<v8::Object> {{v8_class}}::findInstanceInPrototypeChain(v8::Local<v8::V
|
| return scriptWrappable->toImpl<{{cpp_class}}>();
|
|
|
| v8::Local<v8::{{interface_name}}> v8View = object.As<v8::{{interface_name}}>();
|
| - RefPtr<{{cpp_class}}> typedArray = {{cpp_class}}::create(V8ArrayBuffer::toImpl(v8View->Buffer()), v8View->ByteOffset(), v8View->{% if interface_name == 'DataView' %}Byte{% endif %}Length());
|
| +{% if interface_name == 'DataView' %}
|
| + RefPtr<{{cpp_class}}> typedArray = {{cpp_class}}::create(V8ArrayBuffer::toImpl(v8View->Buffer()), v8View->ByteOffset(), v8View->ByteLength());
|
| +{% else %}
|
| + v8::Local<v8::Object> arrayBuffer = v8View->Buffer();
|
| + RefPtr<{{cpp_class}}> typedArray;
|
| + if (arrayBuffer->IsArrayBuffer()) {
|
| + typedArray = {{cpp_class}}::create(V8ArrayBuffer::toImpl(arrayBuffer), v8View->ByteOffset(), v8View->Length());
|
| + } else if (arrayBuffer->IsSharedArrayBuffer()) {
|
| + typedArray = {{cpp_class}}::create(V8SharedArrayBuffer::toImpl(arrayBuffer), v8View->ByteOffset(), v8View->Length());
|
| + } else {
|
| + ASSERT_NOT_REACHED();
|
| + }
|
| +{% endif %}
|
| typedArray->associateWithWrapper(v8::Isolate::GetCurrent(), typedArray->wrapperTypeInfo(), object);
|
|
|
| return typedArray->toImpl<{{cpp_class}}>();
|
|
|