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

Unified Diff: Source/wtf/ArrayBufferContents.cpp

Issue 20804003: Re-land: Ensure that ArrayBuffers actively being used by the Web Audio API cannot be neutered (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebase Created 7 years, 5 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/ArrayBufferView.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 f6c0c0a76c068b8907f54f41926615fc53555b5d..f62734bf8d5613b43965da9569c91c2f088f751c 100644
--- a/Source/wtf/ArrayBufferContents.cpp
+++ b/Source/wtf/ArrayBufferContents.cpp
@@ -28,6 +28,7 @@
#include "wtf/ArrayBufferContents.h"
#include "wtf/ArrayBufferDeallocationObserver.h"
+#include <string.h>
namespace WTF {
@@ -97,6 +98,17 @@ void ArrayBufferContents::transfer(ArrayBufferContents& other)
clear();
}
+void ArrayBufferContents::copyTo(ArrayBufferContents& other)
+{
+ ASSERT(!other.m_sizeInBytes);
+ other.freeMemory(other.m_data);
+ allocateMemory(m_sizeInBytes, DontInitialize, other.m_data);
+ if (!other.m_data)
+ return;
+ memcpy(other.m_data, m_data, m_sizeInBytes);
+ other.m_sizeInBytes = m_sizeInBytes;
+}
+
bool ArrayBufferContents::allocateMemory(size_t size, InitializationPolicy policy, void*& data)
{
if (policy == ZeroInitialize) {
« no previous file with comments | « Source/wtf/ArrayBufferContents.h ('k') | Source/wtf/ArrayBufferView.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698