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

Unified Diff: Source/wtf/ArrayBuffer.cpp

Issue 1186863005: Add a ref-counted data holder to ArrayBufferContents (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: type in ArrayBuffer::shareContentsWith 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/ArrayBuffer.cpp
diff --git a/Source/wtf/ArrayBuffer.cpp b/Source/wtf/ArrayBuffer.cpp
index cfbdc9de1418bca9204a2a7a94e37116d28251ac..21eafab9d65bc3465a270e27e2043dd9c6b16a67 100644
--- a/Source/wtf/ArrayBuffer.cpp
+++ b/Source/wtf/ArrayBuffer.cpp
@@ -33,10 +33,11 @@ namespace WTF {
bool ArrayBuffer::transfer(ArrayBufferContents& result)
{
+ ASSERT(!isShared());
RefPtr<ArrayBuffer> keepAlive(this);
if (!m_contents.data()) {
- result.clear();
+ result.neuter();
return false;
}
@@ -66,6 +67,20 @@ bool ArrayBuffer::transfer(ArrayBufferContents& result)
return true;
}
+bool ArrayBuffer::shareContentsWith(ArrayBufferContents& result)
+{
+ ASSERT(isShared());
+ RefPtr<ArrayBuffer> keepAlive(this);
+
+ if (!m_contents.data()) {
+ result.neuter();
+ return false;
+ }
+
+ m_contents.shareWith(result);
+ return true;
+}
+
void ArrayBuffer::addView(ArrayBufferView* view)
{
view->m_buffer = this;

Powered by Google App Engine
This is Rietveld 408576698