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

Unified Diff: Source/wtf/ArrayBufferContents.h

Issue 148283013: Blink JavaScript shared memory prototype. Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Tweaks Created 6 years, 7 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/ArrayBuffer.cpp ('k') | Source/wtf/ArrayBufferContents.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
};
« no previous file with comments | « Source/wtf/ArrayBuffer.cpp ('k') | Source/wtf/ArrayBufferContents.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698