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

Unified Diff: Source/wtf/ArrayBufferContents.h

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.h
diff --git a/Source/wtf/ArrayBufferContents.h b/Source/wtf/ArrayBufferContents.h
index 4bd137f02ce984f0fe9c70f30e1564b269498f7a..cff8f7b0d6498310c493eacae1be5290a892f2a9 100644
--- a/Source/wtf/ArrayBufferContents.h
+++ b/Source/wtf/ArrayBufferContents.h
@@ -27,8 +27,9 @@
#ifndef ArrayBufferContents_h
#define ArrayBufferContents_h
-#include "wtf/ArrayBufferDeallocationObserver.h"
+#include "wtf/Assertions.h"
#include "wtf/Noncopyable.h"
+#include "wtf/WTF.h"
#include "wtf/WTFExport.h"
namespace WTF {
@@ -49,7 +50,7 @@ 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);
~ArrayBufferContents();
@@ -58,30 +59,21 @@ public:
void* data() const { return m_data; }
unsigned sizeInBytes() const { return m_sizeInBytes; }
- void setDeallocationObserver(ArrayBufferDeallocationObserver& observer)
- {
- if (!m_deallocationObserver) {
- m_deallocationObserver = &observer;
- m_deallocationObserver->blinkAllocatedMemory(m_sizeInBytes);
- }
- }
- void setDeallocationObserverWithoutAllocationNotification(ArrayBufferDeallocationObserver& observer)
- {
- if (!m_deallocationObserver) {
- m_deallocationObserver = &observer;
- }
- }
-
void transfer(ArrayBufferContents& other);
void copyTo(ArrayBufferContents& other);
static void allocateMemory(size_t, InitializationPolicy, void*&);
static void freeMemory(void*, size_t);
+ static void setAllocationListener(ArrayBufferAllocationListenerFunction listener)
+ {
+ ASSERT(!allocationListener);
+ allocationListener = listener;
+ }
private:
void* m_data;
unsigned m_sizeInBytes;
- ArrayBufferDeallocationObserver* m_deallocationObserver;
+ static ArrayBufferAllocationListenerFunction allocationListener;
};
} // namespace WTF

Powered by Google App Engine
This is Rietveld 408576698