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

Unified Diff: net/quic/quic_connection.cc

Issue 483093004: Rename QuicConnection::OnPacketSent to OnWriteError, to reflect it's (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Refactor_async_write_behavior_73648585
Patch Set: Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/quic/quic_connection.h ('k') | net/quic/quic_connection_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/quic_connection.cc
diff --git a/net/quic/quic_connection.cc b/net/quic/quic_connection.cc
index 182bd301f71d097d79a41b9c5d5d7fe7091534fc..e8a71e85cece8a429c20317a95e65655ace30c5b 100644
--- a/net/quic/quic_connection.cc
+++ b/net/quic/quic_connection.cc
@@ -1367,11 +1367,10 @@ bool QuicConnection::WritePacket(QueuedPacket packet) {
encrypted_deleter.reset(encrypted);
}
- LOG_IF(DFATAL, encrypted->length() >
- packet_generator_.max_packet_length())
- << "Writing an encrypted packet larger than max_packet_length:"
- << packet_generator_.max_packet_length() << " encrypted length: "
- << encrypted->length();
+ if (!FLAGS_quic_allow_oversized_packets_for_test) {
+ DCHECK_LE(encrypted->length(), kMaxPacketSize);
+ }
+ DCHECK_LE(encrypted->length(), packet_generator_.max_packet_length());
DVLOG(1) << ENDPOINT << "Sending packet " << sequence_number
<< " : " << (packet.packet->is_fec_packet() ? "FEC " :
(packet.retransmittable == HAS_RETRANSMITTABLE_DATA
@@ -1383,12 +1382,6 @@ bool QuicConnection::WritePacket(QueuedPacket packet) {
DVLOG(2) << ENDPOINT << "packet(" << sequence_number << "): " << std::endl
<< QuicUtils::StringToHexASCIIDump(packet.packet->AsStringPiece());
- DCHECK(encrypted->length() <= kMaxPacketSize ||
- FLAGS_quic_allow_oversized_packets_for_test)
- << "Packet " << sequence_number << " will not be read; too large: "
- << packet.packet->length() << " " << encrypted->length() << " "
- << " close: " << (packet.type == CONNECTION_CLOSE ? "yes" : "no");
-
WriteResult result = writer_->WritePacket(encrypted->data(),
encrypted->length(),
self_address().address(),
@@ -1409,8 +1402,8 @@ bool QuicConnection::WritePacket(QueuedPacket packet) {
visitor_->OnWriteBlocked();
// If the socket buffers the the data, then the packet should not
// be queued and sent again, which would result in an unnecessary
- // duplicate packet being sent. The helper must call OnPacketSent
- // when the packet is actually sent.
+ // duplicate packet being sent. The helper must call OnCanWrite
+ // when the write completes, and OnWriteError if an error occurs.
if (!writer_->IsWriteBlockedDataBuffered()) {
return false;
}
@@ -1449,7 +1442,12 @@ bool QuicConnection::WritePacket(QueuedPacket packet) {
++stats_.packets_retransmitted;
}
- return OnPacketSent(result);
+ if (result.status == WRITE_STATUS_ERROR) {
+ OnWriteError(result.error_code);
+ return false;
+ }
+
+ return true;
}
bool QuicConnection::ShouldDiscardPacket(
@@ -1493,16 +1491,11 @@ bool QuicConnection::ShouldDiscardPacket(
return false;
}
-bool QuicConnection::OnPacketSent(WriteResult result) {
- if (result.status == WRITE_STATUS_ERROR) {
- DVLOG(1) << ENDPOINT << "Write failed with error: " << result.error_code
- << " (" << ErrorToString(result.error_code) << ")";
- // We can't send an error as the socket is presumably borked.
- CloseConnection(QUIC_PACKET_WRITE_ERROR, false);
- return false;
- }
-
- return true;
+void QuicConnection::OnWriteError(int error_code) {
+ DVLOG(1) << ENDPOINT << "Write failed with error: " << error_code
+ << " (" << ErrorToString(error_code) << ")";
+ // We can't send an error as the socket is presumably borked.
+ CloseConnection(QUIC_PACKET_WRITE_ERROR, false);
}
bool QuicConnection::OnSerializedPacket(
« no previous file with comments | « net/quic/quic_connection.h ('k') | net/quic/quic_connection_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698