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

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

Issue 1878463002: Move DOMArrayBuffer, DOMArrayBufferViews and DataView to the heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tidy Created 4 years, 8 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 PassRefPtr<ThisType> create(PassRefPtr<WTFTypedArray> bufferView) 32 static ThisType* create(PassRefPtr<WTFTypedArray> bufferView)
33 { 33 {
34 return adoptRef(new ThisType(bufferView)); 34 return new ThisType(bufferView);
35 } 35 }
36 static PassRefPtr<ThisType> create(unsigned length) 36 static ThisType* create(unsigned length)
37 { 37 {
38 return create(WTFTypedArray::create(length)); 38 return create(WTFTypedArray::create(length));
39 } 39 }
40 static PassRefPtr<ThisType> create(const ValueType* array, unsigned length) 40 static 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 PassRefPtr<ThisType> create(PassRefPtr<WTF::ArrayBuffer> buffer, unsi gned byteOffset, unsigned length) 44 static ThisType* create(PassRefPtr<WTF::ArrayBuffer> buffer, unsigned byteOf fset, unsigned length)
45 { 45 {
46 return create(WTFTypedArray::create(buffer, byteOffset, length)); 46 return create(WTFTypedArray::create(buffer, byteOffset, length));
47 } 47 }
48 static PassRefPtr<ThisType> create(PassRefPtr<DOMArrayBufferBase> prpBuffer, unsigned byteOffset, unsigned length) 48 static ThisType* create(DOMArrayBufferBase *buffer, unsigned byteOffset, uns igned length)
49 { 49 {
50 RefPtr<DOMArrayBufferBase> buffer = prpBuffer;
51 RefPtr<WTFTypedArray> bufferView = WTFTypedArray::create(buffer->buffer( ), byteOffset, length); 50 RefPtr<WTFTypedArray> bufferView = WTFTypedArray::create(buffer->buffer( ), byteOffset, length);
52 return adoptRef(new ThisType(bufferView.release(), buffer.release())); 51 return new ThisType(bufferView.release(), buffer);
53 } 52 }
54 53
55 static PassRefPtr<ThisType> createOrNull(unsigned length) 54 static ThisType* createOrNull(unsigned length)
56 { 55 {
57 RefPtr<WTF::ArrayBuffer> buffer = WTF::ArrayBuffer::createOrNull(length, 1); 56 RefPtr<WTF::ArrayBuffer> buffer = WTF::ArrayBuffer::createOrNull(length, 1);
58 return buffer ? create(buffer.release(), 0, length) : nullptr; 57 return buffer ? create(buffer.release(), 0, length) : nullptr;
59 } 58 }
60 59
61 const WTFTypedArray* view() const { return static_cast<const WTFTypedArray*> (DOMArrayBufferView::view()); } 60 const WTFTypedArray* view() const { return static_cast<const WTFTypedArray*> (DOMArrayBufferView::view()); }
62 WTFTypedArray* view() { return static_cast<WTFTypedArray*>(DOMArrayBufferVie w::view()); } 61 WTFTypedArray* view() { return static_cast<WTFTypedArray*>(DOMArrayBufferVie w::view()); }
63 62
64 ValueType* data() const { return view()->data(); } 63 ValueType* data() const { return view()->data(); }
65 unsigned length() const { return view()->length(); } 64 unsigned length() const { return view()->length(); }
66 // Invoked by the indexed getter. Does not perform range checks; caller 65 // Invoked by the indexed getter. Does not perform range checks; caller
67 // is responsible for doing so and returning undefined as necessary. 66 // is responsible for doing so and returning undefined as necessary.
68 ValueType item(unsigned index) const { return view()->item(index); } 67 ValueType item(unsigned index) const { return view()->item(index); }
69 68
70 v8::Local<v8::Object> wrap(v8::Isolate*, v8::Local<v8::Object> creationConte xt) override; 69 v8::Local<v8::Object> wrap(v8::Isolate*, v8::Local<v8::Object> creationConte xt) override;
71 70
72 private: 71 private:
73 explicit DOMTypedArray(PassRefPtr<WTFTypedArray> bufferView) 72 explicit DOMTypedArray(PassRefPtr<WTFTypedArray> bufferView)
74 : DOMArrayBufferView(bufferView) { } 73 : DOMArrayBufferView(bufferView) { }
75 DOMTypedArray(PassRefPtr<WTFTypedArray> bufferView, PassRefPtr<DOMArrayBuffe rBase> domArrayBuffer) 74 DOMTypedArray(PassRefPtr<WTFTypedArray> bufferView, DOMArrayBufferBase* domA rrayBuffer)
76 : DOMArrayBufferView(bufferView, domArrayBuffer) { } 75 : DOMArrayBufferView(bufferView, domArrayBuffer) { }
77 }; 76 };
78 77
79 extern template class CORE_EXTERN_TEMPLATE_EXPORT DOMTypedArray<WTF::Int8Array, v8::Int8Array>; 78 extern template class CORE_EXTERN_TEMPLATE_EXPORT DOMTypedArray<WTF::Int8Array, v8::Int8Array>;
80 extern template class CORE_EXTERN_TEMPLATE_EXPORT DOMTypedArray<WTF::Int16Array, v8::Int16Array>; 79 extern template class CORE_EXTERN_TEMPLATE_EXPORT DOMTypedArray<WTF::Int16Array, v8::Int16Array>;
81 extern template class CORE_EXTERN_TEMPLATE_EXPORT DOMTypedArray<WTF::Int32Array, v8::Int32Array>; 80 extern template class CORE_EXTERN_TEMPLATE_EXPORT DOMTypedArray<WTF::Int32Array, v8::Int32Array>;
82 extern template class CORE_EXTERN_TEMPLATE_EXPORT DOMTypedArray<WTF::Uint8Array, v8::Uint8Array>; 81 extern template class CORE_EXTERN_TEMPLATE_EXPORT DOMTypedArray<WTF::Uint8Array, v8::Uint8Array>;
83 extern template class CORE_EXTERN_TEMPLATE_EXPORT DOMTypedArray<WTF::Uint8Clampe dArray, v8::Uint8ClampedArray>; 82 extern template class CORE_EXTERN_TEMPLATE_EXPORT DOMTypedArray<WTF::Uint8Clampe dArray, v8::Uint8ClampedArray>;
84 extern template class CORE_EXTERN_TEMPLATE_EXPORT DOMTypedArray<WTF::Uint16Array , v8::Uint16Array>; 83 extern template class CORE_EXTERN_TEMPLATE_EXPORT DOMTypedArray<WTF::Uint16Array , v8::Uint16Array>;
85 extern template class CORE_EXTERN_TEMPLATE_EXPORT DOMTypedArray<WTF::Uint32Array , v8::Uint32Array>; 84 extern template class CORE_EXTERN_TEMPLATE_EXPORT DOMTypedArray<WTF::Uint32Array , v8::Uint32Array>;
86 extern template class CORE_EXTERN_TEMPLATE_EXPORT DOMTypedArray<WTF::Float32Arra y, v8::Float32Array>; 85 extern template class CORE_EXTERN_TEMPLATE_EXPORT DOMTypedArray<WTF::Float32Arra y, v8::Float32Array>;
87 extern template class CORE_EXTERN_TEMPLATE_EXPORT DOMTypedArray<WTF::Float64Arra y, v8::Float64Array>; 86 extern template class CORE_EXTERN_TEMPLATE_EXPORT DOMTypedArray<WTF::Float64Arra y, v8::Float64Array>;
88 87
89 typedef DOMTypedArray<WTF::Int8Array, v8::Int8Array> DOMInt8Array; 88 typedef DOMTypedArray<WTF::Int8Array, v8::Int8Array> DOMInt8Array;
90 typedef DOMTypedArray<WTF::Int16Array, v8::Int16Array> DOMInt16Array; 89 typedef DOMTypedArray<WTF::Int16Array, v8::Int16Array> DOMInt16Array;
91 typedef DOMTypedArray<WTF::Int32Array, v8::Int32Array> DOMInt32Array; 90 typedef DOMTypedArray<WTF::Int32Array, v8::Int32Array> DOMInt32Array;
92 typedef DOMTypedArray<WTF::Uint8Array, v8::Uint8Array> DOMUint8Array; 91 typedef DOMTypedArray<WTF::Uint8Array, v8::Uint8Array> DOMUint8Array;
93 typedef DOMTypedArray<WTF::Uint8ClampedArray, v8::Uint8ClampedArray> DOMUint8Cla mpedArray; 92 typedef DOMTypedArray<WTF::Uint8ClampedArray, v8::Uint8ClampedArray> DOMUint8Cla mpedArray;
94 typedef DOMTypedArray<WTF::Uint16Array, v8::Uint16Array> DOMUint16Array; 93 typedef DOMTypedArray<WTF::Uint16Array, v8::Uint16Array> DOMUint16Array;
95 typedef DOMTypedArray<WTF::Uint32Array, v8::Uint32Array> DOMUint32Array; 94 typedef DOMTypedArray<WTF::Uint32Array, v8::Uint32Array> DOMUint32Array;
96 typedef DOMTypedArray<WTF::Float32Array, v8::Float32Array> DOMFloat32Array; 95 typedef DOMTypedArray<WTF::Float32Array, v8::Float32Array> DOMFloat32Array;
97 typedef DOMTypedArray<WTF::Float64Array, v8::Float64Array> DOMFloat64Array; 96 typedef DOMTypedArray<WTF::Float64Array, v8::Float64Array> DOMFloat64Array;
98 97
99 } // namespace blink 98 } // namespace blink
100 99
101 #endif // DOMTypedArray_h 100 #endif // DOMTypedArray_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698