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

Unified Diff: Source/wtf/ArrayBufferContents.cpp

Issue 1183763003: Remove ArrayBufferDeallocationObserver (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: s_ prefix 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
« no previous file with comments | « Source/wtf/ArrayBufferContents.h ('k') | Source/wtf/ArrayBufferDeallocationObserver.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/wtf/ArrayBufferContents.cpp
diff --git a/Source/wtf/ArrayBufferContents.cpp b/Source/wtf/ArrayBufferContents.cpp
index c71d829a4617c865d62bfcc4337d9cfafc69e840..1fd9c5248e06104b1650338ff689eaccd5fdc610 100644
--- a/Source/wtf/ArrayBufferContents.cpp
+++ b/Source/wtf/ArrayBufferContents.cpp
@@ -34,15 +34,15 @@
namespace WTF {
+AdjustAmountOfExternalAllocatedMemoryFunction ArrayBufferContents::s_adjustAmountOfExternalAllocatedMemoryFunction;
+
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 (s_adjustAmountOfExternalAllocatedMemoryFunction)
+ s_adjustAmountOfExternalAllocatedMemoryFunction(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 (s_adjustAmountOfExternalAllocatedMemoryFunction)
+ s_adjustAmountOfExternalAllocatedMemoryFunction(-static_cast<int>(size));
}
} // namespace WTF
« no previous file with comments | « Source/wtf/ArrayBufferContents.h ('k') | Source/wtf/ArrayBufferDeallocationObserver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698