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 1390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1401 << QuicUtils::StringToHexASCIIDump( | 1401 << QuicUtils::StringToHexASCIIDump( |
1402 packet->serialized_packet.packet->AsStringPiece()); | 1402 packet->serialized_packet.packet->AsStringPiece()); |
1403 | 1403 |
1404 WriteResult result = writer_->WritePacket(encrypted->data(), | 1404 WriteResult result = writer_->WritePacket(encrypted->data(), |
1405 encrypted->length(), | 1405 encrypted->length(), |
1406 self_address().address(), | 1406 self_address().address(), |
1407 peer_address()); | 1407 peer_address()); |
1408 if (result.error_code == ERR_IO_PENDING) { | 1408 if (result.error_code == ERR_IO_PENDING) { |
1409 DCHECK_EQ(WRITE_STATUS_BLOCKED, result.status); | 1409 DCHECK_EQ(WRITE_STATUS_BLOCKED, result.status); |
1410 } | 1410 } |
1411 if (debug_visitor_.get() != nullptr) { | |
1412 // Pass the write result to the visitor. | |
1413 debug_visitor_->OnPacketSent(sequence_number, | |
1414 packet->original_sequence_number, | |
1415 packet->encryption_level, | |
1416 packet->transmission_type, | |
1417 *encrypted, | |
1418 result); | |
1419 } | |
1420 | 1411 |
1421 if (result.status == WRITE_STATUS_BLOCKED) { | 1412 if (result.status == WRITE_STATUS_BLOCKED) { |
1422 visitor_->OnWriteBlocked(); | 1413 visitor_->OnWriteBlocked(); |
1423 // If the socket buffers the the data, then the packet should not | 1414 // If the socket buffers the the data, then the packet should not |
1424 // be queued and sent again, which would result in an unnecessary | 1415 // be queued and sent again, which would result in an unnecessary |
1425 // duplicate packet being sent. The helper must call OnCanWrite | 1416 // duplicate packet being sent. The helper must call OnCanWrite |
1426 // when the write completes, and OnWriteError if an error occurs. | 1417 // when the write completes, and OnWriteError if an error occurs. |
1427 if (!writer_->IsWriteBlockedDataBuffered()) { | 1418 if (!writer_->IsWriteBlockedDataBuffered()) { |
1428 return false; | 1419 return false; |
1429 } | 1420 } |
1430 } | 1421 } |
1431 QuicTime now = clock_->Now(); | 1422 QuicTime now = clock_->Now(); |
| 1423 if (result.status != WRITE_STATUS_ERROR && debug_visitor_.get() != nullptr) { |
| 1424 // Pass the write result to the visitor. |
| 1425 debug_visitor_->OnPacketSent(packet->serialized_packet, |
| 1426 packet->original_sequence_number, |
| 1427 packet->encryption_level, |
| 1428 packet->transmission_type, |
| 1429 *encrypted, |
| 1430 now); |
| 1431 } |
1432 if (packet->transmission_type == NOT_RETRANSMISSION) { | 1432 if (packet->transmission_type == NOT_RETRANSMISSION) { |
1433 time_of_last_sent_new_packet_ = now; | 1433 time_of_last_sent_new_packet_ = now; |
1434 } | 1434 } |
1435 SetPingAlarm(); | 1435 SetPingAlarm(); |
1436 DVLOG(1) << ENDPOINT << "time of last sent packet: " | 1436 DVLOG(1) << ENDPOINT << "time of last sent packet: " |
1437 << now.ToDebuggingValue(); | 1437 << now.ToDebuggingValue(); |
1438 | 1438 |
1439 // TODO(ianswett): Change the sequence number length and other packet creator | 1439 // TODO(ianswett): Change the sequence number length and other packet creator |
1440 // options by a more explicit API than setting a struct value directly, | 1440 // options by a more explicit API than setting a struct value directly, |
1441 // perhaps via the NetworkChangeVisitor. | 1441 // perhaps via the NetworkChangeVisitor. |
(...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2032 } | 2032 } |
2033 for (size_t i = 0; i < retransmittable_frames->frames().size(); ++i) { | 2033 for (size_t i = 0; i < retransmittable_frames->frames().size(); ++i) { |
2034 if (retransmittable_frames->frames()[i].type == CONNECTION_CLOSE_FRAME) { | 2034 if (retransmittable_frames->frames()[i].type == CONNECTION_CLOSE_FRAME) { |
2035 return true; | 2035 return true; |
2036 } | 2036 } |
2037 } | 2037 } |
2038 return false; | 2038 return false; |
2039 } | 2039 } |
2040 | 2040 |
2041 } // namespace net | 2041 } // namespace net |
OLD | NEW |