Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(98)

Side by Side Diff: net/quic/quic_unacked_packet_map.h

Issue 523813003: Revert of Landing Recent QUIC Changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/quic/quic_sent_packet_manager_test.cc ('k') | net/quic/quic_unacked_packet_map.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_UNACKED_PACKET_MAP_H_ 5 #ifndef NET_QUIC_QUIC_UNACKED_PACKET_MAP_H_
6 #define NET_QUIC_QUIC_UNACKED_PACKET_MAP_H_ 6 #define NET_QUIC_QUIC_UNACKED_PACKET_MAP_H_
7 7
8 #include <deque> 8 #include "net/base/linked_hash_map.h"
9
10 #include "net/quic/quic_protocol.h" 9 #include "net/quic/quic_protocol.h"
11 10
12 namespace net { 11 namespace net {
13 12
14 // Class which tracks unacked packets for three purposes: 13 // Class which tracks unacked packets for three purposes:
15 // 1) Track retransmittable data, including multiple transmissions of frames. 14 // 1) Track retransmittable data, including multiple transmissions of frames.
16 // 2) Track packets and bytes in flight for congestion control. 15 // 2) Track packets and bytes in flight for congestion control.
17 // 3) Track sent time of packets to provide RTT measurements from acks. 16 // 3) Track sent time of packets to provide RTT measurements from acks.
18 class NET_EXPORT_PRIVATE QuicUnackedPacketMap { 17 class NET_EXPORT_PRIVATE QuicUnackedPacketMap {
19 public: 18 public:
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 return largest_observed_; 64 return largest_observed_;
66 } 65 }
67 66
68 // Returns the sum of bytes from all packets in flight. 67 // Returns the sum of bytes from all packets in flight.
69 QuicByteCount bytes_in_flight() const { 68 QuicByteCount bytes_in_flight() const {
70 return bytes_in_flight_; 69 return bytes_in_flight_;
71 } 70 }
72 71
73 // Returns the smallest sequence number of a serialized packet which has not 72 // Returns the smallest sequence number of a serialized packet which has not
74 // been acked by the peer. If there are no unacked packets, returns 0. 73 // been acked by the peer. If there are no unacked packets, returns 0.
75 QuicPacketSequenceNumber GetLeastUnacked() const; 74 QuicPacketSequenceNumber GetLeastUnackedSentPacket() const;
76 75
77 // Sets a packet as sent with the sent time |sent_time|. Marks the packet 76 // Sets a packet as sent with the sent time |sent_time|. Marks the packet
78 // as in flight if |set_in_flight| is true. 77 // as in flight if |set_in_flight| is true.
79 // Packets marked as in flight are expected to be marked as missing when they 78 // Packets marked as in flight are expected to be marked as missing when they
80 // don't arrive, indicating the need for retransmission. 79 // don't arrive, indicating the need for retransmission.
81 void SetSent(QuicPacketSequenceNumber sequence_number, 80 void SetSent(QuicPacketSequenceNumber sequence_number,
82 QuicTime sent_time, 81 QuicTime sent_time,
83 QuicByteCount bytes_sent, 82 QuicByteCount bytes_sent,
84 bool set_in_flight); 83 bool set_in_flight);
85 84
86 // Restores the in flight status for a packet that was previously sent. 85 // Restores the in flight status for a packet that was previously sent.
87 void RestoreInFlight(QuicPacketSequenceNumber sequence_number); 86 void RestoreInFlight(QuicPacketSequenceNumber sequence_number);
88 87
89 // Clears up to |num_to_clear| previous transmissions in order to make room 88 // Clears up to |num_to_clear| previous transmissions in order to make room
90 // in the ack frame for new acks. 89 // in the ack frame for new acks.
91 void ClearPreviousRetransmissions(size_t num_to_clear); 90 void ClearPreviousRetransmissions(size_t num_to_clear);
92 91
93 typedef std::deque<TransmissionInfo> UnackedPacketMap; 92 typedef linked_hash_map<QuicPacketSequenceNumber,
93 TransmissionInfo> UnackedPacketMap;
94 94
95 typedef UnackedPacketMap::const_iterator const_iterator; 95 typedef UnackedPacketMap::const_iterator const_iterator;
96 96
97 const_iterator begin() const { return unacked_packets_.begin(); } 97 const_iterator begin() const { return unacked_packets_.begin(); }
98 const_iterator end() const { return unacked_packets_.end(); } 98 const_iterator end() const { return unacked_packets_.end(); }
99 99
100 // Returns true if there are unacked packets that are in flight. 100 // Returns true if there are unacked packets that are in flight.
101 bool HasInFlightPackets() const; 101 bool HasInFlightPackets() const;
102 102
103 // Returns the TransmissionInfo associated with |sequence_number|, which 103 // Returns the TransmissionInfo associated with |sequence_number|, which
104 // must be unacked. 104 // must be unacked.
105 const TransmissionInfo& GetTransmissionInfo( 105 const TransmissionInfo& GetTransmissionInfo(
106 QuicPacketSequenceNumber sequence_number) const; 106 QuicPacketSequenceNumber sequence_number) const;
107 107
108 // Returns the time that the last unacked packet was sent. 108 // Returns the time that the last unacked packet was sent.
109 QuicTime GetLastPacketSentTime() const; 109 QuicTime GetLastPacketSentTime() const;
110 110
111 // Returns the time that the first in flight packet was sent. 111 // Returns the time that the first in flight packet was sent.
112 QuicTime GetFirstInFlightPacketSentTime() const; 112 QuicTime GetFirstInFlightPacketSentTime() const;
113 113
114 // Returns the number of unacked packets. 114 // Returns the number of unacked packets.
115 size_t GetNumUnackedPacketsDebugOnly() const; 115 size_t GetNumUnackedPackets() const;
116 116
117 // Returns true if there are multiple packets in flight. 117 // Returns true if there are multiple packets in flight.
118 bool HasMultipleInFlightPackets() const; 118 bool HasMultipleInFlightPackets() const;
119 119
120 // Returns true if there are any pending crypto packets. 120 // Returns true if there are any pending crypto packets.
121 bool HasPendingCryptoPackets() const; 121 bool HasPendingCryptoPackets() const;
122 122
123 // Removes any retransmittable frames from this transmission or an associated 123 // Removes any retransmittable frames from this transmission or an associated
124 // transmission. It removes now useless transmissions, and disconnects any 124 // transmission. It removes now useless transmissions, and disconnects any
125 // other packets from other transmissions. 125 // other packets from other transmissions.
126 void RemoveRetransmittability(QuicPacketSequenceNumber sequence_number); 126 void RemoveRetransmittability(QuicPacketSequenceNumber sequence_number);
127 127
128 // Increases the largest observed. Any packets less or equal to 128 // Increases the largest observed. Any packets less or equal to
129 // |largest_acked_packet| are discarded if they are only for the RTT purposes. 129 // |largest_acked_packet| are discarded if they are only for the RTT purposes.
130 void IncreaseLargestObserved(QuicPacketSequenceNumber largest_observed); 130 void IncreaseLargestObserved(QuicPacketSequenceNumber largest_observed);
131 131
132 // Remove any packets no longer needed for retransmission, congestion, or
133 // RTT measurement purposes.
134 void RemoveObsoletePackets();
135
136 private: 132 private:
137 void MaybeRemoveRetransmittableFrames(TransmissionInfo* transmission_info); 133 void MaybeRemoveRetransmittableFrames(TransmissionInfo* transmission_info);
138 134
139 // Returns true if the packet no longer has a purpose in the map. 135 // Returns true if the packet no longer has a purpose in the map.
140 bool IsPacketUseless(QuicPacketSequenceNumber sequence_number, 136 bool IsPacketUseless(UnackedPacketMap::const_iterator it) const;
141 const TransmissionInfo& info) const;
142 137
143 QuicPacketSequenceNumber largest_sent_packet_; 138 QuicPacketSequenceNumber largest_sent_packet_;
144 QuicPacketSequenceNumber largest_observed_; 139 QuicPacketSequenceNumber largest_observed_;
145 140
146 // Newly serialized retransmittable and fec packets are added to this map, 141 // Newly serialized retransmittable and fec packets are added to this map,
147 // which contains owning pointers to any contained frames. If a packet is 142 // which contains owning pointers to any contained frames. If a packet is
148 // retransmitted, this map will contain entries for both the old and the new 143 // retransmitted, this map will contain entries for both the old and the new
149 // packet. The old packet's retransmittable frames entry will be NULL, while 144 // packet. The old packet's retransmittable frames entry will be NULL, while
150 // the new packet's entry will contain the frames to retransmit. 145 // the new packet's entry will contain the frames to retransmit.
151 // If the old packet is acked before the new packet, then the old entry will 146 // If the old packet is acked before the new packet, then the old entry will
152 // be removed from the map and the new entry's retransmittable frames will be 147 // be removed from the map and the new entry's retransmittable frames will be
153 // set to NULL. 148 // set to NULL.
154 UnackedPacketMap unacked_packets_; 149 UnackedPacketMap unacked_packets_;
155 // The packet at the 0th index of unacked_packets_.
156 QuicPacketSequenceNumber least_unacked_;
157 150
158 size_t bytes_in_flight_; 151 size_t bytes_in_flight_;
159 // Number of retransmittable crypto handshake packets. 152 // Number of retransmittable crypto handshake packets.
160 size_t pending_crypto_packet_count_; 153 size_t pending_crypto_packet_count_;
161 154
162 DISALLOW_COPY_AND_ASSIGN(QuicUnackedPacketMap); 155 DISALLOW_COPY_AND_ASSIGN(QuicUnackedPacketMap);
163 }; 156 };
164 157
165 } // namespace net 158 } // namespace net
166 159
167 #endif // NET_QUIC_QUIC_UNACKED_PACKET_MAP_H_ 160 #endif // NET_QUIC_QUIC_UNACKED_PACKET_MAP_H_
OLDNEW
« no previous file with comments | « net/quic/quic_sent_packet_manager_test.cc ('k') | net/quic/quic_unacked_packet_map.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698