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

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

Issue 1875343002: Move WTF classes related to typed arrays to wtf/typed_arrays (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef ArrayPiece_h
6 #define ArrayPiece_h
7
8 #include "wtf/Allocator.h"
9 #include "wtf/Forward.h"
10 #include "wtf/WTFExport.h"
11
12 namespace WTF {
13
14 // This class is for passing around un-owned bytes as a pointer + length.
15 // It supports implicit conversion from several other data types.
16 //
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
19 // instances.
20 //
21 // IMPORTANT: The data contained by ArrayPiece is NOT OWNED, so caution must be
22 // taken to ensure it is kept alive.
23 class WTF_EXPORT ArrayPiece {
24 DISALLOW_NEW();
25 public:
26 // Constructs a "null" ArrayPiece object.
27 ArrayPiece();
28
29 ArrayPiece(void* data, unsigned byteLength);
30
31 // Constructs an ArrayPiece from the given ArrayBuffer. If the input is a
32 // nullptr, then the constructed instance will be isNull().
33 ArrayPiece(ArrayBuffer*);
34 ArrayPiece(ArrayBufferView*);
35
36 bool isNull() const;
37 void* data() const;
38 unsigned char* bytes() const;
39 unsigned byteLength() const;
40
41 protected:
42 void initWithData(void* data, unsigned byteLength);
43
44 private:
45 void initNull();
46
47 void* m_data;
48 unsigned m_byteLength;
49 bool m_isNull;
50 };
51
52 } // namespace WTF
53
54 using WTF::ArrayPiece;
55
56 #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