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

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

Issue 1436153002: Apply clang-format with Chromium-style without column limit. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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 6a75a5286cab13c5500cc63fc5ea893edf6dd0e7..5c7352c6d47bc68b69cc1145f8a29d794b25be54 100644
--- a/third_party/WebKit/Source/wtf/ArrayBufferContents.cpp
+++ b/third_party/WebKit/Source/wtf/ArrayBufferContents.cpp
@@ -37,124 +37,111 @@ namespace WTF {
AdjustAmountOfExternalAllocatedMemoryFunction ArrayBufferContents::s_adjustAmountOfExternalAllocatedMemoryFunction;
ArrayBufferContents::ArrayBufferContents()
- : m_holder(adoptRef(new DataHolder())) { }
+ : 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(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->allocateNew(totalSize, isShared, policy);
}
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* 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);
+ }
}
-ArrayBufferContents::~ArrayBufferContents()
-{
+ArrayBufferContents::~ArrayBufferContents() {
}
-void ArrayBufferContents::neuter()
-{
- m_holder.clear();
+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::allocateMemory(size_t size, InitializationPolicy policy, void*& data)
-{
- if (s_adjustAmountOfExternalAllocatedMemoryFunction)
- s_adjustAmountOfExternalAllocatedMemoryFunction(static_cast<int>(size));
- data = partitionAllocGeneric(WTF::Partitions::bufferPartition(), size);
- if (policy == ZeroInitialize && data)
- memset(data, '\0', size);
+void ArrayBufferContents::allocateMemory(size_t size, InitializationPolicy policy, void*& data) {
+ if (s_adjustAmountOfExternalAllocatedMemoryFunction)
+ s_adjustAmountOfExternalAllocatedMemoryFunction(static_cast<int>(size));
+ data = partitionAllocGeneric(WTF::Partitions::bufferPartition(), size);
+ if (policy == ZeroInitialize && data)
+ memset(data, '\0', size);
}
-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