| Index: Source/wtf/ArrayBufferContents.h
|
| diff --git a/Source/wtf/ArrayBufferContents.h b/Source/wtf/ArrayBufferContents.h
|
| index edd5ef7346567a8f06f3a99f18cd14608fa84786..ff8b00e276fc2e412d6149c1ac80a55f50685d04 100644
|
| --- a/Source/wtf/ArrayBufferContents.h
|
| +++ b/Source/wtf/ArrayBufferContents.h
|
| @@ -29,10 +29,25 @@
|
|
|
| #include "wtf/ArrayBufferDeallocationObserver.h"
|
| #include "wtf/Noncopyable.h"
|
| +#include "wtf/RefPtr.h"
|
| +#include "wtf/ThreadSafeRefCounted.h"
|
| #include "wtf/WTFExport.h"
|
|
|
| namespace WTF {
|
|
|
| +class DataHolder : public ThreadSafeRefCounted<DataHolder> {
|
| + WTF_MAKE_NONCOPYABLE(DataHolder);
|
| +public:
|
| + DataHolder();
|
| + ~DataHolder();
|
| +
|
| + void adopt(void* data, unsigned sizeInBytes, bool shared);
|
| +
|
| + void* m_data;
|
| + unsigned m_sizeInBytes;
|
| + bool m_shared;
|
| +};
|
| +
|
| class WTF_EXPORT ArrayBufferContents {
|
| WTF_MAKE_NONCOPYABLE(ArrayBufferContents);
|
| public:
|
| @@ -49,20 +64,21 @@ public:
|
| // upon destruction.
|
| // This constructor will not call observer->StartObserving(), so it is a responsibility
|
| // of the caller to make sure JS knows about external memory.
|
| - ArrayBufferContents(void* data, unsigned sizeInBytes, ArrayBufferDeallocationObserver*);
|
| + ArrayBufferContents(void* data, unsigned sizeInBytes, bool shared, ArrayBufferDeallocationObserver*);
|
|
|
| ~ArrayBufferContents();
|
|
|
| void clear();
|
|
|
| - void* data() const { return m_data; }
|
| - unsigned sizeInBytes() const { return m_sizeInBytes; }
|
| + void* data() const { return m_holder->m_data; }
|
| + unsigned sizeInBytes() const { return m_holder->m_sizeInBytes; }
|
| + bool shared() const { return m_holder->m_shared; }
|
|
|
| void setDeallocationObserver(ArrayBufferDeallocationObserver* observer)
|
| {
|
| if (!m_deallocationObserver) {
|
| m_deallocationObserver = observer;
|
| - m_deallocationObserver->blinkAllocatedMemory(m_sizeInBytes);
|
| + m_deallocationObserver->blinkAllocatedMemory(m_holder->m_sizeInBytes);
|
| }
|
| }
|
|
|
| @@ -73,8 +89,7 @@ public:
|
| static void freeMemory(void*, size_t);
|
|
|
| private:
|
| - void* m_data;
|
| - unsigned m_sizeInBytes;
|
| + RefPtr<DataHolder> m_holder;
|
| ArrayBufferDeallocationObserver* m_deallocationObserver;
|
| };
|
|
|
|
|