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 #include "net/quic/quic_connection.h" | 5 #include "net/quic/quic_connection.h" |
6 | 6 |
7 #include <string.h> | 7 #include <string.h> |
8 #include <sys/types.h> | 8 #include <sys/types.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 1157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1168 WritePendingRetransmissions(); | 1168 WritePendingRetransmissions(); |
1169 | 1169 |
1170 // Sending queued packets may have caused the socket to become write blocked, | 1170 // Sending queued packets may have caused the socket to become write blocked, |
1171 // or the congestion manager to prohibit sending. If we've sent everything | 1171 // or the congestion manager to prohibit sending. If we've sent everything |
1172 // we had queued and we're still not blocked, let the visitor know it can | 1172 // we had queued and we're still not blocked, let the visitor know it can |
1173 // write more. | 1173 // write more. |
1174 if (!CanWrite(HAS_RETRANSMITTABLE_DATA)) { | 1174 if (!CanWrite(HAS_RETRANSMITTABLE_DATA)) { |
1175 return; | 1175 return; |
1176 } | 1176 } |
1177 | 1177 |
1178 { // Limit the scope of the bundler. | 1178 { // Limit the scope of the bundler. ACK inclusion happens elsewhere. |
1179 // Set |include_ack| to false in bundler; ack inclusion happens elsewhere. | |
1180 ScopedPacketBundler bundler(this, NO_ACK); | 1179 ScopedPacketBundler bundler(this, NO_ACK); |
1181 visitor_->OnCanWrite(); | 1180 visitor_->OnCanWrite(); |
1182 } | 1181 } |
1183 | 1182 |
1184 // After the visitor writes, it may have caused the socket to become write | 1183 // After the visitor writes, it may have caused the socket to become write |
1185 // blocked or the congestion manager to prohibit sending, so check again. | 1184 // blocked or the congestion manager to prohibit sending, so check again. |
1186 if (visitor_->WillingAndAbleToWrite() && | 1185 if (visitor_->WillingAndAbleToWrite() && |
1187 !resume_writes_alarm_->IsSet() && | 1186 !resume_writes_alarm_->IsSet() && |
1188 CanWrite(HAS_RETRANSMITTABLE_DATA)) { | 1187 CanWrite(HAS_RETRANSMITTABLE_DATA)) { |
1189 // We're not write blocked, but some stream didn't write out all of its | 1188 // We're not write blocked, but some stream didn't write out all of its |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1314 QuicTime::Delta delay = sent_packet_manager_.TimeUntilSend( | 1313 QuicTime::Delta delay = sent_packet_manager_.TimeUntilSend( |
1315 now, retransmittable); | 1314 now, retransmittable); |
1316 if (delay.IsInfinite()) { | 1315 if (delay.IsInfinite()) { |
1317 send_alarm_->Cancel(); | 1316 send_alarm_->Cancel(); |
1318 return false; | 1317 return false; |
1319 } | 1318 } |
1320 | 1319 |
1321 // If the scheduler requires a delay, then we can not send this packet now. | 1320 // If the scheduler requires a delay, then we can not send this packet now. |
1322 if (!delay.IsZero()) { | 1321 if (!delay.IsZero()) { |
1323 send_alarm_->Update(now.Add(delay), QuicTime::Delta::FromMilliseconds(1)); | 1322 send_alarm_->Update(now.Add(delay), QuicTime::Delta::FromMilliseconds(1)); |
1324 DVLOG(1) << "Delaying sending."; | 1323 DVLOG(1) << ENDPOINT << "Delaying sending " << delay.ToMilliseconds() |
| 1324 << "ms"; |
1325 return false; | 1325 return false; |
1326 } | 1326 } |
1327 send_alarm_->Cancel(); | 1327 send_alarm_->Cancel(); |
1328 return true; | 1328 return true; |
1329 } | 1329 } |
1330 | 1330 |
1331 bool QuicConnection::WritePacket(QueuedPacket* packet) { | 1331 bool QuicConnection::WritePacket(QueuedPacket* packet) { |
1332 if (!WritePacketInner(packet)) { | 1332 if (!WritePacketInner(packet)) { |
1333 return false; | 1333 return false; |
1334 } | 1334 } |
(...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2031 } | 2031 } |
2032 for (size_t i = 0; i < retransmittable_frames->frames().size(); ++i) { | 2032 for (size_t i = 0; i < retransmittable_frames->frames().size(); ++i) { |
2033 if (retransmittable_frames->frames()[i].type == CONNECTION_CLOSE_FRAME) { | 2033 if (retransmittable_frames->frames()[i].type == CONNECTION_CLOSE_FRAME) { |
2034 return true; | 2034 return true; |
2035 } | 2035 } |
2036 } | 2036 } |
2037 return false; | 2037 return false; |
2038 } | 2038 } |
2039 | 2039 |
2040 } // namespace net | 2040 } // namespace net |
OLD | NEW |