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_PROTOCOL_H_ | 5 #ifndef NET_QUIC_QUIC_PROTOCOL_H_ |
6 #define NET_QUIC_QUIC_PROTOCOL_H_ | 6 #define NET_QUIC_QUIC_PROTOCOL_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 #include <limits> | 10 #include <limits> |
11 #include <list> | 11 #include <list> |
12 #include <map> | 12 #include <map> |
13 #include <ostream> | 13 #include <ostream> |
14 #include <set> | 14 #include <set> |
15 #include <string> | 15 #include <string> |
16 #include <utility> | 16 #include <utility> |
17 #include <vector> | 17 #include <vector> |
18 | 18 |
19 #include "base/basictypes.h" | 19 #include "base/basictypes.h" |
20 #include "base/containers/hash_tables.h" | 20 #include "base/containers/hash_tables.h" |
21 #include "base/logging.h" | 21 #include "base/logging.h" |
| 22 #include "base/memory/scoped_ptr.h" |
22 #include "base/strings/string_piece.h" | 23 #include "base/strings/string_piece.h" |
23 #include "net/base/int128.h" | 24 #include "net/base/int128.h" |
24 #include "net/base/iovec.h" | 25 #include "net/base/iovec.h" |
25 #include "net/base/ip_endpoint.h" | 26 #include "net/base/ip_endpoint.h" |
26 #include "net/base/net_export.h" | 27 #include "net/base/net_export.h" |
27 #include "net/quic/interval_set.h" | 28 #include "net/quic/interval_set.h" |
28 #include "net/quic/quic_bandwidth.h" | 29 #include "net/quic/quic_bandwidth.h" |
29 #include "net/quic/quic_time.h" | 30 #include "net/quic/quic_time.h" |
30 #include "net/quic/quic_types.h" | 31 #include "net/quic/quic_types.h" |
31 | 32 |
(...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
689 | 690 |
690 // A ping frame contains no payload, though it is retransmittable, | 691 // A ping frame contains no payload, though it is retransmittable, |
691 // and ACK'd just like other normal frames. | 692 // and ACK'd just like other normal frames. |
692 struct NET_EXPORT_PRIVATE QuicPingFrame { | 693 struct NET_EXPORT_PRIVATE QuicPingFrame { |
693 }; | 694 }; |
694 | 695 |
695 // A path MTU discovery frame contains no payload and is serialized as a ping | 696 // A path MTU discovery frame contains no payload and is serialized as a ping |
696 // frame. | 697 // frame. |
697 struct NET_EXPORT_PRIVATE QuicMtuDiscoveryFrame {}; | 698 struct NET_EXPORT_PRIVATE QuicMtuDiscoveryFrame {}; |
698 | 699 |
| 700 typedef scoped_ptr<char[]> UniqueStreamBuffer; |
| 701 |
| 702 // Allocates memory of size |size| for a QUIC stream buffer. |
| 703 UniqueStreamBuffer NewStreamBuffer(size_t size); |
| 704 |
699 struct NET_EXPORT_PRIVATE QuicStreamFrame { | 705 struct NET_EXPORT_PRIVATE QuicStreamFrame { |
700 QuicStreamFrame(); | 706 QuicStreamFrame(); |
701 QuicStreamFrame(const QuicStreamFrame& frame); | 707 QuicStreamFrame(const QuicStreamFrame& frame); |
702 QuicStreamFrame(QuicStreamId stream_id, | 708 QuicStreamFrame(QuicStreamId stream_id, |
703 bool fin, | 709 bool fin, |
704 QuicStreamOffset offset, | 710 QuicStreamOffset offset, |
705 base::StringPiece data); | 711 base::StringPiece data); |
706 | 712 |
707 NET_EXPORT_PRIVATE friend std::ostream& operator<<( | 713 NET_EXPORT_PRIVATE friend std::ostream& operator<<( |
708 std::ostream& os, const QuicStreamFrame& s); | 714 std::ostream& os, const QuicStreamFrame& s); |
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1101 }; | 1107 }; |
1102 | 1108 |
1103 class NET_EXPORT_PRIVATE RetransmittableFrames { | 1109 class NET_EXPORT_PRIVATE RetransmittableFrames { |
1104 public: | 1110 public: |
1105 explicit RetransmittableFrames(EncryptionLevel level); | 1111 explicit RetransmittableFrames(EncryptionLevel level); |
1106 ~RetransmittableFrames(); | 1112 ~RetransmittableFrames(); |
1107 | 1113 |
1108 // Takes ownership of the frame inside |frame|. | 1114 // Takes ownership of the frame inside |frame|. |
1109 const QuicFrame& AddFrame(const QuicFrame& frame); | 1115 const QuicFrame& AddFrame(const QuicFrame& frame); |
1110 // Takes ownership of the frame inside |frame| and |buffer|. | 1116 // Takes ownership of the frame inside |frame| and |buffer|. |
1111 const QuicFrame& AddFrame(const QuicFrame& frame, char* buffer); | 1117 const QuicFrame& AddFrame(const QuicFrame& frame, UniqueStreamBuffer buffer); |
1112 // Removes all stream frames associated with |stream_id|. | 1118 // Removes all stream frames associated with |stream_id|. |
1113 void RemoveFramesForStream(QuicStreamId stream_id); | 1119 void RemoveFramesForStream(QuicStreamId stream_id); |
1114 | 1120 |
1115 const QuicFrames& frames() const { return frames_; } | 1121 const QuicFrames& frames() const { return frames_; } |
1116 | 1122 |
1117 IsHandshake HasCryptoHandshake() const { | 1123 IsHandshake HasCryptoHandshake() const { |
1118 return has_crypto_handshake_; | 1124 return has_crypto_handshake_; |
1119 } | 1125 } |
1120 | 1126 |
1121 EncryptionLevel encryption_level() const { | 1127 EncryptionLevel encryption_level() const { |
1122 return encryption_level_; | 1128 return encryption_level_; |
1123 } | 1129 } |
1124 | 1130 |
1125 bool needs_padding() const { return needs_padding_; } | 1131 bool needs_padding() const { return needs_padding_; } |
1126 | 1132 |
1127 void set_needs_padding(bool needs_padding) { needs_padding_ = needs_padding; } | 1133 void set_needs_padding(bool needs_padding) { needs_padding_ = needs_padding; } |
1128 | 1134 |
1129 private: | 1135 private: |
1130 QuicFrames frames_; | 1136 QuicFrames frames_; |
1131 const EncryptionLevel encryption_level_; | 1137 const EncryptionLevel encryption_level_; |
1132 IsHandshake has_crypto_handshake_; | 1138 IsHandshake has_crypto_handshake_; |
1133 bool needs_padding_; | 1139 bool needs_padding_; |
1134 // Data referenced by the StringPiece of a QuicStreamFrame. | 1140 // Data referenced by the StringPiece of a QuicStreamFrame. |
| 1141 // |
| 1142 // TODO(rtenneti): Change const char* to UniqueStreamBuffer once chrome has |
| 1143 // c++11 library support. |
| 1144 // std::vector<UniqueStreamBuffer> stream_data_; |
1135 std::vector<const char*> stream_data_; | 1145 std::vector<const char*> stream_data_; |
1136 | 1146 |
1137 DISALLOW_COPY_AND_ASSIGN(RetransmittableFrames); | 1147 DISALLOW_COPY_AND_ASSIGN(RetransmittableFrames); |
1138 }; | 1148 }; |
1139 | 1149 |
1140 struct NET_EXPORT_PRIVATE SerializedPacket { | 1150 struct NET_EXPORT_PRIVATE SerializedPacket { |
1141 SerializedPacket(QuicPacketNumber packet_number, | 1151 SerializedPacket(QuicPacketNumber packet_number, |
1142 QuicPacketNumberLength packet_number_length, | 1152 QuicPacketNumberLength packet_number_length, |
1143 QuicEncryptedPacket* packet, | 1153 QuicEncryptedPacket* packet, |
1144 QuicPacketEntropyHash entropy_hash, | 1154 QuicPacketEntropyHash entropy_hash, |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1198 : iov(iov), iov_count(iov_count), total_length(total_length) {} | 1208 : iov(iov), iov_count(iov_count), total_length(total_length) {} |
1199 | 1209 |
1200 const struct iovec* iov; | 1210 const struct iovec* iov; |
1201 const int iov_count; | 1211 const int iov_count; |
1202 const size_t total_length; | 1212 const size_t total_length; |
1203 }; | 1213 }; |
1204 | 1214 |
1205 } // namespace net | 1215 } // namespace net |
1206 | 1216 |
1207 #endif // NET_QUIC_QUIC_PROTOCOL_H_ | 1217 #endif // NET_QUIC_QUIC_PROTOCOL_H_ |
OLD | NEW |