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

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

Issue 280753002: Revert of Minor QUIC cleanup to combine QuicUnackedPacketMap's (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 NeuterIfPendingOrRemovePacket(sequence_number); 94 RemovePacket(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::NeuterIfPendingOrRemovePacket( 122 void QuicUnackedPacketMap::RemovePacket(
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()) {
126 LOG(DFATAL) << "packet is not unacked: " << sequence_number; 149 LOG(DFATAL) << "packet is not unacked: " << sequence_number;
127 return; 150 return;
128 } 151 }
129 TransmissionInfo* transmission_info = &it->second; 152 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 }
130 if (transmission_info->retransmittable_frames != NULL) { 158 if (transmission_info->retransmittable_frames != NULL) {
131 if (transmission_info->retransmittable_frames->HasCryptoHandshake() 159 if (transmission_info->retransmittable_frames->HasCryptoHandshake()
132 == IS_HANDSHAKE) { 160 == IS_HANDSHAKE) {
133 --pending_crypto_packet_count_; 161 --pending_crypto_packet_count_;
134 } 162 }
135 delete transmission_info->retransmittable_frames; 163 delete transmission_info->retransmittable_frames;
136 transmission_info->retransmittable_frames = NULL; 164 transmission_info->retransmittable_frames = NULL;
137 } 165 }
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 }
153 } 166 }
154 167
155 // static 168 // static
156 bool QuicUnackedPacketMap::IsSentAndNotPending( 169 bool QuicUnackedPacketMap::IsSentAndNotPending(
157 const TransmissionInfo& transmission_info) { 170 const TransmissionInfo& transmission_info) {
158 return !transmission_info.pending && 171 return !transmission_info.pending &&
159 transmission_info.sent_time != QuicTime::Zero() && 172 transmission_info.sent_time != QuicTime::Zero() &&
160 transmission_info.bytes_sent == 0; 173 transmission_info.bytes_sent == 0;
161 } 174 }
162 175
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 largest_sent_packet_ = max(sequence_number, largest_sent_packet_); 308 largest_sent_packet_ = max(sequence_number, largest_sent_packet_);
296 it->second.sent_time = sent_time; 309 it->second.sent_time = sent_time;
297 if (set_pending) { 310 if (set_pending) {
298 bytes_in_flight_ += bytes_sent; 311 bytes_in_flight_ += bytes_sent;
299 it->second.bytes_sent = bytes_sent; 312 it->second.bytes_sent = bytes_sent;
300 it->second.pending = true; 313 it->second.pending = true;
301 } 314 }
302 } 315 }
303 316
304 } // namespace net 317 } // 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