| 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 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 1626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1637 // If the socket buffers the the data, then the packet should not | 1637 // If the socket buffers the the data, then the packet should not |
| 1638 // be queued and sent again, which would result in an unnecessary | 1638 // be queued and sent again, which would result in an unnecessary |
| 1639 // duplicate packet being sent. The helper must call OnCanWrite | 1639 // duplicate packet being sent. The helper must call OnCanWrite |
| 1640 // when the write completes, and OnWriteError if an error occurs. | 1640 // when the write completes, and OnWriteError if an error occurs. |
| 1641 if (!writer_->IsWriteBlockedDataBuffered()) { | 1641 if (!writer_->IsWriteBlockedDataBuffered()) { |
| 1642 return false; | 1642 return false; |
| 1643 } | 1643 } |
| 1644 } | 1644 } |
| 1645 if (result.status != WRITE_STATUS_ERROR && debug_visitor_ != nullptr) { | 1645 if (result.status != WRITE_STATUS_ERROR && debug_visitor_ != nullptr) { |
| 1646 // Pass the write result to the visitor. | 1646 // Pass the write result to the visitor. |
| 1647 debug_visitor_->OnPacketSent(*packet, packet->original_packet_number, | 1647 debug_visitor_->OnPacketSent(*packet, packet->original_path_id, |
| 1648 packet->original_packet_number, |
| 1648 packet->transmission_type, packet_send_time); | 1649 packet->transmission_type, packet_send_time); |
| 1649 } | 1650 } |
| 1650 if (packet->transmission_type == NOT_RETRANSMISSION) { | 1651 if (packet->transmission_type == NOT_RETRANSMISSION) { |
| 1651 time_of_last_sent_new_packet_ = packet_send_time; | 1652 time_of_last_sent_new_packet_ = packet_send_time; |
| 1652 if (IsRetransmittable(*packet) == HAS_RETRANSMITTABLE_DATA && | 1653 if (IsRetransmittable(*packet) == HAS_RETRANSMITTABLE_DATA && |
| 1653 last_send_for_timeout_ <= time_of_last_received_packet_) { | 1654 last_send_for_timeout_ <= time_of_last_received_packet_) { |
| 1654 last_send_for_timeout_ = packet_send_time; | 1655 last_send_for_timeout_ = packet_send_time; |
| 1655 } | 1656 } |
| 1656 } | 1657 } |
| 1657 SetPingAlarm(); | 1658 SetPingAlarm(); |
| 1658 MaybeSetMtuAlarm(); | 1659 MaybeSetMtuAlarm(); |
| 1659 DVLOG(1) << ENDPOINT << "time we began writing last sent packet: " | 1660 DVLOG(1) << ENDPOINT << "time we began writing last sent packet: " |
| 1660 << packet_send_time.ToDebuggingValue(); | 1661 << packet_send_time.ToDebuggingValue(); |
| 1661 | 1662 |
| 1662 // TODO(ianswett): Change the packet number length and other packet creator | 1663 // TODO(ianswett): Change the packet number length and other packet creator |
| 1663 // options by a more explicit API than setting a struct value directly, | 1664 // options by a more explicit API than setting a struct value directly, |
| 1664 // perhaps via the NetworkChangeVisitor. | 1665 // perhaps via the NetworkChangeVisitor. |
| 1665 packet_generator_.UpdateSequenceNumberLength( | 1666 packet_generator_.UpdateSequenceNumberLength( |
| 1666 sent_packet_manager_.least_packet_awaited_by_peer(), | 1667 sent_packet_manager_.least_packet_awaited_by_peer(), |
| 1667 sent_packet_manager_.EstimateMaxPacketsInFlight(max_packet_length())); | 1668 sent_packet_manager_.EstimateMaxPacketsInFlight(max_packet_length())); |
| 1668 | 1669 |
| 1669 bool reset_retransmission_alarm = sent_packet_manager_.OnPacketSent( | 1670 bool reset_retransmission_alarm = sent_packet_manager_.OnPacketSent( |
| 1670 packet, packet->original_packet_number, packet_send_time, | 1671 packet, packet->original_path_id, packet->original_packet_number, |
| 1671 packet->transmission_type, IsRetransmittable(*packet)); | 1672 packet_send_time, packet->transmission_type, IsRetransmittable(*packet)); |
| 1672 | 1673 |
| 1673 if (reset_retransmission_alarm || !retransmission_alarm_->IsSet()) { | 1674 if (reset_retransmission_alarm || !retransmission_alarm_->IsSet()) { |
| 1674 SetRetransmissionAlarm(); | 1675 SetRetransmissionAlarm(); |
| 1675 } | 1676 } |
| 1676 | 1677 |
| 1677 stats_.bytes_sent += result.bytes_written; | 1678 stats_.bytes_sent += result.bytes_written; |
| 1678 ++stats_.packets_sent; | 1679 ++stats_.packets_sent; |
| 1679 if (packet->transmission_type != NOT_RETRANSMISSION) { | 1680 if (packet->transmission_type != NOT_RETRANSMISSION) { |
| 1680 stats_.bytes_retransmitted += result.bytes_written; | 1681 stats_.bytes_retransmitted += result.bytes_written; |
| 1681 ++stats_.packets_retransmitted; | 1682 ++stats_.packets_retransmitted; |
| (...skipping 740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2422 } | 2423 } |
| 2423 | 2424 |
| 2424 StringPiece QuicConnection::GetCurrentPacket() { | 2425 StringPiece QuicConnection::GetCurrentPacket() { |
| 2425 if (current_packet_data_ == nullptr) { | 2426 if (current_packet_data_ == nullptr) { |
| 2426 return StringPiece(); | 2427 return StringPiece(); |
| 2427 } | 2428 } |
| 2428 return StringPiece(current_packet_data_, last_size_); | 2429 return StringPiece(current_packet_data_, last_size_); |
| 2429 } | 2430 } |
| 2430 | 2431 |
| 2431 } // namespace net | 2432 } // namespace net |
| OLD | NEW |