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

Unified Diff: third_party/WebKit/Source/wtf/ArrayBufferContents.cpp

Issue 1611343002: wtf reformat test Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: pydent Created 4 years, 11 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: third_party/WebKit/Source/wtf/ArrayBufferContents.cpp
diff --git a/third_party/WebKit/Source/wtf/ArrayBufferContents.cpp b/third_party/WebKit/Source/wtf/ArrayBufferContents.cpp
index e3c4b0e19425b77a9f5ca307e7f10019d2f75d92..67eb01af9a073b2fdd2fe12f6b833fbfb9473b99 100644
--- a/third_party/WebKit/Source/wtf/ArrayBufferContents.cpp
+++ b/third_party/WebKit/Source/wtf/ArrayBufferContents.cpp
@@ -33,137 +33,139 @@
namespace WTF {
-AdjustAmountOfExternalAllocatedMemoryFunction ArrayBufferContents::s_adjustAmountOfExternalAllocatedMemoryFunction;
+AdjustAmountOfExternalAllocatedMemoryFunction
+ ArrayBufferContents::s_adjustAmountOfExternalAllocatedMemoryFunction;
ArrayBufferContents::ArrayBufferContents()
- : m_holder(adoptRef(new DataHolder())) { }
-
-ArrayBufferContents::ArrayBufferContents(unsigned numElements, unsigned elementByteSize, SharingType isShared, ArrayBufferContents::InitializationPolicy policy)
- : m_holder(adoptRef(new DataHolder()))
-{
- // Do not allow 32-bit overflow of the total size.
- unsigned totalSize = numElements * elementByteSize;
- if (numElements) {
- if (totalSize / numElements != elementByteSize) {
- return;
- }
- }
-
- m_holder->allocateNew(totalSize, isShared, policy);
-}
+ : m_holder(adoptRef(new DataHolder())) {}
ArrayBufferContents::ArrayBufferContents(
- void* data, unsigned sizeInBytes, SharingType isShared)
- : m_holder(adoptRef(new DataHolder()))
-{
- if (data) {
- m_holder->adopt(data, sizeInBytes, isShared);
- } else {
- ASSERT(!sizeInBytes);
- sizeInBytes = 0;
- // Allow null data if size is 0 bytes, make sure data is valid pointer.
- // (PartitionAlloc guarantees valid pointer for size 0)
- m_holder->allocateNew(sizeInBytes, isShared, ZeroInitialize);
+ unsigned numElements,
+ unsigned elementByteSize,
+ SharingType isShared,
+ ArrayBufferContents::InitializationPolicy policy)
+ : m_holder(adoptRef(new DataHolder())) {
+ // Do not allow 32-bit overflow of the total size.
+ unsigned totalSize = numElements * elementByteSize;
+ if (numElements) {
+ if (totalSize / numElements != elementByteSize) {
+ return;
}
+ }
+
+ m_holder->allocateNew(totalSize, isShared, policy);
}
-ArrayBufferContents::~ArrayBufferContents()
-{
+ArrayBufferContents::ArrayBufferContents(void* data,
+ unsigned sizeInBytes,
+ SharingType isShared)
+ : m_holder(adoptRef(new DataHolder())) {
+ if (data) {
+ m_holder->adopt(data, sizeInBytes, isShared);
+ } else {
+ ASSERT(!sizeInBytes);
+ sizeInBytes = 0;
+ // Allow null data if size is 0 bytes, make sure data is valid pointer.
+ // (PartitionAlloc guarantees valid pointer for size 0)
+ m_holder->allocateNew(sizeInBytes, isShared, ZeroInitialize);
+ }
}
-void ArrayBufferContents::neuter()
-{
- m_holder.clear();
+ArrayBufferContents::~ArrayBufferContents() {}
+
+void ArrayBufferContents::neuter() {
+ m_holder.clear();
}
-void ArrayBufferContents::transfer(ArrayBufferContents& other)
-{
- ASSERT(!isShared());
- ASSERT(!other.m_holder->data());
- other.m_holder = m_holder;
- neuter();
+void ArrayBufferContents::transfer(ArrayBufferContents& other) {
+ ASSERT(!isShared());
+ ASSERT(!other.m_holder->data());
+ other.m_holder = m_holder;
+ neuter();
}
-void ArrayBufferContents::shareWith(ArrayBufferContents& other)
-{
- ASSERT(isShared());
- ASSERT(!other.m_holder->data());
- other.m_holder = m_holder;
+void ArrayBufferContents::shareWith(ArrayBufferContents& other) {
+ ASSERT(isShared());
+ ASSERT(!other.m_holder->data());
+ other.m_holder = m_holder;
}
-void ArrayBufferContents::copyTo(ArrayBufferContents& other)
-{
- ASSERT(!m_holder->isShared() && !other.m_holder->isShared());
- m_holder->copyMemoryTo(*other.m_holder);
+void ArrayBufferContents::copyTo(ArrayBufferContents& other) {
+ ASSERT(!m_holder->isShared() && !other.m_holder->isShared());
+ m_holder->copyMemoryTo(*other.m_holder);
}
-void ArrayBufferContents::allocateMemoryWithFlags(size_t size, InitializationPolicy policy, int flags, void*& data)
-{
- if (s_adjustAmountOfExternalAllocatedMemoryFunction)
- s_adjustAmountOfExternalAllocatedMemoryFunction(static_cast<int>(size));
- data = partitionAllocGenericFlags(WTF::Partitions::bufferPartition(), flags, size, WTF_HEAP_PROFILER_TYPE_NAME(ArrayBufferContents));
- if (policy == ZeroInitialize && data)
- memset(data, '\0', size);
+void ArrayBufferContents::allocateMemoryWithFlags(size_t size,
+ InitializationPolicy policy,
+ int flags,
+ void*& data) {
+ if (s_adjustAmountOfExternalAllocatedMemoryFunction)
+ s_adjustAmountOfExternalAllocatedMemoryFunction(static_cast<int>(size));
+ data = partitionAllocGenericFlags(
+ WTF::Partitions::bufferPartition(), flags, size,
+ WTF_HEAP_PROFILER_TYPE_NAME(ArrayBufferContents));
+ if (policy == ZeroInitialize && data)
+ memset(data, '\0', size);
}
-void ArrayBufferContents::allocateMemory(size_t size, InitializationPolicy policy, void*& data)
-{
- allocateMemoryWithFlags(size, policy, 0, data);
+void ArrayBufferContents::allocateMemory(size_t size,
+ InitializationPolicy policy,
+ void*& data) {
+ allocateMemoryWithFlags(size, policy, 0, data);
}
-void ArrayBufferContents::allocateMemoryOrNull(size_t size, InitializationPolicy policy, void*& data)
-{
- allocateMemoryWithFlags(size, policy, PartitionAllocReturnNull, data);
+void ArrayBufferContents::allocateMemoryOrNull(size_t size,
+ InitializationPolicy policy,
+ void*& data) {
+ allocateMemoryWithFlags(size, policy, PartitionAllocReturnNull, data);
}
-void ArrayBufferContents::freeMemory(void* data, size_t size)
-{
- Partitions::bufferFree(data);
- if (s_adjustAmountOfExternalAllocatedMemoryFunction)
- s_adjustAmountOfExternalAllocatedMemoryFunction(-static_cast<int>(size));
+void ArrayBufferContents::freeMemory(void* data, size_t size) {
+ Partitions::bufferFree(data);
+ if (s_adjustAmountOfExternalAllocatedMemoryFunction)
+ s_adjustAmountOfExternalAllocatedMemoryFunction(-static_cast<int>(size));
}
ArrayBufferContents::DataHolder::DataHolder()
- : m_data(nullptr)
- , m_sizeInBytes(0)
- , m_isShared(NotShared) { }
+ : m_data(nullptr), m_sizeInBytes(0), m_isShared(NotShared) {}
-ArrayBufferContents::DataHolder::~DataHolder()
-{
- ArrayBufferContents::freeMemory(m_data, m_sizeInBytes);
+ArrayBufferContents::DataHolder::~DataHolder() {
+ ArrayBufferContents::freeMemory(m_data, m_sizeInBytes);
- m_data = nullptr;
- m_sizeInBytes = 0;
- m_isShared = NotShared;
+ m_data = nullptr;
+ m_sizeInBytes = 0;
+ m_isShared = NotShared;
}
-void ArrayBufferContents::DataHolder::allocateNew(unsigned sizeInBytes, SharingType isShared, InitializationPolicy policy)
-{
- ASSERT(!m_data);
- void* data = nullptr;
- allocateMemory(sizeInBytes, policy, data);
- m_data = data;
- m_sizeInBytes = data ? sizeInBytes : 0;
- m_isShared = isShared;
+void ArrayBufferContents::DataHolder::allocateNew(unsigned sizeInBytes,
+ SharingType isShared,
+ InitializationPolicy policy) {
+ ASSERT(!m_data);
+ void* data = nullptr;
+ allocateMemory(sizeInBytes, policy, data);
+ m_data = data;
+ m_sizeInBytes = data ? sizeInBytes : 0;
+ m_isShared = isShared;
}
-void ArrayBufferContents::DataHolder::adopt(void* data, unsigned sizeInBytes, SharingType isShared)
-{
- ASSERT(!m_data);
- m_data = data;
- m_sizeInBytes = sizeInBytes;
- m_isShared = isShared;
+void ArrayBufferContents::DataHolder::adopt(void* data,
+ unsigned sizeInBytes,
+ SharingType isShared) {
+ ASSERT(!m_data);
+ m_data = data;
+ m_sizeInBytes = sizeInBytes;
+ m_isShared = isShared;
}
-void ArrayBufferContents::DataHolder::copyMemoryTo(DataHolder& other)
-{
- ASSERT(!other.m_sizeInBytes);
- ArrayBufferContents::freeMemory(other.m_data, other.m_sizeInBytes);
- ArrayBufferContents::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;
+void ArrayBufferContents::DataHolder::copyMemoryTo(DataHolder& other) {
+ ASSERT(!other.m_sizeInBytes);
+ ArrayBufferContents::freeMemory(other.m_data, other.m_sizeInBytes);
+ ArrayBufferContents::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;
}
-} // namespace WTF
+} // namespace WTF
« no previous file with comments | « third_party/WebKit/Source/wtf/ArrayBufferContents.h ('k') | third_party/WebKit/Source/wtf/ArrayBufferView.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698