| 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_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" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 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 bool WriteUInt128(uint128 value); | 46 bool WriteUInt128(uint128 value); |
| 47 bool WriteStringPiece16(base::StringPiece val); | 47 bool WriteStringPiece16(base::StringPiece val); |
| 48 bool WriteBytes(const void* data, uint32 data_len); | 48 bool WriteBytes(const void* data, uint32 data_len); |
| 49 | 49 |
| 50 static void WriteUint8ToBuffer(uint8 value, char* buffer); |
| 51 static void WriteUint16ToBuffer(uint16 value, char* buffer); |
| 52 static void WriteUint32ToBuffer(uint32 value, char* buffer); |
| 53 static void WriteUint48ToBuffer(uint64 value, char* buffer); |
| 50 static void WriteUint64ToBuffer(uint64 value, char* buffer); | 54 static void WriteUint64ToBuffer(uint64 value, char* buffer); |
| 51 static void WriteUint128ToBuffer(uint128 value, char* buffer); | 55 static void WriteUint128ToBuffer(uint128 value, char* buffer); |
| 52 | 56 |
| 53 size_t capacity() const { | 57 size_t capacity() const { |
| 54 return capacity_; | 58 return capacity_; |
| 55 } | 59 } |
| 56 | 60 |
| 57 protected: | 61 protected: |
| 58 const char* end_of_payload() const { return buffer_ + length_; } | 62 const char* end_of_payload() const { return buffer_ + length_; } |
| 59 | 63 |
| 60 private: | 64 private: |
| 61 // Returns the location that the data should be written at, or NULL if there | 65 // Returns the location that the data should be written at, or NULL if there |
| 62 // is not enough room. Call EndWrite with the returned offset and the given | 66 // is not enough room. Call EndWrite with the returned offset and the given |
| 63 // length to pad out for the next write. | 67 // length to pad out for the next write. |
| 64 char* BeginWrite(size_t length); | 68 char* BeginWrite(size_t length); |
| 65 | 69 |
| 66 char* buffer_; | 70 char* buffer_; |
| 67 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). |
| 68 size_t length_; // Current length of the buffer. | 72 size_t length_; // Current length of the buffer. |
| 69 }; | 73 }; |
| 70 | 74 |
| 71 } // namespace net | 75 } // namespace net |
| 72 | 76 |
| 73 #endif // NET_QUIC_QUIC_DATA_WRITER_H_ | 77 #endif // NET_QUIC_QUIC_DATA_WRITER_H_ |
| OLD | NEW |