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

Side by Side Diff: third_party/WebKit/Source/wtf/ArrayPiece.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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/wtf/ArrayPiece.h ('k') | third_party/WebKit/Source/wtf/Assertions.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "wtf/ArrayPiece.h" 6 #include "wtf/ArrayPiece.h"
7 7
8 #include "wtf/ArrayBuffer.h" 8 #include "wtf/ArrayBuffer.h"
9 #include "wtf/ArrayBufferView.h" 9 #include "wtf/ArrayBufferView.h"
10 #include "wtf/Assertions.h" 10 #include "wtf/Assertions.h"
11 11
12 namespace WTF { 12 namespace WTF {
13 13
14 ArrayPiece::ArrayPiece() 14 ArrayPiece::ArrayPiece() {
15 { 15 initNull();
16 initNull();
17 } 16 }
18 17
19 ArrayPiece::ArrayPiece(void* data, unsigned byteLength) 18 ArrayPiece::ArrayPiece(void* data, unsigned byteLength) {
20 { 19 initWithData(data, byteLength);
21 initWithData(data, byteLength);
22 } 20 }
23 21
24 ArrayPiece::ArrayPiece(ArrayBuffer* buffer) 22 ArrayPiece::ArrayPiece(ArrayBuffer* buffer) {
25 { 23 if (buffer) {
26 if (buffer) { 24 initWithData(buffer->data(), buffer->byteLength());
27 initWithData(buffer->data(), buffer->byteLength()); 25 } else {
28 } else { 26 initNull();
29 initNull(); 27 }
30 }
31 } 28 }
32 29
33 ArrayPiece::ArrayPiece(ArrayBufferView* buffer) 30 ArrayPiece::ArrayPiece(ArrayBufferView* buffer) {
34 { 31 if (buffer) {
35 if (buffer) { 32 initWithData(buffer->baseAddress(), buffer->byteLength());
36 initWithData(buffer->baseAddress(), buffer->byteLength()); 33 } else {
37 } else { 34 initNull();
38 initNull(); 35 }
39 }
40 } 36 }
41 37
42 bool ArrayPiece::isNull() const 38 bool ArrayPiece::isNull() const {
43 { 39 return m_isNull;
44 return m_isNull;
45 } 40 }
46 41
47 void* ArrayPiece::data() const 42 void* ArrayPiece::data() const {
48 { 43 ASSERT(!isNull());
49 ASSERT(!isNull()); 44 return m_data;
50 return m_data;
51 } 45 }
52 46
53 unsigned char* ArrayPiece::bytes() const 47 unsigned char* ArrayPiece::bytes() const {
54 { 48 return static_cast<unsigned char*>(data());
55 return static_cast<unsigned char*>(data());
56 } 49 }
57 50
58 unsigned ArrayPiece::byteLength() const 51 unsigned ArrayPiece::byteLength() const {
59 { 52 ASSERT(!isNull());
60 ASSERT(!isNull()); 53 return m_byteLength;
61 return m_byteLength;
62 } 54 }
63 55
64 void ArrayPiece::initWithData(void* data, unsigned byteLength) 56 void ArrayPiece::initWithData(void* data, unsigned byteLength) {
65 { 57 m_byteLength = byteLength;
66 m_byteLength = byteLength; 58 m_data = data;
67 m_data = data; 59 m_isNull = false;
68 m_isNull = false;
69 } 60 }
70 61
71 void ArrayPiece::initNull() 62 void ArrayPiece::initNull() {
72 { 63 m_byteLength = 0;
73 m_byteLength = 0; 64 m_data = 0;
74 m_data = 0; 65 m_isNull = true;
75 m_isNull = true;
76 } 66 }
77 67
78 } // namespace WTF 68 } // namespace WTF
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/wtf/ArrayPiece.h ('k') | third_party/WebKit/Source/wtf/Assertions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698