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

Side by Side Diff: third_party/WebKit/Source/wtf/ArrayPiece.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 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 "wtf/ArrayPiece.h" 5 #include "wtf/ArrayPiece.h"
6 6
7 #include "wtf/ArrayBuffer.h" 7 #include "wtf/ArrayBuffer.h"
8 #include "wtf/ArrayBufferView.h" 8 #include "wtf/ArrayBufferView.h"
9 #include "wtf/Assertions.h" 9 #include "wtf/Assertions.h"
10 10
11 namespace WTF { 11 namespace WTF {
12 12
13 ArrayPiece::ArrayPiece() 13 ArrayPiece::ArrayPiece() {
14 { 14 initNull();
15 initNull();
16 } 15 }
17 16
18 ArrayPiece::ArrayPiece(void* data, unsigned byteLength) 17 ArrayPiece::ArrayPiece(void* data, unsigned byteLength) {
19 { 18 initWithData(data, byteLength);
20 initWithData(data, byteLength);
21 } 19 }
22 20
23 ArrayPiece::ArrayPiece(ArrayBuffer* buffer) 21 ArrayPiece::ArrayPiece(ArrayBuffer* buffer) {
24 { 22 if (buffer) {
25 if (buffer) { 23 initWithData(buffer->data(), buffer->byteLength());
26 initWithData(buffer->data(), buffer->byteLength()); 24 } else {
27 } else { 25 initNull();
28 initNull(); 26 }
29 }
30 } 27 }
31 28
32 ArrayPiece::ArrayPiece(ArrayBufferView* buffer) 29 ArrayPiece::ArrayPiece(ArrayBufferView* buffer) {
33 { 30 if (buffer) {
34 if (buffer) { 31 initWithData(buffer->baseAddress(), buffer->byteLength());
35 initWithData(buffer->baseAddress(), buffer->byteLength()); 32 } else {
36 } else { 33 initNull();
37 initNull(); 34 }
38 }
39 } 35 }
40 36
41 bool ArrayPiece::isNull() const 37 bool ArrayPiece::isNull() const {
42 { 38 return m_isNull;
43 return m_isNull;
44 } 39 }
45 40
46 void* ArrayPiece::data() const 41 void* ArrayPiece::data() const {
47 { 42 ASSERT(!isNull());
48 ASSERT(!isNull()); 43 return m_data;
49 return m_data;
50 } 44 }
51 45
52 unsigned char* ArrayPiece::bytes() const 46 unsigned char* ArrayPiece::bytes() const {
53 { 47 return static_cast<unsigned char*>(data());
54 return static_cast<unsigned char*>(data());
55 } 48 }
56 49
57 unsigned ArrayPiece::byteLength() const 50 unsigned ArrayPiece::byteLength() const {
58 { 51 ASSERT(!isNull());
59 ASSERT(!isNull()); 52 return m_byteLength;
60 return m_byteLength;
61 } 53 }
62 54
63 void ArrayPiece::initWithData(void* data, unsigned byteLength) 55 void ArrayPiece::initWithData(void* data, unsigned byteLength) {
64 { 56 m_byteLength = byteLength;
65 m_byteLength = byteLength; 57 m_data = data;
66 m_data = data; 58 m_isNull = false;
67 m_isNull = false;
68 } 59 }
69 60
70 void ArrayPiece::initNull() 61 void ArrayPiece::initNull() {
71 { 62 m_byteLength = 0;
72 m_byteLength = 0; 63 m_data = 0;
73 m_data = 0; 64 m_isNull = true;
74 m_isNull = true;
75 } 65 }
76 66
77 } // namespace WTF 67 } // 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