Chromium Code Reviews| Index: Source/wtf/ArrayBufferContents.cpp |
| diff --git a/Source/wtf/ArrayBufferContents.cpp b/Source/wtf/ArrayBufferContents.cpp |
| index c71d829a4617c865d62bfcc4337d9cfafc69e840..dd264d7925d4d15186d2ed5ca9d4e91ec5d91259 100644 |
| --- a/Source/wtf/ArrayBufferContents.cpp |
| +++ b/Source/wtf/ArrayBufferContents.cpp |
| @@ -34,15 +34,15 @@ |
| namespace WTF { |
| +ArrayBufferContents::AllocationListener ArrayBufferContents::allocationListener; |
| + |
| ArrayBufferContents::ArrayBufferContents() |
| : m_data(0) |
| - , m_sizeInBytes(0) |
| - , m_deallocationObserver(0) { } |
| + , m_sizeInBytes(0) { } |
| ArrayBufferContents::ArrayBufferContents(unsigned numElements, unsigned elementByteSize, ArrayBufferContents::InitializationPolicy policy) |
| : m_data(0) |
| , m_sizeInBytes(0) |
| - , m_deallocationObserver(0) |
| { |
| // Do not allow 32-bit overflow of the total size. |
| if (numElements) { |
| @@ -56,11 +56,9 @@ ArrayBufferContents::ArrayBufferContents(unsigned numElements, unsigned elementB |
| m_sizeInBytes = numElements * elementByteSize; |
| } |
| -ArrayBufferContents::ArrayBufferContents( |
| - void* data, unsigned sizeInBytes, ArrayBufferDeallocationObserver* observer) |
| +ArrayBufferContents::ArrayBufferContents(void* data, unsigned sizeInBytes) |
| : m_data(data) |
| , m_sizeInBytes(sizeInBytes) |
| - , m_deallocationObserver(observer) |
| { |
| if (!m_data) { |
| ASSERT(!m_sizeInBytes); |
| @@ -79,11 +77,8 @@ ArrayBufferContents::~ArrayBufferContents() |
| void ArrayBufferContents::clear() |
| { |
| - if (m_data && m_deallocationObserver) |
| - m_deallocationObserver->arrayBufferDeallocated(m_sizeInBytes); |
| m_data = 0; |
| m_sizeInBytes = 0; |
| - m_deallocationObserver = 0; |
| } |
| void ArrayBufferContents::transfer(ArrayBufferContents& other) |
| @@ -107,14 +102,16 @@ void ArrayBufferContents::copyTo(ArrayBufferContents& other) |
| void ArrayBufferContents::allocateMemory(size_t size, InitializationPolicy policy, void*& data) |
| { |
| + allocationListener(static_cast<int>(size)); |
|
haraken
2015/06/15 17:33:29
Just to confirm: Is 'int' enough?
binji
2015/06/15 19:19:46
I assume so: the DOMArrayBufferDeallocationObserve
|
| data = partitionAllocGenericFlags(WTF::Partitions::getBufferPartition(), PartitionAllocReturnNull, size); |
| if (policy == ZeroInitialize && data) |
| memset(data, '\0', size); |
| } |
| -void ArrayBufferContents::freeMemory(void* data, size_t) |
| +void ArrayBufferContents::freeMemory(void* data, size_t size) |
| { |
| partitionFreeGeneric(WTF::Partitions::getBufferPartition(), data); |
| + allocationListener(-static_cast<int>(size)); |
| } |
| } // namespace WTF |