| Index: Source/wtf/ArrayBuffer.h
|
| diff --git a/Source/wtf/ArrayBuffer.h b/Source/wtf/ArrayBuffer.h
|
| index e8a737c8fcd3680cd6f5945a17a28713de15060a..66252161bb4762230c8f4177092a2724c9958fe8 100644
|
| --- a/Source/wtf/ArrayBuffer.h
|
| +++ b/Source/wtf/ArrayBuffer.h
|
| @@ -50,6 +50,9 @@ public:
|
| // (through DOMArrayBuffer::createUninitialized).
|
| static inline PassRefPtr<ArrayBuffer> createUninitialized(unsigned numElements, unsigned elementByteSize);
|
|
|
| + static inline PassRefPtr<ArrayBuffer> createShared(unsigned numElements, unsigned elementByteSize);
|
| + static inline PassRefPtr<ArrayBuffer> createShared(const void* source, unsigned byteLength);
|
| +
|
| inline void* data();
|
| inline const void* data() const;
|
| inline unsigned byteLength() const;
|
| @@ -63,7 +66,8 @@ public:
|
| void removeView(ArrayBufferView*);
|
|
|
| bool transfer(ArrayBufferContents&);
|
| - bool isNeutered() { return m_isNeutered; }
|
| + bool isNeutered() const { return m_isNeutered; }
|
| + bool isShared() const { return m_contents.isShared(); }
|
|
|
| ~ArrayBuffer() { }
|
|
|
| @@ -73,6 +77,7 @@ protected:
|
| private:
|
| static inline PassRefPtr<ArrayBuffer> create(unsigned numElements, unsigned elementByteSize, ArrayBufferContents::InitializationPolicy);
|
| static inline PassRefPtr<ArrayBuffer> createOrNull(unsigned numElements, unsigned elementByteSize, ArrayBufferContents::InitializationPolicy);
|
| + static inline PassRefPtr<ArrayBuffer> createShared(unsigned numElements, unsigned elementByteSize, ArrayBufferContents::InitializationPolicy);
|
|
|
| inline PassRefPtr<ArrayBuffer> sliceImpl(unsigned begin, unsigned end) const;
|
| inline unsigned clampIndex(int index) const;
|
| @@ -100,12 +105,14 @@ PassRefPtr<ArrayBuffer> ArrayBuffer::create(unsigned numElements, unsigned eleme
|
|
|
| PassRefPtr<ArrayBuffer> ArrayBuffer::create(ArrayBuffer* other)
|
| {
|
| + // TODO(binji): support creating a SharedArrayBuffer by copying another ArrayBuffer?
|
| + ASSERT(!other->isShared());
|
| return ArrayBuffer::create(other->data(), other->byteLength());
|
| }
|
|
|
| PassRefPtr<ArrayBuffer> ArrayBuffer::create(const void* source, unsigned byteLength)
|
| {
|
| - ArrayBufferContents contents(byteLength, 1, ArrayBufferContents::ZeroInitialize);
|
| + ArrayBufferContents contents(byteLength, 1, ArrayBufferContents::NotShared, ArrayBufferContents::ZeroInitialize);
|
| RELEASE_ASSERT(contents.data());
|
| RefPtr<ArrayBuffer> buffer = adoptRef(new ArrayBuffer(contents));
|
| memcpy(buffer->data(), source, byteLength);
|
| @@ -129,19 +136,40 @@ PassRefPtr<ArrayBuffer> ArrayBuffer::createUninitialized(unsigned numElements, u
|
|
|
| PassRefPtr<ArrayBuffer> ArrayBuffer::create(unsigned numElements, unsigned elementByteSize, ArrayBufferContents::InitializationPolicy policy)
|
| {
|
| - ArrayBufferContents contents(numElements, elementByteSize, policy);
|
| + ArrayBufferContents contents(numElements, elementByteSize, ArrayBufferContents::NotShared, policy);
|
| RELEASE_ASSERT(contents.data());
|
| return adoptRef(new ArrayBuffer(contents));
|
| }
|
|
|
| PassRefPtr<ArrayBuffer> ArrayBuffer::createOrNull(unsigned numElements, unsigned elementByteSize, ArrayBufferContents::InitializationPolicy policy)
|
| {
|
| - ArrayBufferContents contents(numElements, elementByteSize, policy);
|
| + ArrayBufferContents contents(numElements, elementByteSize, ArrayBufferContents::NotShared, policy);
|
| if (!contents.data())
|
| return nullptr;
|
| return adoptRef(new ArrayBuffer(contents));
|
| }
|
|
|
| +PassRefPtr<ArrayBuffer> ArrayBuffer::createShared(unsigned numElements, unsigned elementByteSize)
|
| +{
|
| + return createShared(numElements, elementByteSize, ArrayBufferContents::ZeroInitialize);
|
| +}
|
| +
|
| +PassRefPtr<ArrayBuffer> ArrayBuffer::createShared(const void* source, unsigned byteLength)
|
| +{
|
| + ArrayBufferContents contents(byteLength, 1, ArrayBufferContents::Shared, ArrayBufferContents::ZeroInitialize);
|
| + RELEASE_ASSERT(contents.data());
|
| + RefPtr<ArrayBuffer> buffer = adoptRef(new ArrayBuffer(contents));
|
| + memcpy(buffer->data(), source, byteLength);
|
| + return buffer.release();
|
| +}
|
| +
|
| +PassRefPtr<ArrayBuffer> ArrayBuffer::createShared(unsigned numElements, unsigned elementByteSize, ArrayBufferContents::InitializationPolicy policy)
|
| +{
|
| + ArrayBufferContents contents(numElements, elementByteSize, ArrayBufferContents::Shared, policy);
|
| + RELEASE_ASSERT(contents.data());
|
| + return adoptRef(new ArrayBuffer(contents));
|
| +}
|
| +
|
| ArrayBuffer::ArrayBuffer(ArrayBufferContents& contents)
|
| : m_firstView(0), m_isNeutered(false)
|
| {
|
|
|