| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/dom/DOMTypedArray.h" | 5 #include "core/dom/DOMTypedArray.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/DOMDataStore.h" | 7 #include "bindings/core/v8/DOMDataStore.h" |
| 8 #include "bindings/core/v8/V8ArrayBuffer.h" | 8 #include "bindings/core/v8/V8ArrayBuffer.h" |
| 9 #include "bindings/core/v8/V8Float32Array.h" | 9 #include "bindings/core/v8/V8Float32Array.h" |
| 10 #include "bindings/core/v8/V8Float64Array.h" | 10 #include "bindings/core/v8/V8Float64Array.h" |
| 11 #include "bindings/core/v8/V8Int16Array.h" | 11 #include "bindings/core/v8/V8Int16Array.h" |
| 12 #include "bindings/core/v8/V8Int32Array.h" | 12 #include "bindings/core/v8/V8Int32Array.h" |
| 13 #include "bindings/core/v8/V8Int8Array.h" | 13 #include "bindings/core/v8/V8Int8Array.h" |
| 14 #include "bindings/core/v8/V8Uint16Array.h" | 14 #include "bindings/core/v8/V8Uint16Array.h" |
| 15 #include "bindings/core/v8/V8Uint32Array.h" | 15 #include "bindings/core/v8/V8Uint32Array.h" |
| 16 #include "bindings/core/v8/V8Uint8Array.h" | 16 #include "bindings/core/v8/V8Uint8Array.h" |
| 17 #include "bindings/core/v8/V8Uint8ClampedArray.h" | 17 #include "bindings/core/v8/V8Uint8ClampedArray.h" |
| 18 | 18 |
| 19 namespace blink { | 19 namespace blink { |
| 20 | 20 |
| 21 template<typename WTFTypedArray, typename V8TypedArray> | 21 template<typename WTFTypedArray, typename V8TypedArray> |
| 22 v8::Local<v8::Object> DOMTypedArray<WTFTypedArray, V8TypedArray>::wrap(v8::Isola
te* isolate, v8::Local<v8::Object> creationContext) | 22 v8::Local<v8::Object> DOMTypedArray<WTFTypedArray, V8TypedArray>::wrap(v8::Isola
te* isolate, v8::Local<v8::Object> creationContext) |
| 23 { | 23 { |
| 24 // It's possible that no one except for the new wrapper owns this object at | |
| 25 // this moment, so we have to prevent GC to collect this object until the | |
| 26 // object gets associated with the wrapper. | |
| 27 RefPtr<ThisType> protect(this); | |
| 28 | |
| 29 DCHECK(!DOMDataStore::containsWrapper(this, isolate)); | 24 DCHECK(!DOMDataStore::containsWrapper(this, isolate)); |
| 30 | 25 |
| 31 const WrapperTypeInfo* wrapperTypeInfo = this->wrapperTypeInfo(); | 26 const WrapperTypeInfo* wrapperTypeInfo = this->wrapperTypeInfo(); |
| 32 RefPtr<DOMArrayBufferBase> buffer = this->bufferBase(); | 27 DOMArrayBufferBase* buffer = this->bufferBase(); |
| 33 v8::Local<v8::Value> v8Buffer = toV8(buffer.get(), creationContext, isolate)
; | 28 v8::Local<v8::Value> v8Buffer = toV8(buffer, creationContext, isolate); |
| 34 if (v8Buffer.IsEmpty()) | 29 if (v8Buffer.IsEmpty()) |
| 35 return v8::Local<v8::Object>(); | 30 return v8::Local<v8::Object>(); |
| 36 DCHECK_EQ(isShared(), v8Buffer->IsSharedArrayBuffer()); | 31 DCHECK_EQ(isShared(), v8Buffer->IsSharedArrayBuffer()); |
| 37 | 32 |
| 38 v8::Local<v8::Object> wrapper; | 33 v8::Local<v8::Object> wrapper; |
| 39 if (isShared()) { | 34 if (isShared()) { |
| 40 wrapper = V8TypedArray::New(v8Buffer.As<v8::SharedArrayBuffer>(), byteOf
fset(), length()); | 35 wrapper = V8TypedArray::New(v8Buffer.As<v8::SharedArrayBuffer>(), byteOf
fset(), length()); |
| 41 } else { | 36 } else { |
| 42 wrapper = V8TypedArray::New(v8Buffer.As<v8::ArrayBuffer>(), byteOffset()
, length()); | 37 wrapper = V8TypedArray::New(v8Buffer.As<v8::ArrayBuffer>(), byteOffset()
, length()); |
| 43 } | 38 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 template class CORE_TEMPLATE_EXPORT DOMTypedArray<WTF::Int16Array, v8::Int16Arra
y>; | 70 template class CORE_TEMPLATE_EXPORT DOMTypedArray<WTF::Int16Array, v8::Int16Arra
y>; |
| 76 template class CORE_TEMPLATE_EXPORT DOMTypedArray<WTF::Int32Array, v8::Int32Arra
y>; | 71 template class CORE_TEMPLATE_EXPORT DOMTypedArray<WTF::Int32Array, v8::Int32Arra
y>; |
| 77 template class CORE_TEMPLATE_EXPORT DOMTypedArray<WTF::Uint8Array, v8::Uint8Arra
y>; | 72 template class CORE_TEMPLATE_EXPORT DOMTypedArray<WTF::Uint8Array, v8::Uint8Arra
y>; |
| 78 template class CORE_TEMPLATE_EXPORT DOMTypedArray<WTF::Uint8ClampedArray, v8::Ui
nt8ClampedArray>; | 73 template class CORE_TEMPLATE_EXPORT DOMTypedArray<WTF::Uint8ClampedArray, v8::Ui
nt8ClampedArray>; |
| 79 template class CORE_TEMPLATE_EXPORT DOMTypedArray<WTF::Uint16Array, v8::Uint16Ar
ray>; | 74 template class CORE_TEMPLATE_EXPORT DOMTypedArray<WTF::Uint16Array, v8::Uint16Ar
ray>; |
| 80 template class CORE_TEMPLATE_EXPORT DOMTypedArray<WTF::Uint32Array, v8::Uint32Ar
ray>; | 75 template class CORE_TEMPLATE_EXPORT DOMTypedArray<WTF::Uint32Array, v8::Uint32Ar
ray>; |
| 81 template class CORE_TEMPLATE_EXPORT DOMTypedArray<WTF::Float32Array, v8::Float32
Array>; | 76 template class CORE_TEMPLATE_EXPORT DOMTypedArray<WTF::Float32Array, v8::Float32
Array>; |
| 82 template class CORE_TEMPLATE_EXPORT DOMTypedArray<WTF::Float64Array, v8::Float64
Array>; | 77 template class CORE_TEMPLATE_EXPORT DOMTypedArray<WTF::Float64Array, v8::Float64
Array>; |
| 83 | 78 |
| 84 } // namespace blink | 79 } // namespace blink |
| OLD | NEW |