| Index: net/quic/quic_connection.cc
|
| diff --git a/net/quic/quic_connection.cc b/net/quic/quic_connection.cc
|
| index 44fe48b8f407085155abf4e9f49cd5a504eb6f61..61fd3c140ae4c0eb1654d40f4bff94c147a5f820 100644
|
| --- a/net/quic/quic_connection.cc
|
| +++ b/net/quic/quic_connection.cc
|
| @@ -1449,6 +1449,13 @@ bool QuicConnection::WritePacketInner(QueuedPacket* packet) {
|
| << QuicUtils::StringToHexASCIIDump(
|
| packet->serialized_packet.packet->AsStringPiece());
|
|
|
| + QuicTime packet_send_time = QuicTime::Zero();
|
| + if (FLAGS_quic_record_send_time_before_write) {
|
| + // Measure the RTT from before the write begins to avoid underestimating the
|
| + // min_rtt_, especially in cases where the thread blocks or gets swapped out
|
| + // during the WritePacket below.
|
| + packet_send_time = clock_->Now();
|
| + }
|
| WriteResult result = writer_->WritePacket(encrypted->data(),
|
| encrypted->length(),
|
| self_address().address(),
|
| @@ -1467,7 +1474,16 @@ bool QuicConnection::WritePacketInner(QueuedPacket* packet) {
|
| return false;
|
| }
|
| }
|
| - QuicTime now = clock_->Now();
|
| + if (!FLAGS_quic_record_send_time_before_write) {
|
| + packet_send_time = clock_->Now();
|
| + }
|
| + if (!packet_send_time.IsInitialized()) {
|
| + // TODO(jokulik): This is only needed because of the two code paths for
|
| + // initializing packet_send_time. Once "quic_record_send_time_before_write"
|
| + // is deprecated, this check can be removed.
|
| + LOG(DFATAL) << "The packet send time should never be zero. "
|
| + << "This is a programming bug, please report it.";
|
| + }
|
| if (result.status != WRITE_STATUS_ERROR && debug_visitor_.get() != nullptr) {
|
| // Pass the write result to the visitor.
|
| debug_visitor_->OnPacketSent(packet->serialized_packet,
|
| @@ -1475,14 +1491,17 @@ bool QuicConnection::WritePacketInner(QueuedPacket* packet) {
|
| packet->encryption_level,
|
| packet->transmission_type,
|
| *encrypted,
|
| - now);
|
| + packet_send_time);
|
| }
|
| if (packet->transmission_type == NOT_RETRANSMISSION) {
|
| - time_of_last_sent_new_packet_ = now;
|
| + time_of_last_sent_new_packet_ = packet_send_time;
|
| }
|
| SetPingAlarm();
|
| - DVLOG(1) << ENDPOINT << "time of last sent packet: "
|
| - << now.ToDebuggingValue();
|
| + DVLOG(1) << ENDPOINT << "time "
|
| + << (FLAGS_quic_record_send_time_before_write ?
|
| + "we began writing " : "we finished writing ")
|
| + << "last sent packet: "
|
| + << packet_send_time.ToDebuggingValue();
|
|
|
| // TODO(ianswett): Change the sequence number length and other packet creator
|
| // options by a more explicit API than setting a struct value directly,
|
| @@ -1494,7 +1513,7 @@ bool QuicConnection::WritePacketInner(QueuedPacket* packet) {
|
| bool reset_retransmission_alarm = sent_packet_manager_.OnPacketSent(
|
| &packet->serialized_packet,
|
| packet->original_sequence_number,
|
| - now,
|
| + packet_send_time,
|
| encrypted->length(),
|
| packet->transmission_type,
|
| IsRetransmittable(*packet));
|
|
|