Index: net/quic/quic_connection.cc |
diff --git a/net/quic/quic_connection.cc b/net/quic/quic_connection.cc |
index 3ca6d9945efbefa49281e4eede2006e3d2f6979d..30e874665e707fa7b80a64c740ccad17bc615913 100644 |
--- a/net/quic/quic_connection.cc |
+++ b/net/quic/quic_connection.cc |
@@ -154,17 +154,17 @@ class PingAlarm : public QuicAlarm::Delegate { |
DISALLOW_COPY_AND_ASSIGN(PingAlarm); |
}; |
-QuicConnection::PacketType GetPacketType( |
+bool IsConnectionClose( |
const RetransmittableFrames* retransmittable_frames) { |
if (!retransmittable_frames) { |
- return QuicConnection::NORMAL; |
+ return false; |
} |
for (size_t i = 0; i < retransmittable_frames->frames().size(); ++i) { |
if (retransmittable_frames->frames()[i].type == CONNECTION_CLOSE_FRAME) { |
- return QuicConnection::CONNECTION_CLOSE; |
+ return true; |
} |
} |
- return QuicConnection::NORMAL; |
+ return false; |
} |
} // namespace |
@@ -181,7 +181,7 @@ QuicConnection::QueuedPacket::QueuedPacket(SerializedPacket packet, |
HAS_RETRANSMITTABLE_DATA : NO_RETRANSMITTABLE_DATA), |
handshake(packet.retransmittable_frames == NULL ? |
NOT_HANDSHAKE : packet.retransmittable_frames->HasCryptoHandshake()), |
- type(GetPacketType(packet.retransmittable_frames)), |
+ is_connection_close(IsConnectionClose(packet.retransmittable_frames)), |
length(packet.packet->length()) { |
} |
@@ -1246,8 +1246,7 @@ void QuicConnection::WritePendingRetransmissions() { |
while (sent_packet_manager_.HasPendingRetransmissions()) { |
const QuicSentPacketManager::PendingRetransmission pending = |
sent_packet_manager_.NextPendingRetransmission(); |
- if (GetPacketType(&pending.retransmittable_frames) == NORMAL && |
- !CanWrite(HAS_RETRANSMITTABLE_DATA)) { |
+ if (!CanWrite(HAS_RETRANSMITTABLE_DATA)) { |
break; |
} |
@@ -1340,16 +1339,6 @@ bool QuicConnection::WritePacket(QueuedPacket packet) { |
return true; |
} |
- // If the packet is CONNECTION_CLOSE, we need to try to send it immediately |
- // and encrypt it to hand it off to TimeWaitListManager. |
- // If the packet is QUEUED, we don't re-consult the congestion control. |
- // This ensures packets are sent in sequence number order. |
- // TODO(ianswett): The congestion control should have been consulted before |
- // serializing the packet, so this could be turned into a LOG_IF(DFATAL). |
- if (packet.type == NORMAL && !CanWrite(packet.retransmittable)) { |
- return false; |
- } |
- |
// Some encryption algorithms require the packet sequence numbers not be |
// repeated. |
DCHECK_LE(sequence_number_of_last_sent_packet_, sequence_number); |
@@ -1368,7 +1357,7 @@ bool QuicConnection::WritePacket(QueuedPacket packet) { |
// Connection close packets are eventually owned by TimeWaitListManager. |
// Others are deleted at the end of this call. |
scoped_ptr<QuicEncryptedPacket> encrypted_deleter; |
- if (packet.type == CONNECTION_CLOSE) { |
+ if (packet.is_connection_close) { |
DCHECK(connection_close_packet_.get() == NULL); |
connection_close_packet_.reset(encrypted); |
// This assures we won't try to write *forced* packets when blocked. |
@@ -1538,6 +1527,7 @@ void QuicConnection::OnHandshakeComplete() { |
bool QuicConnection::SendOrQueuePacket(EncryptionLevel level, |
const SerializedPacket& packet, |
TransmissionType transmission_type) { |
+ // The caller of this function is responsible for checking CanWrite(). |
if (packet.packet == NULL) { |
LOG(DFATAL) << "NULL packet passed in to SendOrQueuePacket"; |
return true; |
@@ -1548,12 +1538,11 @@ bool QuicConnection::SendOrQueuePacket(EncryptionLevel level, |
QueuedPacket queued_packet(packet, level, transmission_type); |
// If there are already queued packets, put this at the end, |
// unless it's ConnectionClose, in which case it is written immediately. |
- if ((queued_packet.type == CONNECTION_CLOSE || queued_packets_.empty()) && |
+ if ((queued_packet.is_connection_close || queued_packets_.empty()) && |
WritePacket(queued_packet)) { |
delete packet.packet; |
return true; |
} |
- queued_packet.type = QUEUED; |
queued_packets_.push_back(queued_packet); |
return false; |
} |