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

Side by Side Diff: third_party/WebKit/Source/wtf/ArrayBuffer.h

Issue 1845923005: CL for perf tryjob on android Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/wtf/BitArray.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) 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2009 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 PassRefPtr<ArrayBuffer> ArrayBuffer::create(ArrayBuffer* other) 107 PassRefPtr<ArrayBuffer> ArrayBuffer::create(ArrayBuffer* other)
108 { 108 {
109 // TODO(binji): support creating a SharedArrayBuffer by copying another Arra yBuffer? 109 // TODO(binji): support creating a SharedArrayBuffer by copying another Arra yBuffer?
110 ASSERT(!other->isShared()); 110 ASSERT(!other->isShared());
111 return ArrayBuffer::create(other->data(), other->byteLength()); 111 return ArrayBuffer::create(other->data(), other->byteLength());
112 } 112 }
113 113
114 PassRefPtr<ArrayBuffer> ArrayBuffer::create(const void* source, unsigned byteLen gth) 114 PassRefPtr<ArrayBuffer> ArrayBuffer::create(const void* source, unsigned byteLen gth)
115 { 115 {
116 ArrayBufferContents contents(byteLength, 1, ArrayBufferContents::NotShared, ArrayBufferContents::ZeroInitialize); 116 ArrayBufferContents contents(byteLength, 1, ArrayBufferContents::NotShared, ArrayBufferContents::ZeroInitialize);
117 CHECK(contents.data()); 117 RELEASE_ASSERT(contents.data());
118 RefPtr<ArrayBuffer> buffer = adoptRef(new ArrayBuffer(contents)); 118 RefPtr<ArrayBuffer> buffer = adoptRef(new ArrayBuffer(contents));
119 memcpy(buffer->data(), source, byteLength); 119 memcpy(buffer->data(), source, byteLength);
120 return buffer.release(); 120 return buffer.release();
121 } 121 }
122 122
123 PassRefPtr<ArrayBuffer> ArrayBuffer::create(ArrayBufferContents& contents) 123 PassRefPtr<ArrayBuffer> ArrayBuffer::create(ArrayBufferContents& contents)
124 { 124 {
125 CHECK(contents.data()); 125 RELEASE_ASSERT(contents.data());
126 return adoptRef(new ArrayBuffer(contents)); 126 return adoptRef(new ArrayBuffer(contents));
127 } 127 }
128 128
129 PassRefPtr<ArrayBuffer> ArrayBuffer::createOrNull(unsigned numElements, unsigned elementByteSize) 129 PassRefPtr<ArrayBuffer> ArrayBuffer::createOrNull(unsigned numElements, unsigned elementByteSize)
130 { 130 {
131 return createOrNull(numElements, elementByteSize, ArrayBufferContents::ZeroI nitialize); 131 return createOrNull(numElements, elementByteSize, ArrayBufferContents::ZeroI nitialize);
132 } 132 }
133 133
134 PassRefPtr<ArrayBuffer> ArrayBuffer::createUninitialized(unsigned numElements, u nsigned elementByteSize) 134 PassRefPtr<ArrayBuffer> ArrayBuffer::createUninitialized(unsigned numElements, u nsigned elementByteSize)
135 { 135 {
136 return create(numElements, elementByteSize, ArrayBufferContents::DontInitial ize); 136 return create(numElements, elementByteSize, ArrayBufferContents::DontInitial ize);
137 } 137 }
138 138
139 PassRefPtr<ArrayBuffer> ArrayBuffer::create(unsigned numElements, unsigned eleme ntByteSize, ArrayBufferContents::InitializationPolicy policy) 139 PassRefPtr<ArrayBuffer> ArrayBuffer::create(unsigned numElements, unsigned eleme ntByteSize, ArrayBufferContents::InitializationPolicy policy)
140 { 140 {
141 ArrayBufferContents contents(numElements, elementByteSize, ArrayBufferConten ts::NotShared, policy); 141 ArrayBufferContents contents(numElements, elementByteSize, ArrayBufferConten ts::NotShared, policy);
142 CHECK(contents.data()); 142 RELEASE_ASSERT(contents.data());
143 return adoptRef(new ArrayBuffer(contents)); 143 return adoptRef(new ArrayBuffer(contents));
144 } 144 }
145 145
146 PassRefPtr<ArrayBuffer> ArrayBuffer::createOrNull(unsigned numElements, unsigned elementByteSize, ArrayBufferContents::InitializationPolicy policy) 146 PassRefPtr<ArrayBuffer> ArrayBuffer::createOrNull(unsigned numElements, unsigned elementByteSize, ArrayBufferContents::InitializationPolicy policy)
147 { 147 {
148 ArrayBufferContents contents(numElements, elementByteSize, ArrayBufferConten ts::NotShared, policy); 148 ArrayBufferContents contents(numElements, elementByteSize, ArrayBufferConten ts::NotShared, policy);
149 if (!contents.data()) 149 if (!contents.data())
150 return nullptr; 150 return nullptr;
151 return adoptRef(new ArrayBuffer(contents)); 151 return adoptRef(new ArrayBuffer(contents));
152 } 152 }
153 153
154 PassRefPtr<ArrayBuffer> ArrayBuffer::createShared(unsigned numElements, unsigned elementByteSize) 154 PassRefPtr<ArrayBuffer> ArrayBuffer::createShared(unsigned numElements, unsigned elementByteSize)
155 { 155 {
156 return createShared(numElements, elementByteSize, ArrayBufferContents::ZeroI nitialize); 156 return createShared(numElements, elementByteSize, ArrayBufferContents::ZeroI nitialize);
157 } 157 }
158 158
159 PassRefPtr<ArrayBuffer> ArrayBuffer::createShared(const void* source, unsigned b yteLength) 159 PassRefPtr<ArrayBuffer> ArrayBuffer::createShared(const void* source, unsigned b yteLength)
160 { 160 {
161 ArrayBufferContents contents(byteLength, 1, ArrayBufferContents::Shared, Arr ayBufferContents::ZeroInitialize); 161 ArrayBufferContents contents(byteLength, 1, ArrayBufferContents::Shared, Arr ayBufferContents::ZeroInitialize);
162 CHECK(contents.data()); 162 RELEASE_ASSERT(contents.data());
163 RefPtr<ArrayBuffer> buffer = adoptRef(new ArrayBuffer(contents)); 163 RefPtr<ArrayBuffer> buffer = adoptRef(new ArrayBuffer(contents));
164 memcpy(buffer->data(), source, byteLength); 164 memcpy(buffer->data(), source, byteLength);
165 return buffer.release(); 165 return buffer.release();
166 } 166 }
167 167
168 PassRefPtr<ArrayBuffer> ArrayBuffer::createShared(unsigned numElements, unsigned elementByteSize, ArrayBufferContents::InitializationPolicy policy) 168 PassRefPtr<ArrayBuffer> ArrayBuffer::createShared(unsigned numElements, unsigned elementByteSize, ArrayBufferContents::InitializationPolicy policy)
169 { 169 {
170 ArrayBufferContents contents(numElements, elementByteSize, ArrayBufferConten ts::Shared, policy); 170 ArrayBufferContents contents(numElements, elementByteSize, ArrayBufferConten ts::Shared, policy);
171 CHECK(contents.data()); 171 RELEASE_ASSERT(contents.data());
172 return adoptRef(new ArrayBuffer(contents)); 172 return adoptRef(new ArrayBuffer(contents));
173 } 173 }
174 174
175 ArrayBuffer::ArrayBuffer(ArrayBufferContents& contents) 175 ArrayBuffer::ArrayBuffer(ArrayBufferContents& contents)
176 : m_firstView(0), m_isNeutered(false) 176 : m_firstView(0), m_isNeutered(false)
177 { 177 {
178 if (contents.isShared()) 178 if (contents.isShared())
179 contents.shareWith(m_contents); 179 contents.shareWith(m_contents);
180 else 180 else
181 contents.transfer(m_contents); 181 contents.transfer(m_contents);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 if (index < 0) 218 if (index < 0)
219 index = currentLength + index; 219 index = currentLength + index;
220 return clampValue(index, 0, currentLength); 220 return clampValue(index, 0, currentLength);
221 } 221 }
222 222
223 } // namespace WTF 223 } // namespace WTF
224 224
225 using WTF::ArrayBuffer; 225 using WTF::ArrayBuffer;
226 226
227 #endif // ArrayBuffer_h 227 #endif // ArrayBuffer_h
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/wtf/BitArray.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698