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

Side by Side Diff: net/quic/quic_data_writer.h

Issue 935333002: Update from https://crrev.com/316786 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 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/quic_crypto_server_stream_test.cc ('k') | net/quic/quic_data_writer.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_QUIC_DATA_WRITER_H_ 5 #ifndef NET_QUIC_QUIC_DATA_WRITER_H_
6 #define NET_QUIC_QUIC_DATA_WRITER_H_ 6 #define NET_QUIC_QUIC_DATA_WRITER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/port.h" 12 #include "base/port.h"
13 #include "base/strings/string_piece.h" 13 #include "base/strings/string_piece.h"
14 #include "net/base/int128.h" 14 #include "net/base/int128.h"
15 #include "net/base/net_export.h" 15 #include "net/base/net_export.h"
16 #include "net/quic/quic_protocol.h" 16 #include "net/quic/quic_protocol.h"
17 17
18 namespace net { 18 namespace net {
19 19
20 // This class provides facilities for packing QUIC data. 20 // This class provides facilities for packing QUIC data.
21 // 21 //
22 // The QuicDataWriter supports appending primitive values (int, string, etc) 22 // The QuicDataWriter supports appending primitive values (int, string, etc)
23 // to a frame instance. The QuicDataWriter grows its internal memory buffer 23 // to a frame instance. The internal memory buffer is exposed as the "data"
24 // dynamically to hold the sequence of primitive values. The internal memory 24 // of the QuicDataWriter.
25 // buffer is exposed as the "data" of the QuicDataWriter.
26 class NET_EXPORT_PRIVATE QuicDataWriter { 25 class NET_EXPORT_PRIVATE QuicDataWriter {
27 public: 26 public:
28 explicit QuicDataWriter(size_t length); 27 // Creates a QuicDataWriter where |buffer| is not owned.
28 QuicDataWriter(size_t size, char* buffer);
29 29
30 ~QuicDataWriter(); 30 ~QuicDataWriter();
31 31
32 // Returns the size of the QuicDataWriter's data. 32 // Returns the size of the QuicDataWriter's data.
33 size_t length() const { return length_; } 33 size_t length() const { return length_; }
34 34
35 // Takes the buffer from the QuicDataWriter. 35 // Retrieves the buffer from the QuicDataWriter without changing ownership.
36 char* take(); 36 char* data();
37 37
38 // Methods for adding to the payload. These values are appended to the end 38 // Methods for adding to the payload. These values are appended to the end
39 // of the QuicDataWriter payload. Note - binary integers are written in 39 // of the QuicDataWriter payload. Note - binary integers are written in
40 // host byte order (little endian) not network byte order (big endian). 40 // host byte order (little endian) not network byte order (big endian).
41 bool WriteUInt8(uint8 value); 41 bool WriteUInt8(uint8 value);
42 bool WriteUInt16(uint16 value); 42 bool WriteUInt16(uint16 value);
43 bool WriteUInt32(uint32 value); 43 bool WriteUInt32(uint32 value);
44 bool WriteUInt48(uint64 value); 44 bool WriteUInt48(uint64 value);
45 bool WriteUInt64(uint64 value); 45 bool WriteUInt64(uint64 value);
46 // Write unsigned floating point corresponding to the value. Large values are 46 // Write unsigned floating point corresponding to the value. Large values are
(...skipping 27 matching lines...) Expand all
74 char* buffer_; 74 char* buffer_;
75 size_t capacity_; // Allocation size of payload (or -1 if buffer is const). 75 size_t capacity_; // Allocation size of payload (or -1 if buffer is const).
76 size_t length_; // Current length of the buffer. 76 size_t length_; // Current length of the buffer.
77 77
78 DISALLOW_COPY_AND_ASSIGN(QuicDataWriter); 78 DISALLOW_COPY_AND_ASSIGN(QuicDataWriter);
79 }; 79 };
80 80
81 } // namespace net 81 } // namespace net
82 82
83 #endif // NET_QUIC_QUIC_DATA_WRITER_H_ 83 #endif // NET_QUIC_QUIC_DATA_WRITER_H_
OLDNEW
« no previous file with comments | « net/quic/quic_crypto_server_stream_test.cc ('k') | net/quic/quic_data_writer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698