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

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

Issue 965873004: Deprecate FLAGS_quic_record_send_time_before_write. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@QuicConnection_no_longer_owns_debug_visitor_86801250
Patch Set: Created 5 years, 9 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
« no previous file with comments | « no previous file | net/quic/quic_connection_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1426 matching lines...) Expand 10 before | Expand all | Expand 10 after
1437 << (packet->serialized_packet.is_fec_packet 1437 << (packet->serialized_packet.is_fec_packet
1438 ? "FEC " 1438 ? "FEC "
1439 : (IsRetransmittable(*packet) == HAS_RETRANSMITTABLE_DATA 1439 : (IsRetransmittable(*packet) == HAS_RETRANSMITTABLE_DATA
1440 ? "data bearing " 1440 ? "data bearing "
1441 : " ack only ")) << ", encryption level: " 1441 : " ack only ")) << ", encryption level: "
1442 << QuicUtils::EncryptionLevelToString(packet->encryption_level) 1442 << QuicUtils::EncryptionLevelToString(packet->encryption_level)
1443 << ", encrypted length:" << encrypted->length(); 1443 << ", encrypted length:" << encrypted->length();
1444 DVLOG(2) << ENDPOINT << "packet(" << sequence_number << "): " << std::endl 1444 DVLOG(2) << ENDPOINT << "packet(" << sequence_number << "): " << std::endl
1445 << QuicUtils::StringToHexASCIIDump(encrypted->AsStringPiece()); 1445 << QuicUtils::StringToHexASCIIDump(encrypted->AsStringPiece());
1446 1446
1447 QuicTime packet_send_time = QuicTime::Zero(); 1447 // Measure the RTT from before the write begins to avoid underestimating the
1448 if (FLAGS_quic_record_send_time_before_write) { 1448 // min_rtt_, especially in cases where the thread blocks or gets swapped out
1449 // Measure the RTT from before the write begins to avoid underestimating the 1449 // during the WritePacket below.
1450 // min_rtt_, especially in cases where the thread blocks or gets swapped out 1450 QuicTime packet_send_time = clock_->Now();
1451 // during the WritePacket below.
1452 packet_send_time = clock_->Now();
1453 }
1454 WriteResult result = writer_->WritePacket(encrypted->data(), 1451 WriteResult result = writer_->WritePacket(encrypted->data(),
1455 encrypted->length(), 1452 encrypted->length(),
1456 self_address().address(), 1453 self_address().address(),
1457 peer_address()); 1454 peer_address());
1458 if (result.error_code == ERR_IO_PENDING) { 1455 if (result.error_code == ERR_IO_PENDING) {
1459 DCHECK_EQ(WRITE_STATUS_BLOCKED, result.status); 1456 DCHECK_EQ(WRITE_STATUS_BLOCKED, result.status);
1460 } 1457 }
1461 1458
1462 if (result.status == WRITE_STATUS_BLOCKED) { 1459 if (result.status == WRITE_STATUS_BLOCKED) {
1463 visitor_->OnWriteBlocked(); 1460 visitor_->OnWriteBlocked();
1464 // If the socket buffers the the data, then the packet should not 1461 // If the socket buffers the the data, then the packet should not
1465 // be queued and sent again, which would result in an unnecessary 1462 // be queued and sent again, which would result in an unnecessary
1466 // duplicate packet being sent. The helper must call OnCanWrite 1463 // duplicate packet being sent. The helper must call OnCanWrite
1467 // when the write completes, and OnWriteError if an error occurs. 1464 // when the write completes, and OnWriteError if an error occurs.
1468 if (!writer_->IsWriteBlockedDataBuffered()) { 1465 if (!writer_->IsWriteBlockedDataBuffered()) {
1469 return false; 1466 return false;
1470 } 1467 }
1471 } 1468 }
1472 if (!FLAGS_quic_record_send_time_before_write) {
1473 packet_send_time = clock_->Now();
1474 }
1475 if (!packet_send_time.IsInitialized()) {
1476 // TODO(jokulik): This is only needed because of the two code paths for
1477 // initializing packet_send_time. Once "quic_record_send_time_before_write"
1478 // is deprecated, this check can be removed.
1479 LOG(DFATAL) << "The packet send time should never be zero. "
1480 << "This is a programming bug, please report it.";
1481 }
1482 if (result.status != WRITE_STATUS_ERROR && debug_visitor_ != nullptr) { 1469 if (result.status != WRITE_STATUS_ERROR && debug_visitor_ != nullptr) {
1483 // Pass the write result to the visitor. 1470 // Pass the write result to the visitor.
1484 debug_visitor_->OnPacketSent(packet->serialized_packet, 1471 debug_visitor_->OnPacketSent(packet->serialized_packet,
1485 packet->original_sequence_number, 1472 packet->original_sequence_number,
1486 packet->encryption_level, 1473 packet->encryption_level,
1487 packet->transmission_type, 1474 packet->transmission_type,
1488 *encrypted, 1475 *encrypted,
1489 packet_send_time); 1476 packet_send_time);
1490 } 1477 }
1491 if (packet->transmission_type == NOT_RETRANSMISSION) { 1478 if (packet->transmission_type == NOT_RETRANSMISSION) {
1492 time_of_last_sent_new_packet_ = packet_send_time; 1479 time_of_last_sent_new_packet_ = packet_send_time;
1493 } 1480 }
1494 SetPingAlarm(); 1481 SetPingAlarm();
1495 MaybeSetFecAlarm(sequence_number); 1482 MaybeSetFecAlarm(sequence_number);
1496 DVLOG(1) << ENDPOINT << "time " 1483 DVLOG(1) << ENDPOINT << "time we began writing last sent packet: "
1497 << (FLAGS_quic_record_send_time_before_write ?
1498 "we began writing " : "we finished writing ")
1499 << "last sent packet: "
1500 << packet_send_time.ToDebuggingValue(); 1484 << packet_send_time.ToDebuggingValue();
1501 1485
1502 // TODO(ianswett): Change the sequence number length and other packet creator 1486 // TODO(ianswett): Change the sequence number length and other packet creator
1503 // options by a more explicit API than setting a struct value directly, 1487 // options by a more explicit API than setting a struct value directly,
1504 // perhaps via the NetworkChangeVisitor. 1488 // perhaps via the NetworkChangeVisitor.
1505 packet_generator_.UpdateSequenceNumberLength( 1489 packet_generator_.UpdateSequenceNumberLength(
1506 sent_packet_manager_.least_packet_awaited_by_peer(), 1490 sent_packet_manager_.least_packet_awaited_by_peer(),
1507 sent_packet_manager_.EstimateMaxPacketsInFlight(max_packet_length())); 1491 sent_packet_manager_.EstimateMaxPacketsInFlight(max_packet_length()));
1508 1492
1509 bool reset_retransmission_alarm = sent_packet_manager_.OnPacketSent( 1493 bool reset_retransmission_alarm = sent_packet_manager_.OnPacketSent(
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after
2098 } 2082 }
2099 for (const QuicFrame& frame : retransmittable_frames->frames()) { 2083 for (const QuicFrame& frame : retransmittable_frames->frames()) {
2100 if (frame.type == CONNECTION_CLOSE_FRAME) { 2084 if (frame.type == CONNECTION_CLOSE_FRAME) {
2101 return true; 2085 return true;
2102 } 2086 }
2103 } 2087 }
2104 return false; 2088 return false;
2105 } 2089 }
2106 2090
2107 } // namespace net 2091 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/quic/quic_connection_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698