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

Side by Side Diff: third_party/WebKit/Source/core/dom/DOMTypedArray.h

Issue 1964183004: Revert of Move DOMArrayBuffer, DOMArrayBufferViews and DataView to the heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 // 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 #ifndef DOMTypedArray_h 5 #ifndef DOMTypedArray_h
6 #define DOMTypedArray_h 6 #define DOMTypedArray_h
7 7
8 #include "bindings/core/v8/ScriptWrappable.h" 8 #include "bindings/core/v8/ScriptWrappable.h"
9 #include "core/CoreExport.h" 9 #include "core/CoreExport.h"
10 #include "core/dom/DOMArrayBufferView.h" 10 #include "core/dom/DOMArrayBufferView.h"
(...skipping 11 matching lines...) Expand all
22 22
23 namespace blink { 23 namespace blink {
24 24
25 template<typename WTFTypedArray, typename V8TypedArray> 25 template<typename WTFTypedArray, typename V8TypedArray>
26 class CORE_TEMPLATE_CLASS_EXPORT DOMTypedArray final : public DOMArrayBufferView { 26 class CORE_TEMPLATE_CLASS_EXPORT DOMTypedArray final : public DOMArrayBufferView {
27 typedef DOMTypedArray<WTFTypedArray, V8TypedArray> ThisType; 27 typedef DOMTypedArray<WTFTypedArray, V8TypedArray> ThisType;
28 DECLARE_WRAPPERTYPEINFO(); 28 DECLARE_WRAPPERTYPEINFO();
29 public: 29 public:
30 typedef typename WTFTypedArray::ValueType ValueType; 30 typedef typename WTFTypedArray::ValueType ValueType;
31 31
32 static ThisType* create(PassRefPtr<WTFTypedArray> bufferView) 32 static PassRefPtr<ThisType> create(PassRefPtr<WTFTypedArray> bufferView)
33 { 33 {
34 return new ThisType(bufferView); 34 return adoptRef(new ThisType(bufferView));
35 } 35 }
36 static ThisType* create(unsigned length) 36 static PassRefPtr<ThisType> create(unsigned length)
37 { 37 {
38 return create(WTFTypedArray::create(length)); 38 return create(WTFTypedArray::create(length));
39 } 39 }
40 static ThisType* create(const ValueType* array, unsigned length) 40 static PassRefPtr<ThisType> create(const ValueType* array, unsigned length)
41 { 41 {
42 return create(WTFTypedArray::create(array, length)); 42 return create(WTFTypedArray::create(array, length));
43 } 43 }
44 static ThisType* create(PassRefPtr<WTF::ArrayBuffer> buffer, unsigned byteOf fset, unsigned length) 44 static PassRefPtr<ThisType> create(PassRefPtr<WTF::ArrayBuffer> buffer, unsi gned byteOffset, unsigned length)
45 { 45 {
46 return create(WTFTypedArray::create(buffer, byteOffset, length)); 46 return create(WTFTypedArray::create(buffer, byteOffset, length));
47 } 47 }
48 static ThisType* create(DOMArrayBufferBase *buffer, unsigned byteOffset, uns igned length) 48 static PassRefPtr<ThisType> create(PassRefPtr<DOMArrayBufferBase> prpBuffer, unsigned byteOffset, unsigned length)
49 { 49 {
50 RefPtr<DOMArrayBufferBase> buffer = prpBuffer;
50 RefPtr<WTFTypedArray> bufferView = WTFTypedArray::create(buffer->buffer( ), byteOffset, length); 51 RefPtr<WTFTypedArray> bufferView = WTFTypedArray::create(buffer->buffer( ), byteOffset, length);
51 return new ThisType(bufferView.release(), buffer); 52 return adoptRef(new ThisType(bufferView.release(), buffer.release()));
52 } 53 }
53 54
54 static ThisType* createOrNull(unsigned length) 55 static PassRefPtr<ThisType> createOrNull(unsigned length)
55 { 56 {
56 RefPtr<WTF::ArrayBuffer> buffer = WTF::ArrayBuffer::createOrNull(length, 1); 57 RefPtr<WTF::ArrayBuffer> buffer = WTF::ArrayBuffer::createOrNull(length, 1);
57 return buffer ? create(buffer.release(), 0, length) : nullptr; 58 return buffer ? create(buffer.release(), 0, length) : nullptr;
58 } 59 }
59 60
60 const WTFTypedArray* view() const { return static_cast<const WTFTypedArray*> (DOMArrayBufferView::view()); } 61 const WTFTypedArray* view() const { return static_cast<const WTFTypedArray*> (DOMArrayBufferView::view()); }
61 WTFTypedArray* view() { return static_cast<WTFTypedArray*>(DOMArrayBufferVie w::view()); } 62 WTFTypedArray* view() { return static_cast<WTFTypedArray*>(DOMArrayBufferVie w::view()); }
62 63
63 ValueType* data() const { return view()->data(); } 64 ValueType* data() const { return view()->data(); }
64 unsigned length() const { return view()->length(); } 65 unsigned length() const { return view()->length(); }
65 // Invoked by the indexed getter. Does not perform range checks; caller 66 // Invoked by the indexed getter. Does not perform range checks; caller
66 // is responsible for doing so and returning undefined as necessary. 67 // is responsible for doing so and returning undefined as necessary.
67 ValueType item(unsigned index) const { return view()->item(index); } 68 ValueType item(unsigned index) const { return view()->item(index); }
68 69
69 v8::Local<v8::Object> wrap(v8::Isolate*, v8::Local<v8::Object> creationConte xt) override; 70 v8::Local<v8::Object> wrap(v8::Isolate*, v8::Local<v8::Object> creationConte xt) override;
70 71
71 private: 72 private:
72 explicit DOMTypedArray(PassRefPtr<WTFTypedArray> bufferView) 73 explicit DOMTypedArray(PassRefPtr<WTFTypedArray> bufferView)
73 : DOMArrayBufferView(bufferView) { } 74 : DOMArrayBufferView(bufferView) { }
74 DOMTypedArray(PassRefPtr<WTFTypedArray> bufferView, DOMArrayBufferBase* domA rrayBuffer) 75 DOMTypedArray(PassRefPtr<WTFTypedArray> bufferView, PassRefPtr<DOMArrayBuffe rBase> domArrayBuffer)
75 : DOMArrayBufferView(bufferView, domArrayBuffer) { } 76 : DOMArrayBufferView(bufferView, domArrayBuffer) { }
76 }; 77 };
77 78
78 extern template class CORE_EXTERN_TEMPLATE_EXPORT DOMTypedArray<WTF::Int8Array, v8::Int8Array>; 79 extern template class CORE_EXTERN_TEMPLATE_EXPORT DOMTypedArray<WTF::Int8Array, v8::Int8Array>;
79 extern template class CORE_EXTERN_TEMPLATE_EXPORT DOMTypedArray<WTF::Int16Array, v8::Int16Array>; 80 extern template class CORE_EXTERN_TEMPLATE_EXPORT DOMTypedArray<WTF::Int16Array, v8::Int16Array>;
80 extern template class CORE_EXTERN_TEMPLATE_EXPORT DOMTypedArray<WTF::Int32Array, v8::Int32Array>; 81 extern template class CORE_EXTERN_TEMPLATE_EXPORT DOMTypedArray<WTF::Int32Array, v8::Int32Array>;
81 extern template class CORE_EXTERN_TEMPLATE_EXPORT DOMTypedArray<WTF::Uint8Array, v8::Uint8Array>; 82 extern template class CORE_EXTERN_TEMPLATE_EXPORT DOMTypedArray<WTF::Uint8Array, v8::Uint8Array>;
82 extern template class CORE_EXTERN_TEMPLATE_EXPORT DOMTypedArray<WTF::Uint8Clampe dArray, v8::Uint8ClampedArray>; 83 extern template class CORE_EXTERN_TEMPLATE_EXPORT DOMTypedArray<WTF::Uint8Clampe dArray, v8::Uint8ClampedArray>;
83 extern template class CORE_EXTERN_TEMPLATE_EXPORT DOMTypedArray<WTF::Uint16Array , v8::Uint16Array>; 84 extern template class CORE_EXTERN_TEMPLATE_EXPORT DOMTypedArray<WTF::Uint16Array , v8::Uint16Array>;
84 extern template class CORE_EXTERN_TEMPLATE_EXPORT DOMTypedArray<WTF::Uint32Array , v8::Uint32Array>; 85 extern template class CORE_EXTERN_TEMPLATE_EXPORT DOMTypedArray<WTF::Uint32Array , v8::Uint32Array>;
85 extern template class CORE_EXTERN_TEMPLATE_EXPORT DOMTypedArray<WTF::Float32Arra y, v8::Float32Array>; 86 extern template class CORE_EXTERN_TEMPLATE_EXPORT DOMTypedArray<WTF::Float32Arra y, v8::Float32Array>;
86 extern template class CORE_EXTERN_TEMPLATE_EXPORT DOMTypedArray<WTF::Float64Arra y, v8::Float64Array>; 87 extern template class CORE_EXTERN_TEMPLATE_EXPORT DOMTypedArray<WTF::Float64Arra y, v8::Float64Array>;
87 88
88 typedef DOMTypedArray<WTF::Int8Array, v8::Int8Array> DOMInt8Array; 89 typedef DOMTypedArray<WTF::Int8Array, v8::Int8Array> DOMInt8Array;
89 typedef DOMTypedArray<WTF::Int16Array, v8::Int16Array> DOMInt16Array; 90 typedef DOMTypedArray<WTF::Int16Array, v8::Int16Array> DOMInt16Array;
90 typedef DOMTypedArray<WTF::Int32Array, v8::Int32Array> DOMInt32Array; 91 typedef DOMTypedArray<WTF::Int32Array, v8::Int32Array> DOMInt32Array;
91 typedef DOMTypedArray<WTF::Uint8Array, v8::Uint8Array> DOMUint8Array; 92 typedef DOMTypedArray<WTF::Uint8Array, v8::Uint8Array> DOMUint8Array;
92 typedef DOMTypedArray<WTF::Uint8ClampedArray, v8::Uint8ClampedArray> DOMUint8Cla mpedArray; 93 typedef DOMTypedArray<WTF::Uint8ClampedArray, v8::Uint8ClampedArray> DOMUint8Cla mpedArray;
93 typedef DOMTypedArray<WTF::Uint16Array, v8::Uint16Array> DOMUint16Array; 94 typedef DOMTypedArray<WTF::Uint16Array, v8::Uint16Array> DOMUint16Array;
94 typedef DOMTypedArray<WTF::Uint32Array, v8::Uint32Array> DOMUint32Array; 95 typedef DOMTypedArray<WTF::Uint32Array, v8::Uint32Array> DOMUint32Array;
95 typedef DOMTypedArray<WTF::Float32Array, v8::Float32Array> DOMFloat32Array; 96 typedef DOMTypedArray<WTF::Float32Array, v8::Float32Array> DOMFloat32Array;
96 typedef DOMTypedArray<WTF::Float64Array, v8::Float64Array> DOMFloat64Array; 97 typedef DOMTypedArray<WTF::Float64Array, v8::Float64Array> DOMFloat64Array;
97 98
98 } // namespace blink 99 } // namespace blink
99 100
100 #endif // DOMTypedArray_h 101 #endif // DOMTypedArray_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/DOMSharedArrayBuffer.cpp ('k') | third_party/WebKit/Source/core/dom/DOMTypedArray.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698