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

Side by Side Diff: third_party/WebKit/Source/wtf/ArrayPiece.h

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
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 #ifndef ArrayPiece_h 5 #ifndef ArrayPiece_h
6 #define ArrayPiece_h 6 #define ArrayPiece_h
7 7
8 #include "wtf/Allocator.h" 8 #include "wtf/Allocator.h"
9 #include "wtf/Forward.h" 9 #include "wtf/Forward.h"
10 #include "wtf/WTFExport.h" 10 #include "wtf/WTFExport.h"
11 11
12 namespace WTF { 12 namespace WTF {
13 13
14 // This class is for passing around un-owned bytes as a pointer + length. 14 // This class is for passing around un-owned bytes as a pointer + length.
15 // It supports implicit conversion from several other data types. 15 // It supports implicit conversion from several other data types.
16 // 16 //
17 // ArrayPiece has the concept of being "null". This is different from an empty 17 // ArrayPiece has the concept of being "null". This is different from an empty
18 // byte range. It is invalid to call methods other than isNull() on such 18 // byte range. It is invalid to call methods other than isNull() on such
19 // instances. 19 // instances.
20 // 20 //
21 // IMPORTANT: The data contained by ArrayPiece is NOT OWNED, so caution must be 21 // IMPORTANT: The data contained by ArrayPiece is NOT OWNED, so caution must be
22 // taken to ensure it is kept alive. 22 // taken to ensure it is kept alive.
23 class WTF_EXPORT ArrayPiece { 23 class WTF_EXPORT ArrayPiece {
24 DISALLOW_NEW(); 24 DISALLOW_NEW();
25 public:
26 // Constructs a "null" ArrayPiece object.
27 ArrayPiece();
28 25
29 ArrayPiece(void* data, unsigned byteLength); 26 public:
27 // Constructs a "null" ArrayPiece object.
28 ArrayPiece();
30 29
31 // Constructs an ArrayPiece from the given ArrayBuffer. If the input is a 30 ArrayPiece(void* data, unsigned byteLength);
32 // nullptr, then the constructed instance will be isNull().
33 ArrayPiece(ArrayBuffer*);
34 ArrayPiece(ArrayBufferView*);
35 31
36 bool isNull() const; 32 // Constructs an ArrayPiece from the given ArrayBuffer. If the input is a
37 void* data() const; 33 // nullptr, then the constructed instance will be isNull().
38 unsigned char* bytes() const; 34 ArrayPiece(ArrayBuffer*);
39 unsigned byteLength() const; 35 ArrayPiece(ArrayBufferView*);
40 36
41 protected: 37 bool isNull() const;
42 void initWithData(void* data, unsigned byteLength); 38 void* data() const;
39 unsigned char* bytes() const;
40 unsigned byteLength() const;
43 41
44 private: 42 protected:
45 void initNull(); 43 void initWithData(void* data, unsigned byteLength);
46 44
47 void* m_data; 45 private:
48 unsigned m_byteLength; 46 void initNull();
49 bool m_isNull; 47
48 void* m_data;
49 unsigned m_byteLength;
50 bool m_isNull;
50 }; 51 };
51 52
52 } // namespace WTF 53 } // namespace WTF
53 54
54 using WTF::ArrayPiece; 55 using WTF::ArrayPiece;
55 56
56 #endif // ArrayPiece_h 57 #endif // ArrayPiece_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/wtf/ArrayBufferView.cpp ('k') | third_party/WebKit/Source/wtf/ArrayPiece.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698