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 #include <algorithm> | 9 #include <algorithm> |
10 #include <iterator> | 10 #include <iterator> |
(...skipping 1477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1488 return false; | 1488 return false; |
1489 } | 1489 } |
1490 | 1490 |
1491 void QuicConnection::OnWriteError(int error_code) { | 1491 void QuicConnection::OnWriteError(int error_code) { |
1492 DVLOG(1) << ENDPOINT << "Write failed with error: " << error_code | 1492 DVLOG(1) << ENDPOINT << "Write failed with error: " << error_code |
1493 << " (" << ErrorToString(error_code) << ")"; | 1493 << " (" << ErrorToString(error_code) << ")"; |
1494 // We can't send an error as the socket is presumably borked. | 1494 // We can't send an error as the socket is presumably borked. |
1495 CloseConnection(QUIC_PACKET_WRITE_ERROR, false); | 1495 CloseConnection(QUIC_PACKET_WRITE_ERROR, false); |
1496 } | 1496 } |
1497 | 1497 |
1498 bool QuicConnection::OnSerializedPacket( | 1498 void QuicConnection::OnSerializedPacket( |
1499 const SerializedPacket& serialized_packet) { | 1499 const SerializedPacket& serialized_packet) { |
1500 if (serialized_packet.retransmittable_frames) { | 1500 if (serialized_packet.retransmittable_frames) { |
1501 serialized_packet.retransmittable_frames-> | 1501 serialized_packet.retransmittable_frames-> |
1502 set_encryption_level(encryption_level_); | 1502 set_encryption_level(encryption_level_); |
1503 } | 1503 } |
1504 sent_packet_manager_.OnSerializedPacket(serialized_packet); | 1504 sent_packet_manager_.OnSerializedPacket(serialized_packet); |
1505 // The TransmissionType is NOT_RETRANSMISSION because all retransmissions | 1505 // The TransmissionType is NOT_RETRANSMISSION because all retransmissions |
1506 // serialize packets and invoke SendOrQueuePacket directly. | 1506 // serialize packets and invoke SendOrQueuePacket directly. |
1507 return SendOrQueuePacket(encryption_level_, | 1507 SendOrQueuePacket(encryption_level_, serialized_packet, NOT_RETRANSMISSION); |
1508 serialized_packet, | |
1509 NOT_RETRANSMISSION); | |
1510 } | 1508 } |
1511 | 1509 |
1512 void QuicConnection::OnCongestionWindowChange(QuicByteCount congestion_window) { | 1510 void QuicConnection::OnCongestionWindowChange(QuicByteCount congestion_window) { |
1513 packet_generator_.OnCongestionWindowChange(congestion_window); | 1511 packet_generator_.OnCongestionWindowChange(congestion_window); |
1514 visitor_->OnCongestionWindowChange(clock_->ApproximateNow()); | 1512 visitor_->OnCongestionWindowChange(clock_->ApproximateNow()); |
1515 } | 1513 } |
1516 | 1514 |
1517 void QuicConnection::OnHandshakeComplete() { | 1515 void QuicConnection::OnHandshakeComplete() { |
1518 sent_packet_manager_.SetHandshakeConfirmed(); | 1516 sent_packet_manager_.SetHandshakeConfirmed(); |
1519 } | 1517 } |
1520 | 1518 |
1521 bool QuicConnection::SendOrQueuePacket(EncryptionLevel level, | 1519 void QuicConnection::SendOrQueuePacket(EncryptionLevel level, |
1522 const SerializedPacket& packet, | 1520 const SerializedPacket& packet, |
1523 TransmissionType transmission_type) { | 1521 TransmissionType transmission_type) { |
1524 // The caller of this function is responsible for checking CanWrite(). | 1522 // The caller of this function is responsible for checking CanWrite(). |
1525 if (packet.packet == NULL) { | 1523 if (packet.packet == NULL) { |
1526 LOG(DFATAL) << "NULL packet passed in to SendOrQueuePacket"; | 1524 LOG(DFATAL) << "NULL packet passed in to SendOrQueuePacket"; |
1527 return true; | 1525 return; |
1528 } | 1526 } |
1529 | 1527 |
1530 sent_entropy_manager_.RecordPacketEntropyHash(packet.sequence_number, | 1528 sent_entropy_manager_.RecordPacketEntropyHash(packet.sequence_number, |
1531 packet.entropy_hash); | 1529 packet.entropy_hash); |
1532 QueuedPacket queued_packet(packet, level, transmission_type); | 1530 QueuedPacket queued_packet(packet, level, transmission_type); |
1533 LOG_IF(DFATAL, !queued_packets_.empty() && !writer_->IsWriteBlocked()) | 1531 LOG_IF(DFATAL, !queued_packets_.empty() && !writer_->IsWriteBlocked()) |
1534 << "Packets should only be left queued if we're write blocked."; | 1532 << "Packets should only be left queued if we're write blocked."; |
1535 if (WritePacket(queued_packet)) { | 1533 if (WritePacket(queued_packet)) { |
1536 delete packet.packet; | 1534 delete packet.packet; |
1537 return true; | 1535 } else { |
| 1536 queued_packets_.push_back(queued_packet); |
1538 } | 1537 } |
1539 queued_packets_.push_back(queued_packet); | |
1540 return false; | |
1541 } | 1538 } |
1542 | 1539 |
1543 void QuicConnection::UpdateStopWaiting(QuicStopWaitingFrame* stop_waiting) { | 1540 void QuicConnection::UpdateStopWaiting(QuicStopWaitingFrame* stop_waiting) { |
1544 stop_waiting->least_unacked = GetLeastUnacked(); | 1541 stop_waiting->least_unacked = GetLeastUnacked(); |
1545 stop_waiting->entropy_hash = sent_entropy_manager_.GetCumulativeEntropy( | 1542 stop_waiting->entropy_hash = sent_entropy_manager_.GetCumulativeEntropy( |
1546 stop_waiting->least_unacked - 1); | 1543 stop_waiting->least_unacked - 1); |
1547 } | 1544 } |
1548 | 1545 |
1549 void QuicConnection::SendPing() { | 1546 void QuicConnection::SendPing() { |
1550 if (retransmission_alarm_->IsSet()) { | 1547 if (retransmission_alarm_->IsSet()) { |
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2010 } | 2007 } |
2011 for (size_t i = 0; i < retransmittable_frames->frames().size(); ++i) { | 2008 for (size_t i = 0; i < retransmittable_frames->frames().size(); ++i) { |
2012 if (retransmittable_frames->frames()[i].type == CONNECTION_CLOSE_FRAME) { | 2009 if (retransmittable_frames->frames()[i].type == CONNECTION_CLOSE_FRAME) { |
2013 return true; | 2010 return true; |
2014 } | 2011 } |
2015 } | 2012 } |
2016 return false; | 2013 return false; |
2017 } | 2014 } |
2018 | 2015 |
2019 } // namespace net | 2016 } // namespace net |
OLD | NEW |