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_PACKETS_H_ | 5 #ifndef NET_QUIC_CORE_QUIC_PACKETS_H_ |
6 #define NET_QUIC_CORE_QUIC_PACKETS_H_ | 6 #define NET_QUIC_CORE_QUIC_PACKETS_H_ |
7 | 7 |
8 #include <cstdint> | 8 #include <cstdint> |
9 #include <limits> | 9 #include <limits> |
10 #include <list> | 10 #include <list> |
11 #include <memory> | 11 #include <memory> |
12 #include <ostream> | 12 #include <ostream> |
13 #include <string> | 13 #include <string> |
14 #include <utility> | 14 #include <utility> |
15 #include <vector> | 15 #include <vector> |
16 | 16 |
17 #include "base/macros.h" | 17 #include "base/macros.h" |
18 #include "base/strings/string_piece.h" | |
19 #include "net/base/iovec.h" | 18 #include "net/base/iovec.h" |
20 #include "net/quic/core/frames/quic_frame.h" | 19 #include "net/quic/core/frames/quic_frame.h" |
21 #include "net/quic/core/quic_ack_listener_interface.h" | 20 #include "net/quic/core/quic_ack_listener_interface.h" |
22 #include "net/quic/core/quic_bandwidth.h" | 21 #include "net/quic/core/quic_bandwidth.h" |
23 #include "net/quic/core/quic_constants.h" | 22 #include "net/quic/core/quic_constants.h" |
24 #include "net/quic/core/quic_error_codes.h" | 23 #include "net/quic/core/quic_error_codes.h" |
25 #include "net/quic/core/quic_time.h" | 24 #include "net/quic/core/quic_time.h" |
26 #include "net/quic/core/quic_types.h" | 25 #include "net/quic/core/quic_types.h" |
27 #include "net/quic/core/quic_versions.h" | 26 #include "net/quic/core/quic_versions.h" |
28 #include "net/quic/platform/api/quic_export.h" | 27 #include "net/quic/platform/api/quic_export.h" |
29 #include "net/quic/platform/api/quic_socket_address.h" | 28 #include "net/quic/platform/api/quic_socket_address.h" |
| 29 #include "net/quic/platform/api/quic_string_piece.h" |
30 | 30 |
31 namespace net { | 31 namespace net { |
32 | 32 |
33 class QuicPacket; | 33 class QuicPacket; |
34 struct QuicPacketHeader; | 34 struct QuicPacketHeader; |
35 | 35 |
36 // Size in bytes of the data packet header. | 36 // Size in bytes of the data packet header. |
37 QUIC_EXPORT_PRIVATE size_t GetPacketHeaderSize(QuicVersion version, | 37 QUIC_EXPORT_PRIVATE size_t GetPacketHeaderSize(QuicVersion version, |
38 const QuicPacketHeader& header); | 38 const QuicPacketHeader& header); |
39 | 39 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 }; | 101 }; |
102 | 102 |
103 typedef QuicPacketPublicHeader QuicVersionNegotiationPacket; | 103 typedef QuicPacketPublicHeader QuicVersionNegotiationPacket; |
104 | 104 |
105 class QUIC_EXPORT_PRIVATE QuicData { | 105 class QUIC_EXPORT_PRIVATE QuicData { |
106 public: | 106 public: |
107 QuicData(const char* buffer, size_t length); | 107 QuicData(const char* buffer, size_t length); |
108 QuicData(const char* buffer, size_t length, bool owns_buffer); | 108 QuicData(const char* buffer, size_t length, bool owns_buffer); |
109 virtual ~QuicData(); | 109 virtual ~QuicData(); |
110 | 110 |
111 base::StringPiece AsStringPiece() const { | 111 QuicStringPiece AsStringPiece() const { |
112 return base::StringPiece(data(), length()); | 112 return QuicStringPiece(data(), length()); |
113 } | 113 } |
114 | 114 |
115 const char* data() const { return buffer_; } | 115 const char* data() const { return buffer_; } |
116 size_t length() const { return length_; } | 116 size_t length() const { return length_; } |
117 | 117 |
118 private: | 118 private: |
119 const char* buffer_; | 119 const char* buffer_; |
120 size_t length_; | 120 size_t length_; |
121 bool owns_buffer_; | 121 bool owns_buffer_; |
122 | 122 |
123 DISALLOW_COPY_AND_ASSIGN(QuicData); | 123 DISALLOW_COPY_AND_ASSIGN(QuicData); |
124 }; | 124 }; |
125 | 125 |
126 class QUIC_EXPORT_PRIVATE QuicPacket : public QuicData { | 126 class QUIC_EXPORT_PRIVATE QuicPacket : public QuicData { |
127 public: | 127 public: |
128 // TODO(fayang): 3 fields from public header are passed in as arguments. | 128 // TODO(fayang): 3 fields from public header are passed in as arguments. |
129 // Consider to add a convenience method which directly accepts the entire | 129 // Consider to add a convenience method which directly accepts the entire |
130 // public header. | 130 // public header. |
131 QuicPacket(char* buffer, | 131 QuicPacket(char* buffer, |
132 size_t length, | 132 size_t length, |
133 bool owns_buffer, | 133 bool owns_buffer, |
134 QuicConnectionIdLength connection_id_length, | 134 QuicConnectionIdLength connection_id_length, |
135 bool includes_version, | 135 bool includes_version, |
136 bool includes_diversification_nonce, | 136 bool includes_diversification_nonce, |
137 QuicPacketNumberLength packet_number_length); | 137 QuicPacketNumberLength packet_number_length); |
138 | 138 |
139 base::StringPiece AssociatedData(QuicVersion version) const; | 139 QuicStringPiece AssociatedData(QuicVersion version) const; |
140 base::StringPiece Plaintext(QuicVersion version) const; | 140 QuicStringPiece Plaintext(QuicVersion version) const; |
141 | 141 |
142 char* mutable_data() { return buffer_; } | 142 char* mutable_data() { return buffer_; } |
143 | 143 |
144 private: | 144 private: |
145 char* buffer_; | 145 char* buffer_; |
146 const QuicConnectionIdLength connection_id_length_; | 146 const QuicConnectionIdLength connection_id_length_; |
147 const bool includes_version_; | 147 const bool includes_version_; |
148 const bool includes_diversification_nonce_; | 148 const bool includes_diversification_nonce_; |
149 const QuicPacketNumberLength packet_number_length_; | 149 const QuicPacketNumberLength packet_number_length_; |
150 | 150 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 QUIC_EXPORT_PRIVATE void ClearSerializedPacket( | 248 QUIC_EXPORT_PRIVATE void ClearSerializedPacket( |
249 SerializedPacket* serialized_packet); | 249 SerializedPacket* serialized_packet); |
250 | 250 |
251 // Allocates a new char[] of size |packet.encrypted_length| and copies in | 251 // Allocates a new char[] of size |packet.encrypted_length| and copies in |
252 // |packet.encrypted_buffer|. | 252 // |packet.encrypted_buffer|. |
253 QUIC_EXPORT_PRIVATE char* CopyBuffer(const SerializedPacket& packet); | 253 QUIC_EXPORT_PRIVATE char* CopyBuffer(const SerializedPacket& packet); |
254 | 254 |
255 } // namespace net | 255 } // namespace net |
256 | 256 |
257 #endif // NET_QUIC_CORE_QUIC_PACKETS_H_ | 257 #endif // NET_QUIC_CORE_QUIC_PACKETS_H_ |
OLD | NEW |