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

Side by Side Diff: Source/wtf/TypedArrayBase.h

Issue 1180713004: Remove unused code from WTF TypedArrays (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « Source/wtf/Int8Array.h ('k') | Source/wtf/Uint16Array.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2010 Apple Inc. All rights reserved.
3 * Copyright (c) 2010, Google Inc. All rights reserved. 3 * Copyright (c) 2010, Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 } 68 }
69 69
70 // Invoked by the indexed getter. Does not perform range checks; caller 70 // Invoked by the indexed getter. Does not perform range checks; caller
71 // is responsible for doing so and returning undefined as necessary. 71 // is responsible for doing so and returning undefined as necessary.
72 T item(unsigned index) const 72 T item(unsigned index) const
73 { 73 {
74 ASSERT_WITH_SECURITY_IMPLICATION(index < TypedArrayBase<T>::m_length); 74 ASSERT_WITH_SECURITY_IMPLICATION(index < TypedArrayBase<T>::m_length);
75 return TypedArrayBase<T>::data()[index]; 75 return TypedArrayBase<T>::data()[index];
76 } 76 }
77 77
78 bool checkInboundData(unsigned offset, unsigned pos) const
79 {
80 return (offset <= m_length
81 && offset + pos <= m_length
82 // check overflow
83 && offset + pos >= offset);
84 }
85
86 protected: 78 protected:
87 TypedArrayBase(PassRefPtr<ArrayBuffer> buffer, unsigned byteOffset, unsigned length) 79 TypedArrayBase(PassRefPtr<ArrayBuffer> buffer, unsigned byteOffset, unsigned length)
88 : ArrayBufferView(buffer, byteOffset) 80 : ArrayBufferView(buffer, byteOffset)
89 , m_length(length) 81 , m_length(length)
90 { 82 {
91 } 83 }
92 84
93 template <class Subclass> 85 template <class Subclass>
94 static PassRefPtr<Subclass> create(unsigned length) 86 static PassRefPtr<Subclass> create(unsigned length)
95 { 87 {
(...skipping 23 matching lines...) Expand all
119 111
120 template <class Subclass> 112 template <class Subclass>
121 static PassRefPtr<Subclass> createOrNull(unsigned length) 113 static PassRefPtr<Subclass> createOrNull(unsigned length)
122 { 114 {
123 RefPtr<ArrayBuffer> buffer = ArrayBuffer::createOrNull(length, sizeof(T) ); 115 RefPtr<ArrayBuffer> buffer = ArrayBuffer::createOrNull(length, sizeof(T) );
124 if (!buffer) 116 if (!buffer)
125 return nullptr; 117 return nullptr;
126 return create<Subclass>(buffer.release(), 0, length); 118 return create<Subclass>(buffer.release(), 0, length);
127 } 119 }
128 120
129 template <class Subclass>
130 static PassRefPtr<Subclass> createUninitialized(unsigned length)
131 {
132 RefPtr<ArrayBuffer> buffer = ArrayBuffer::createUninitialized(length, si zeof(T));
133 return create<Subclass>(buffer.release(), 0, length);
134 }
135
136 template <class Subclass>
137 PassRefPtr<Subclass> subarrayImpl(int start, int end) const
138 {
139 unsigned offset, length;
140 calculateOffsetAndLength(start, end, m_length, &offset, &length);
141 clampOffsetAndNumElements<T>(buffer(), m_byteOffset, &offset, &length);
142 return create<Subclass>(buffer(), offset, length);
143 }
144
145 virtual void neuter() override final 121 virtual void neuter() override final
146 { 122 {
147 ArrayBufferView::neuter(); 123 ArrayBufferView::neuter();
148 m_length = 0; 124 m_length = 0;
149 } 125 }
150 126
151 // We do not want to have to access this via a virtual function in subclasse s, 127 // We do not want to have to access this via a virtual function in subclasse s,
152 // which is why it is protected rather than private. 128 // which is why it is protected rather than private.
153 unsigned m_length; 129 unsigned m_length;
154 }; 130 };
155 131
156 } // namespace WTF 132 } // namespace WTF
157 133
158 using WTF::TypedArrayBase; 134 using WTF::TypedArrayBase;
159 135
160 #endif // TypedArrayBase_h 136 #endif // TypedArrayBase_h
OLDNEW
« no previous file with comments | « Source/wtf/Int8Array.h ('k') | Source/wtf/Uint16Array.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698