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

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

Issue 271443008: Minor QUIC cleanup to combine QuicUnackedPacketMap's RemovePacket and (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sending for review Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « net/quic/quic_unacked_packet_map.h ('k') | no next file » | 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 #include "net/quic/quic_unacked_packet_map.h" 5 #include "net/quic/quic_unacked_packet_map.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "net/quic/quic_connection_stats.h" 9 #include "net/quic/quic_connection_stats.h"
10 #include "net/quic/quic_utils_chromium.h" 10 #include "net/quic/quic_utils_chromium.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 while (it != unacked_packets_.end() && num_to_clear > 0) { 84 while (it != unacked_packets_.end() && num_to_clear > 0) {
85 QuicPacketSequenceNumber sequence_number = it->first; 85 QuicPacketSequenceNumber sequence_number = it->first;
86 // If this is a pending packet, or has retransmittable data, then there is 86 // If this is a pending packet, or has retransmittable data, then there is
87 // no point in clearing out any further packets, because they would not 87 // no point in clearing out any further packets, because they would not
88 // affect the high water mark. 88 // affect the high water mark.
89 if (it->second.pending || it->second.retransmittable_frames != NULL) { 89 if (it->second.pending || it->second.retransmittable_frames != NULL) {
90 break; 90 break;
91 } 91 }
92 92
93 ++it; 93 ++it;
94 RemovePacket(sequence_number); 94 NeuterIfPendingOrRemovePacket(sequence_number);
95 --num_to_clear; 95 --num_to_clear;
96 } 96 }
97 } 97 }
98 98
99 bool QuicUnackedPacketMap::HasRetransmittableFrames( 99 bool QuicUnackedPacketMap::HasRetransmittableFrames(
100 QuicPacketSequenceNumber sequence_number) const { 100 QuicPacketSequenceNumber sequence_number) const {
101 const TransmissionInfo* transmission_info = 101 const TransmissionInfo* transmission_info =
102 FindOrNull(unacked_packets_, sequence_number); 102 FindOrNull(unacked_packets_, sequence_number);
103 if (transmission_info == NULL) { 103 if (transmission_info == NULL) {
104 return false; 104 return false;
105 } 105 }
106 106
107 return transmission_info->retransmittable_frames != NULL; 107 return transmission_info->retransmittable_frames != NULL;
108 } 108 }
109 109
110 void QuicUnackedPacketMap::NackPacket(QuicPacketSequenceNumber sequence_number, 110 void QuicUnackedPacketMap::NackPacket(QuicPacketSequenceNumber sequence_number,
111 size_t min_nacks) { 111 size_t min_nacks) {
112 UnackedPacketMap::iterator it = unacked_packets_.find(sequence_number); 112 UnackedPacketMap::iterator it = unacked_packets_.find(sequence_number);
113 if (it == unacked_packets_.end()) { 113 if (it == unacked_packets_.end()) {
114 LOG(DFATAL) << "NackPacket called for packet that is not unacked: " 114 LOG(DFATAL) << "NackPacket called for packet that is not unacked: "
115 << sequence_number; 115 << sequence_number;
116 return; 116 return;
117 } 117 }
118 118
119 it->second.nack_count = max(min_nacks, it->second.nack_count); 119 it->second.nack_count = max(min_nacks, it->second.nack_count);
120 } 120 }
121 121
122 void QuicUnackedPacketMap::RemovePacket( 122 void QuicUnackedPacketMap::NeuterIfPendingOrRemovePacket(
123 QuicPacketSequenceNumber sequence_number) { 123 QuicPacketSequenceNumber sequence_number) {
124 UnackedPacketMap::iterator it = unacked_packets_.find(sequence_number); 124 UnackedPacketMap::iterator it = unacked_packets_.find(sequence_number);
125 if (it == unacked_packets_.end()) { 125 if (it == unacked_packets_.end()) {
126 LOG(DFATAL) << "packet is not unacked: " << sequence_number;
127 return;
128 }
129 const TransmissionInfo& transmission_info = it->second;
130 transmission_info.all_transmissions->erase(sequence_number);
131 if (transmission_info.all_transmissions->empty()) {
132 delete transmission_info.all_transmissions;
133 }
134 if (transmission_info.retransmittable_frames != NULL) {
135 if (transmission_info.retransmittable_frames->HasCryptoHandshake()
136 == IS_HANDSHAKE) {
137 --pending_crypto_packet_count_;
138 }
139 delete transmission_info.retransmittable_frames;
140 }
141 DCHECK(!transmission_info.pending);
142 unacked_packets_.erase(it);
143 }
144
145 void QuicUnackedPacketMap::NeuterPacket(
146 QuicPacketSequenceNumber sequence_number) {
147 UnackedPacketMap::iterator it = unacked_packets_.find(sequence_number);
148 if (it == unacked_packets_.end()) {
149 LOG(DFATAL) << "packet is not unacked: " << sequence_number; 126 LOG(DFATAL) << "packet is not unacked: " << sequence_number;
150 return; 127 return;
151 } 128 }
152 TransmissionInfo* transmission_info = &it->second; 129 TransmissionInfo* transmission_info = &it->second;
153 if (transmission_info->all_transmissions->size() > 1) {
154 transmission_info->all_transmissions->erase(sequence_number);
155 transmission_info->all_transmissions = new SequenceNumberSet();
156 transmission_info->all_transmissions->insert(sequence_number);
157 }
158 if (transmission_info->retransmittable_frames != NULL) { 130 if (transmission_info->retransmittable_frames != NULL) {
159 if (transmission_info->retransmittable_frames->HasCryptoHandshake() 131 if (transmission_info->retransmittable_frames->HasCryptoHandshake()
160 == IS_HANDSHAKE) { 132 == IS_HANDSHAKE) {
161 --pending_crypto_packet_count_; 133 --pending_crypto_packet_count_;
162 } 134 }
163 delete transmission_info->retransmittable_frames; 135 delete transmission_info->retransmittable_frames;
164 transmission_info->retransmittable_frames = NULL; 136 transmission_info->retransmittable_frames = NULL;
165 } 137 }
138 if (transmission_info->pending) {
139 // Neuter it so it can't be retransmitted.
140 if (transmission_info->all_transmissions->size() > 1) {
141 transmission_info->all_transmissions->erase(sequence_number);
142 transmission_info->all_transmissions = new SequenceNumberSet();
143 transmission_info->all_transmissions->insert(sequence_number);
144 }
145 } else {
146 // Remove it.
147 transmission_info->all_transmissions->erase(sequence_number);
148 if (transmission_info->all_transmissions->empty()) {
149 delete transmission_info->all_transmissions;
150 }
151 unacked_packets_.erase(it);
152 }
166 } 153 }
167 154
168 // static 155 // static
169 bool QuicUnackedPacketMap::IsSentAndNotPending( 156 bool QuicUnackedPacketMap::IsSentAndNotPending(
170 const TransmissionInfo& transmission_info) { 157 const TransmissionInfo& transmission_info) {
171 return !transmission_info.pending && 158 return !transmission_info.pending &&
172 transmission_info.sent_time != QuicTime::Zero() && 159 transmission_info.sent_time != QuicTime::Zero() &&
173 transmission_info.bytes_sent == 0; 160 transmission_info.bytes_sent == 0;
174 } 161 }
175 162
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 largest_sent_packet_ = max(sequence_number, largest_sent_packet_); 311 largest_sent_packet_ = max(sequence_number, largest_sent_packet_);
325 it->second.sent_time = sent_time; 312 it->second.sent_time = sent_time;
326 if (set_pending) { 313 if (set_pending) {
327 bytes_in_flight_ += bytes_sent; 314 bytes_in_flight_ += bytes_sent;
328 it->second.bytes_sent = bytes_sent; 315 it->second.bytes_sent = bytes_sent;
329 it->second.pending = true; 316 it->second.pending = true;
330 } 317 }
331 } 318 }
332 319
333 } // namespace net 320 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_unacked_packet_map.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698