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 |
24 DCHECK(!DOMDataStore::containsWrapper(this, isolate)); | 29 DCHECK(!DOMDataStore::containsWrapper(this, isolate)); |
25 | 30 |
26 const WrapperTypeInfo* wrapperTypeInfo = this->wrapperTypeInfo(); | 31 const WrapperTypeInfo* wrapperTypeInfo = this->wrapperTypeInfo(); |
27 DOMArrayBufferBase* buffer = this->bufferBase(); | 32 RefPtr<DOMArrayBufferBase> buffer = this->bufferBase(); |
28 v8::Local<v8::Value> v8Buffer = toV8(buffer, creationContext, isolate); | 33 v8::Local<v8::Value> v8Buffer = toV8(buffer.get(), creationContext, isolate)
; |
29 if (v8Buffer.IsEmpty()) | 34 if (v8Buffer.IsEmpty()) |
30 return v8::Local<v8::Object>(); | 35 return v8::Local<v8::Object>(); |
31 DCHECK_EQ(isShared(), v8Buffer->IsSharedArrayBuffer()); | 36 DCHECK_EQ(isShared(), v8Buffer->IsSharedArrayBuffer()); |
32 | 37 |
33 v8::Local<v8::Object> wrapper; | 38 v8::Local<v8::Object> wrapper; |
34 if (isShared()) { | 39 if (isShared()) { |
35 wrapper = V8TypedArray::New(v8Buffer.As<v8::SharedArrayBuffer>(), byteOf
fset(), length()); | 40 wrapper = V8TypedArray::New(v8Buffer.As<v8::SharedArrayBuffer>(), byteOf
fset(), length()); |
36 } else { | 41 } else { |
37 wrapper = V8TypedArray::New(v8Buffer.As<v8::ArrayBuffer>(), byteOffset()
, length()); | 42 wrapper = V8TypedArray::New(v8Buffer.As<v8::ArrayBuffer>(), byteOffset()
, length()); |
38 } | 43 } |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 template class CORE_TEMPLATE_EXPORT DOMTypedArray<WTF::Int16Array, v8::Int16Arra
y>; | 75 template class CORE_TEMPLATE_EXPORT DOMTypedArray<WTF::Int16Array, v8::Int16Arra
y>; |
71 template class CORE_TEMPLATE_EXPORT DOMTypedArray<WTF::Int32Array, v8::Int32Arra
y>; | 76 template class CORE_TEMPLATE_EXPORT DOMTypedArray<WTF::Int32Array, v8::Int32Arra
y>; |
72 template class CORE_TEMPLATE_EXPORT DOMTypedArray<WTF::Uint8Array, v8::Uint8Arra
y>; | 77 template class CORE_TEMPLATE_EXPORT DOMTypedArray<WTF::Uint8Array, v8::Uint8Arra
y>; |
73 template class CORE_TEMPLATE_EXPORT DOMTypedArray<WTF::Uint8ClampedArray, v8::Ui
nt8ClampedArray>; | 78 template class CORE_TEMPLATE_EXPORT DOMTypedArray<WTF::Uint8ClampedArray, v8::Ui
nt8ClampedArray>; |
74 template class CORE_TEMPLATE_EXPORT DOMTypedArray<WTF::Uint16Array, v8::Uint16Ar
ray>; | 79 template class CORE_TEMPLATE_EXPORT DOMTypedArray<WTF::Uint16Array, v8::Uint16Ar
ray>; |
75 template class CORE_TEMPLATE_EXPORT DOMTypedArray<WTF::Uint32Array, v8::Uint32Ar
ray>; | 80 template class CORE_TEMPLATE_EXPORT DOMTypedArray<WTF::Uint32Array, v8::Uint32Ar
ray>; |
76 template class CORE_TEMPLATE_EXPORT DOMTypedArray<WTF::Float32Array, v8::Float32
Array>; | 81 template class CORE_TEMPLATE_EXPORT DOMTypedArray<WTF::Float32Array, v8::Float32
Array>; |
77 template class CORE_TEMPLATE_EXPORT DOMTypedArray<WTF::Float64Array, v8::Float64
Array>; | 82 template class CORE_TEMPLATE_EXPORT DOMTypedArray<WTF::Float64Array, v8::Float64
Array>; |
78 | 83 |
79 } // namespace blink | 84 } // namespace blink |
OLD | NEW |