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

Unified Diff: Source/wtf/ArrayBufferContents.cpp

Issue 1183763003: Remove ArrayBufferDeallocationObserver (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: move callback to WTF.cpp Created 5 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: Source/wtf/ArrayBufferContents.cpp
diff --git a/Source/wtf/ArrayBufferContents.cpp b/Source/wtf/ArrayBufferContents.cpp
index c71d829a4617c865d62bfcc4337d9cfafc69e840..c5e3227ffcdf944d269f79ed36c580afcbdf76d0 100644
--- a/Source/wtf/ArrayBufferContents.cpp
+++ b/Source/wtf/ArrayBufferContents.cpp
@@ -34,15 +34,15 @@
namespace WTF {
+ArrayBufferAllocationListenerFunction 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,18 @@ void ArrayBufferContents::copyTo(ArrayBufferContents& other)
void ArrayBufferContents::allocateMemory(size_t size, InitializationPolicy policy, void*& data)
{
+ if (allocationListener)
+ allocationListener(static_cast<int>(size));
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);
+ if (allocationListener)
+ allocationListener(-static_cast<int>(size));
}
} // namespace WTF

Powered by Google App Engine
This is Rietveld 408576698