| 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 // Some helpers for quic. | 5 // Some helpers for quic. |
| 6 | 6 |
| 7 #ifndef NET_QUIC_QUIC_UTILS_H_ | 7 #ifndef NET_QUIC_QUIC_UTILS_H_ |
| 8 #define NET_QUIC_QUIC_UTILS_H_ | 8 #define NET_QUIC_QUIC_UTILS_H_ |
| 9 | 9 |
| 10 #include <stddef.h> | 10 #include <stddef.h> |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 | 113 |
| 114 // Deletes and clears all the frames and the packet from serialized packet. | 114 // Deletes and clears all the frames and the packet from serialized packet. |
| 115 static void ClearSerializedPacket(SerializedPacket* serialized_packet); | 115 static void ClearSerializedPacket(SerializedPacket* serialized_packet); |
| 116 | 116 |
| 117 // Returns a packed representation of |path_id| and |packet_number| in which | 117 // Returns a packed representation of |path_id| and |packet_number| in which |
| 118 // the highest byte is set to |path_id| and the lower 7 bytes are the lower | 118 // the highest byte is set to |path_id| and the lower 7 bytes are the lower |
| 119 // 7 bytes of |packet_number|. | 119 // 7 bytes of |packet_number|. |
| 120 static uint64_t PackPathIdAndPacketNumber(QuicPathId path_id, | 120 static uint64_t PackPathIdAndPacketNumber(QuicPathId path_id, |
| 121 QuicPacketNumber packet_number); | 121 QuicPacketNumber packet_number); |
| 122 | 122 |
| 123 // Allocates a new char[] of size |packet.encrypted_length| and copies in |
| 124 // |packet.encrypted_buffer|. |
| 125 static char* CopyBuffer(const SerializedPacket& packet); |
| 126 |
| 123 private: | 127 private: |
| 124 DISALLOW_COPY_AND_ASSIGN(QuicUtils); | 128 DISALLOW_COPY_AND_ASSIGN(QuicUtils); |
| 125 }; | 129 }; |
| 126 | 130 |
| 127 // Utility function that returns an QuicIOVector object wrapped around |str|. | 131 // Utility function that returns an QuicIOVector object wrapped around |str|. |
| 128 // |str|'s data is stored in |iov|. | 132 // |str|'s data is stored in |iov|. |
| 129 inline QuicIOVector MakeIOVector(base::StringPiece str, struct iovec* iov) { | 133 inline QuicIOVector MakeIOVector(base::StringPiece str, struct iovec* iov) { |
| 130 iov->iov_base = const_cast<char*>(str.data()); | 134 iov->iov_base = const_cast<char*>(str.data()); |
| 131 iov->iov_len = static_cast<size_t>(str.size()); | 135 iov->iov_len = static_cast<size_t>(str.size()); |
| 132 QuicIOVector quic_iov(iov, 1, str.size()); | 136 QuicIOVector quic_iov(iov, 1, str.size()); |
| 133 return quic_iov; | 137 return quic_iov; |
| 134 } | 138 } |
| 135 | 139 |
| 136 } // namespace net | 140 } // namespace net |
| 137 | 141 |
| 138 #endif // NET_QUIC_QUIC_UTILS_H_ | 142 #endif // NET_QUIC_QUIC_UTILS_H_ |
| OLD | NEW |