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

Unified Diff: Source/wtf/ArrayBuffer.h

Issue 1532413002: Added Dartium changes onto 45.0.2454.104 (Closed) Base URL: http://src.chromium.org/blink/branches/chromium/2454
Patch Set: Created 5 years 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/platform/MIMETypeRegistry.cpp ('k') | Source/wtf/ArrayBufferContents.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/wtf/ArrayBuffer.h
diff --git a/Source/wtf/ArrayBuffer.h b/Source/wtf/ArrayBuffer.h
index d83dd2e7b062e91cdb907ccfa14a9849bc79ea71..675ee57f47d47b6dcf400e3b3df16db8b5b28f7d 100644
--- a/Source/wtf/ArrayBuffer.h
+++ b/Source/wtf/ArrayBuffer.h
@@ -44,6 +44,16 @@ public:
static inline PassRefPtr<ArrayBuffer> create(const void* source, unsigned byteLength);
static inline PassRefPtr<ArrayBuffer> create(ArrayBufferContents&);
+ // Create an ArrayBuffer for an existing piece of memory with no copying.
+ // The ArrayBuffer does not take ownership of the passed-in memory and care
+ // must be taken to not deallocate the data before the ArrayBuffer has been
+ // deallocated.
+ //
+ // FIXME: This should be removed when pointers into the JS/Dart heap can
+ // can be passed directly.
+ static inline PassRefPtr<ArrayBuffer> createNoCopy(void* source, unsigned byteLength);
+
+ // Only for use by Uint8ClampedArray::createUninitialized and SharedBuffer::getAsArrayBuffer.
static inline PassRefPtr<ArrayBuffer> createOrNull(unsigned numElements, unsigned elementByteSize);
// Only for use by XMLHttpRequest::responseArrayBuffer and Internals::serializeObject
@@ -120,6 +130,13 @@ PassRefPtr<ArrayBuffer> ArrayBuffer::create(const void* source, unsigned byteLen
return buffer.release();
}
+PassRefPtr<ArrayBuffer> ArrayBuffer::createNoCopy(void* source, unsigned byteLength)
+{
+ // FIXME: What do we pass in for a DeallocationObserver?
+ ArrayBufferContents contents(source, byteLength, ArrayBufferContents::SharingType::NotShared);
+ return adoptRef(new ArrayBuffer(contents));
+}
+
PassRefPtr<ArrayBuffer> ArrayBuffer::create(ArrayBufferContents& contents)
{
RELEASE_ASSERT(contents.data());
@@ -175,7 +192,10 @@ PassRefPtr<ArrayBuffer> ArrayBuffer::createShared(unsigned numElements, unsigned
ArrayBuffer::ArrayBuffer(ArrayBufferContents& contents)
: m_firstView(0), m_isNeutered(false)
{
- contents.transfer(m_contents);
+ if (contents.isShared())
+ contents.shareWith(m_contents);
+ else
+ contents.transfer(m_contents);
}
void* ArrayBuffer::data()
« no previous file with comments | « Source/platform/MIMETypeRegistry.cpp ('k') | Source/wtf/ArrayBufferContents.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698