OLD | NEW |
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_WRITER_H_ | 5 #ifndef NET_QUIC_CORE_QUIC_DATA_WRITER_H_ |
6 #define NET_QUIC_CORE_QUIC_DATA_WRITER_H_ | 6 #define NET_QUIC_CORE_QUIC_DATA_WRITER_H_ |
7 | 7 |
8 #include <cstddef> | 8 #include <cstddef> |
9 #include <cstdint> | 9 #include <cstdint> |
10 #include <string> | 10 #include <string> |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 // Write unsigned floating point corresponding to the value. Large values are | 46 // Write unsigned floating point corresponding to the value. Large values are |
47 // clamped to the maximum representable (kUFloat16MaxValue). Values that can | 47 // clamped to the maximum representable (kUFloat16MaxValue). Values that can |
48 // not be represented directly are rounded down. | 48 // not be represented directly are rounded down. |
49 bool WriteUFloat16(uint64_t value); | 49 bool WriteUFloat16(uint64_t value); |
50 bool WriteStringPiece16(QuicStringPiece val); | 50 bool WriteStringPiece16(QuicStringPiece val); |
51 bool WriteBytes(const void* data, size_t data_len); | 51 bool WriteBytes(const void* data, size_t data_len); |
52 bool WriteRepeatedByte(uint8_t byte, size_t count); | 52 bool WriteRepeatedByte(uint8_t byte, size_t count); |
53 // Fills the remaining buffer with null characters. | 53 // Fills the remaining buffer with null characters. |
54 void WritePadding(); | 54 void WritePadding(); |
55 | 55 |
| 56 // Write connection ID as a 64-bit unsigned integer to the payload. |
| 57 // TODO(fayang): Remove this method and use WriteUInt64() once deprecating |
| 58 // quic_restart_flag_quic_rw_cid_in_big_endian and QuicDataWriter has a mode |
| 59 // indicating writing in little/big endian. |
| 60 bool WriteConnectionId(uint64_t connection_id); |
| 61 |
56 size_t capacity() const { return capacity_; } | 62 size_t capacity() const { return capacity_; } |
57 | 63 |
58 private: | 64 private: |
59 // Returns the location that the data should be written at, or nullptr if | 65 // Returns the location that the data should be written at, or nullptr if |
60 // there is not enough room. Call EndWrite with the returned offset and the | 66 // there is not enough room. Call EndWrite with the returned offset and the |
61 // given length to pad out for the next write. | 67 // given length to pad out for the next write. |
62 char* BeginWrite(size_t length); | 68 char* BeginWrite(size_t length); |
63 | 69 |
64 char* buffer_; | 70 char* buffer_; |
65 size_t capacity_; // Allocation size of payload (or -1 if buffer is const). | 71 size_t capacity_; // Allocation size of payload (or -1 if buffer is const). |
66 size_t length_; // Current length of the buffer. | 72 size_t length_; // Current length of the buffer. |
67 | 73 |
68 DISALLOW_COPY_AND_ASSIGN(QuicDataWriter); | 74 DISALLOW_COPY_AND_ASSIGN(QuicDataWriter); |
69 }; | 75 }; |
70 | 76 |
71 } // namespace net | 77 } // namespace net |
72 | 78 |
73 #endif // NET_QUIC_CORE_QUIC_DATA_WRITER_H_ | 79 #endif // NET_QUIC_CORE_QUIC_DATA_WRITER_H_ |
OLD | NEW |