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

Side by Side Diff: net/quic/core/quic_data_reader.h

Issue 2740453006: Add QuicStringPiece which is actually StringPiece. (Closed)
Patch Set: fix compile error and rebase Created 3 years, 9 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/quic/core/quic_crypto_stream.cc ('k') | net/quic/core/quic_data_reader.cc » ('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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_QUIC_CORE_QUIC_DATA_READER_H_ 5 #ifndef NET_QUIC_CORE_QUIC_DATA_READER_H_
6 #define NET_QUIC_CORE_QUIC_DATA_READER_H_ 6 #define NET_QUIC_CORE_QUIC_DATA_READER_H_
7 7
8 #include <cstddef> 8 #include <cstddef>
9 #include <cstdint> 9 #include <cstdint>
10 10
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/strings/string_piece.h"
13 #include "net/base/int128.h" 12 #include "net/base/int128.h"
14 #include "net/quic/platform/api/quic_export.h" 13 #include "net/quic/platform/api/quic_export.h"
14 #include "net/quic/platform/api/quic_string_piece.h"
15 15
16 namespace net { 16 namespace net {
17 17
18 // Used for reading QUIC data. Though there isn't really anything terribly 18 // Used for reading QUIC data. Though there isn't really anything terribly
19 // QUIC-specific here, it's a helper class that's useful when doing QUIC 19 // QUIC-specific here, it's a helper class that's useful when doing QUIC
20 // framing. 20 // framing.
21 // 21 //
22 // To use, simply construct a QuicDataReader using the underlying buffer that 22 // To use, simply construct a QuicDataReader using the underlying buffer that
23 // you'd like to read fields from, then call one of the Read*() methods to 23 // you'd like to read fields from, then call one of the Read*() methods to
24 // actually do some reading. 24 // actually do some reading.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 // Returns true on success, false otherwise. 57 // Returns true on success, false otherwise.
58 bool ReadUFloat16(uint64_t* result); 58 bool ReadUFloat16(uint64_t* result);
59 59
60 // Reads a string prefixed with 16-bit length into the given output parameter. 60 // Reads a string prefixed with 16-bit length into the given output parameter.
61 // 61 //
62 // NOTE: Does not copy but rather references strings in the underlying buffer. 62 // NOTE: Does not copy but rather references strings in the underlying buffer.
63 // This should be kept in mind when handling memory management! 63 // This should be kept in mind when handling memory management!
64 // 64 //
65 // Forwards the internal iterator on success. 65 // Forwards the internal iterator on success.
66 // Returns true on success, false otherwise. 66 // Returns true on success, false otherwise.
67 bool ReadStringPiece16(base::StringPiece* result); 67 bool ReadStringPiece16(QuicStringPiece* result);
68 68
69 // Reads a given number of bytes into the given buffer. The buffer 69 // Reads a given number of bytes into the given buffer. The buffer
70 // must be of adequate size. 70 // must be of adequate size.
71 // Forwards the internal iterator on success. 71 // Forwards the internal iterator on success.
72 // Returns true on success, false otherwise. 72 // Returns true on success, false otherwise.
73 bool ReadStringPiece(base::StringPiece* result, size_t len); 73 bool ReadStringPiece(QuicStringPiece* result, size_t len);
74 74
75 // Returns the remaining payload as a StringPiece. 75 // Returns the remaining payload as a QuicStringPiece.
76 // 76 //
77 // NOTE: Does not copy but rather references strings in the underlying buffer. 77 // NOTE: Does not copy but rather references strings in the underlying buffer.
78 // This should be kept in mind when handling memory management! 78 // This should be kept in mind when handling memory management!
79 // 79 //
80 // Forwards the internal iterator. 80 // Forwards the internal iterator.
81 base::StringPiece ReadRemainingPayload(); 81 QuicStringPiece ReadRemainingPayload();
82 82
83 // Returns the remaining payload as a StringPiece. 83 // Returns the remaining payload as a QuicStringPiece.
84 // 84 //
85 // NOTE: Does not copy but rather references strings in the underlying buffer. 85 // NOTE: Does not copy but rather references strings in the underlying buffer.
86 // This should be kept in mind when handling memory management! 86 // This should be kept in mind when handling memory management!
87 // 87 //
88 // DOES NOT forward the internal iterator. 88 // DOES NOT forward the internal iterator.
89 base::StringPiece PeekRemainingPayload(); 89 QuicStringPiece PeekRemainingPayload();
90 90
91 // Reads a given number of bytes into the given buffer. The buffer 91 // Reads a given number of bytes into the given buffer. The buffer
92 // must be of adequate size. 92 // must be of adequate size.
93 // Forwards the internal iterator on success. 93 // Forwards the internal iterator on success.
94 // Returns true on success, false otherwise. 94 // Returns true on success, false otherwise.
95 bool ReadBytes(void* result, size_t size); 95 bool ReadBytes(void* result, size_t size);
96 96
97 // Returns true if the entirety of the underlying buffer has been read via 97 // Returns true if the entirety of the underlying buffer has been read via
98 // Read*() calls. 98 // Read*() calls.
99 bool IsDoneReading() const; 99 bool IsDoneReading() const;
(...skipping 17 matching lines...) Expand all
117 117
118 // The location of the next read from our data buffer. 118 // The location of the next read from our data buffer.
119 size_t pos_; 119 size_t pos_;
120 120
121 DISALLOW_COPY_AND_ASSIGN(QuicDataReader); 121 DISALLOW_COPY_AND_ASSIGN(QuicDataReader);
122 }; 122 };
123 123
124 } // namespace net 124 } // namespace net
125 125
126 #endif // NET_QUIC_CORE_QUIC_DATA_READER_H_ 126 #endif // NET_QUIC_CORE_QUIC_DATA_READER_H_
OLDNEW
« no previous file with comments | « net/quic/core/quic_crypto_stream.cc ('k') | net/quic/core/quic_data_reader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698