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

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

Issue 2832973003: Split net/spdy into core and chromium subdirectories. (Closed)
Patch Set: Fix some more build rules. Created 3 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
« no previous file with comments | « net/spdy/spdy_no_op_visitor.cc ('k') | net/spdy/spdy_pinnable_buffer_piece.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 NET_SPDY_SPDY_PINNABLE_BUFFER_PIECE_H_
6 #define NET_SPDY_SPDY_PINNABLE_BUFFER_PIECE_H_
7
8 #include <stddef.h>
9
10 #include <memory>
11
12 #include "net/base/net_export.h"
13 #include "net/spdy/platform/api/spdy_string_piece.h"
14
15 namespace net {
16
17 class SpdyPrefixedBufferReader;
18
19 // Helper class of SpdyPrefixedBufferReader.
20 // Represents a piece of consumed buffer which may (or may not) own its
21 // underlying storage. Users may "pin" the buffer at a later time to ensure
22 // a SpdyPinnableBufferPiece owns and retains storage of the buffer.
23 struct NET_EXPORT_PRIVATE SpdyPinnableBufferPiece {
24 public:
25 SpdyPinnableBufferPiece();
26 ~SpdyPinnableBufferPiece();
27
28 const char * buffer() const {
29 return buffer_;
30 }
31
32 size_t length() const {
33 return length_;
34 }
35
36 explicit operator SpdyStringPiece() const {
37 return SpdyStringPiece(buffer_, length_);
38 }
39
40 // Allocates and copies the buffer to internal storage.
41 void Pin();
42
43 bool IsPinned() const { return storage_ != nullptr; }
44
45 // Swaps buffers, including internal storage, with |other|.
46 void Swap(SpdyPinnableBufferPiece* other);
47
48 private:
49 friend class SpdyPrefixedBufferReader;
50
51 const char * buffer_;
52 size_t length_;
53 // Null iff |buffer_| isn't pinned.
54 std::unique_ptr<char[]> storage_;
55 };
56
57 } // namespace net
58
59 #endif // NET_SPDY_SPDY_PINNABLE_BUFFER_PIECE_H_
OLDNEW
« no previous file with comments | « net/spdy/spdy_no_op_visitor.cc ('k') | net/spdy/spdy_pinnable_buffer_piece.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698