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

Side by Side Diff: net/spdy/spdy_pinnable_buffer_piece.h

Issue 266243004: Clang format slam. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
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 NET_SPDY_SPDY_PINNABLE_BUFFER_PIECE_H_ 5 #ifndef NET_SPDY_SPDY_PINNABLE_BUFFER_PIECE_H_
6 #define NET_SPDY_SPDY_PINNABLE_BUFFER_PIECE_H_ 6 #define NET_SPDY_SPDY_PINNABLE_BUFFER_PIECE_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/strings/string_piece.h" 11 #include "base/strings/string_piece.h"
12 #include "net/base/net_export.h" 12 #include "net/base/net_export.h"
13 13
14 namespace net { 14 namespace net {
15 15
16 class SpdyPrefixedBufferReader; 16 class SpdyPrefixedBufferReader;
17 17
18 // Helper class of SpdyPrefixedBufferReader. 18 // Helper class of SpdyPrefixedBufferReader.
19 // Represents a piece of consumed buffer which may (or may not) own its 19 // Represents a piece of consumed buffer which may (or may not) own its
20 // underlying storage. Users may "pin" the buffer at a later time to ensure 20 // underlying storage. Users may "pin" the buffer at a later time to ensure
21 // a SpdyPinnableBufferPiece owns and retains storage of the buffer. 21 // a SpdyPinnableBufferPiece owns and retains storage of the buffer.
22 struct NET_EXPORT_PRIVATE SpdyPinnableBufferPiece { 22 struct NET_EXPORT_PRIVATE SpdyPinnableBufferPiece {
23 public: 23 public:
24 SpdyPinnableBufferPiece(); 24 SpdyPinnableBufferPiece();
25 ~SpdyPinnableBufferPiece(); 25 ~SpdyPinnableBufferPiece();
26 26
27 const char * buffer() const { 27 const char* buffer() const { return buffer_; }
28 return buffer_;
29 }
30 28
31 size_t length() const { 29 size_t length() const { return length_; }
32 return length_;
33 }
34 30
35 operator base::StringPiece() const { 31 operator base::StringPiece() const {
36 return base::StringPiece(buffer_, length_); 32 return base::StringPiece(buffer_, length_);
37 } 33 }
38 34
39 // Allocates and copies the buffer to internal storage. 35 // Allocates and copies the buffer to internal storage.
40 void Pin(); 36 void Pin();
41 37
42 bool IsPinned() const { 38 bool IsPinned() const { return storage_.get() != NULL; }
43 return storage_.get() != NULL;
44 }
45 39
46 // Swaps buffers, including internal storage, with |other|. 40 // Swaps buffers, including internal storage, with |other|.
47 void Swap(SpdyPinnableBufferPiece* other); 41 void Swap(SpdyPinnableBufferPiece* other);
48 42
49 private: 43 private:
50 friend class SpdyPrefixedBufferReader; 44 friend class SpdyPrefixedBufferReader;
51 45
52 const char * buffer_; 46 const char* buffer_;
53 size_t length_; 47 size_t length_;
54 // Null iff |buffer_| isn't pinned. 48 // Null iff |buffer_| isn't pinned.
55 scoped_ptr<char[]> storage_; 49 scoped_ptr<char[]> storage_;
56 }; 50 };
57 51
58 } // namespace net 52 } // namespace net
59 53
60 #endif // NET_SPDY_SPDY_PINNABLE_BUFFER_PIECE_H_ 54 #endif // NET_SPDY_SPDY_PINNABLE_BUFFER_PIECE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698