| OLD | NEW |
| 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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 PassRefPtr<ArrayBuffer> ArrayBuffer::createShared(unsigned numElements, unsigned
elementByteSize, ArrayBufferContents::InitializationPolicy policy) | 167 PassRefPtr<ArrayBuffer> ArrayBuffer::createShared(unsigned numElements, unsigned
elementByteSize, ArrayBufferContents::InitializationPolicy policy) |
| 168 { | 168 { |
| 169 ArrayBufferContents contents(numElements, elementByteSize, ArrayBufferConten
ts::Shared, policy); | 169 ArrayBufferContents contents(numElements, elementByteSize, ArrayBufferConten
ts::Shared, policy); |
| 170 RELEASE_ASSERT(contents.data()); | 170 RELEASE_ASSERT(contents.data()); |
| 171 return adoptRef(new ArrayBuffer(contents)); | 171 return adoptRef(new ArrayBuffer(contents)); |
| 172 } | 172 } |
| 173 | 173 |
| 174 ArrayBuffer::ArrayBuffer(ArrayBufferContents& contents) | 174 ArrayBuffer::ArrayBuffer(ArrayBufferContents& contents) |
| 175 : m_firstView(0), m_isNeutered(false) | 175 : m_firstView(0), m_isNeutered(false) |
| 176 { | 176 { |
| 177 contents.transfer(m_contents); | 177 if (contents.isShared()) |
| 178 contents.shareWith(m_contents); |
| 179 else |
| 180 contents.transfer(m_contents); |
| 178 } | 181 } |
| 179 | 182 |
| 180 void* ArrayBuffer::data() | 183 void* ArrayBuffer::data() |
| 181 { | 184 { |
| 182 return m_contents.data(); | 185 return m_contents.data(); |
| 183 } | 186 } |
| 184 | 187 |
| 185 const void* ArrayBuffer::data() const | 188 const void* ArrayBuffer::data() const |
| 186 { | 189 { |
| 187 return m_contents.data(); | 190 return m_contents.data(); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 214 if (index < 0) | 217 if (index < 0) |
| 215 index = currentLength + index; | 218 index = currentLength + index; |
| 216 return clampValue(index, 0, currentLength); | 219 return clampValue(index, 0, currentLength); |
| 217 } | 220 } |
| 218 | 221 |
| 219 } // namespace WTF | 222 } // namespace WTF |
| 220 | 223 |
| 221 using WTF::ArrayBuffer; | 224 using WTF::ArrayBuffer; |
| 222 | 225 |
| 223 #endif // ArrayBuffer_h | 226 #endif // ArrayBuffer_h |
| OLD | NEW |