| 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 "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "net/base/net_errors.h" | 10 #include "net/base/net_errors.h" |
| (...skipping 1971 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1982 writer_->set_is_write_blocked_data_buffered(true); | 1982 writer_->set_is_write_blocked_data_buffered(true); |
| 1983 // Simulate the retransmission alarm firing. | 1983 // Simulate the retransmission alarm firing. |
| 1984 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(_)); | 1984 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(_)); |
| 1985 clock_.AdvanceTime(DefaultRetransmissionTime()); | 1985 clock_.AdvanceTime(DefaultRetransmissionTime()); |
| 1986 connection_.GetRetransmissionAlarm()->Fire(); | 1986 connection_.GetRetransmissionAlarm()->Fire(); |
| 1987 | 1987 |
| 1988 // Ack the sent packet before the callback returns, which happens in | 1988 // Ack the sent packet before the callback returns, which happens in |
| 1989 // rare circumstances with write blocked sockets. | 1989 // rare circumstances with write blocked sockets. |
| 1990 QuicAckFrame ack = InitAckFrame(1, 0); | 1990 QuicAckFrame ack = InitAckFrame(1, 0); |
| 1991 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); | 1991 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
| 1992 EXPECT_CALL(*send_algorithm_, RevertRetransmissionTimeout()); |
| 1992 ProcessAckPacket(&ack); | 1993 ProcessAckPacket(&ack); |
| 1993 | 1994 |
| 1994 connection_.OnPacketSent(WriteResult(WRITE_STATUS_OK, 0)); | 1995 connection_.OnPacketSent(WriteResult(WRITE_STATUS_OK, 0)); |
| 1995 // There is now a pending packet, but with no retransmittable frames. | 1996 // There is now a pending packet, but with no retransmittable frames. |
| 1996 EXPECT_TRUE(connection_.GetRetransmissionAlarm()->IsSet()); | 1997 EXPECT_TRUE(connection_.GetRetransmissionAlarm()->IsSet()); |
| 1997 EXPECT_FALSE(connection_.sent_packet_manager().HasRetransmittableFrames(2)); | 1998 EXPECT_FALSE(connection_.sent_packet_manager().HasRetransmittableFrames(2)); |
| 1998 } | 1999 } |
| 1999 | 2000 |
| 2000 TEST_P(QuicConnectionTest, AlarmsWhenWriteBlocked) { | 2001 TEST_P(QuicConnectionTest, AlarmsWhenWriteBlocked) { |
| 2001 // Block the connection. | 2002 // Block the connection. |
| (...skipping 1547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3549 NackPacket(3, &nack_three); | 3550 NackPacket(3, &nack_three); |
| 3550 NackPacket(1, &nack_three); | 3551 NackPacket(1, &nack_three); |
| 3551 SequenceNumberSet lost_packets; | 3552 SequenceNumberSet lost_packets; |
| 3552 lost_packets.insert(1); | 3553 lost_packets.insert(1); |
| 3553 lost_packets.insert(3); | 3554 lost_packets.insert(3); |
| 3554 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) | 3555 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) |
| 3555 .WillOnce(Return(lost_packets)); | 3556 .WillOnce(Return(lost_packets)); |
| 3556 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); | 3557 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
| 3557 EXPECT_CALL(visitor_, OnCanWrite()).Times(2); | 3558 EXPECT_CALL(visitor_, OnCanWrite()).Times(2); |
| 3558 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 3559 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 3560 EXPECT_CALL(*send_algorithm_, RevertRetransmissionTimeout()); |
| 3559 ProcessAckPacket(&nack_three); | 3561 ProcessAckPacket(&nack_three); |
| 3560 | 3562 |
| 3561 EXPECT_CALL(*send_algorithm_, BandwidthEstimate()).WillOnce( | 3563 EXPECT_CALL(*send_algorithm_, BandwidthEstimate()).WillOnce( |
| 3562 Return(QuicBandwidth::Zero())); | 3564 Return(QuicBandwidth::Zero())); |
| 3563 | 3565 |
| 3564 const QuicConnectionStats& stats = connection_.GetStats(); | 3566 const QuicConnectionStats& stats = connection_.GetStats(); |
| 3565 EXPECT_EQ(3 * first_packet_size + 2 * second_packet_size - kQuicVersionSize, | 3567 EXPECT_EQ(3 * first_packet_size + 2 * second_packet_size - kQuicVersionSize, |
| 3566 stats.bytes_sent); | 3568 stats.bytes_sent); |
| 3567 EXPECT_EQ(5u, stats.packets_sent); | 3569 EXPECT_EQ(5u, stats.packets_sent); |
| 3568 EXPECT_EQ(2 * first_packet_size + second_packet_size - kQuicVersionSize, | 3570 EXPECT_EQ(2 * first_packet_size + second_packet_size - kQuicVersionSize, |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3800 connection_.GetRetransmissionAlarm()->deadline()); | 3802 connection_.GetRetransmissionAlarm()->deadline()); |
| 3801 // Simulate the retransmission alarm firing. | 3803 // Simulate the retransmission alarm firing. |
| 3802 clock_.AdvanceTime(DefaultRetransmissionTime()); | 3804 clock_.AdvanceTime(DefaultRetransmissionTime()); |
| 3803 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true)); | 3805 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true)); |
| 3804 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, 2u, _, _)); | 3806 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, 2u, _, _)); |
| 3805 connection_.GetRetransmissionAlarm()->Fire(); | 3807 connection_.GetRetransmissionAlarm()->Fire(); |
| 3806 EXPECT_EQ(2u, writer_->header().packet_sequence_number); | 3808 EXPECT_EQ(2u, writer_->header().packet_sequence_number); |
| 3807 // We do not raise the high water mark yet. | 3809 // We do not raise the high water mark yet. |
| 3808 EXPECT_EQ(1u, outgoing_ack()->sent_info.least_unacked); | 3810 EXPECT_EQ(1u, outgoing_ack()->sent_info.least_unacked); |
| 3809 | 3811 |
| 3810 // Ack the original packet. | 3812 // Ack the original packet, which will revert the RTO. |
| 3811 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 3813 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 3812 EXPECT_CALL(*delegate, OnAckNotification(1, _, 1, _, _)); | 3814 EXPECT_CALL(*delegate, OnAckNotification(1, _, 1, _, _)); |
| 3815 EXPECT_CALL(*send_algorithm_, RevertRetransmissionTimeout()); |
| 3813 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); | 3816 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
| 3814 QuicAckFrame ack_frame = InitAckFrame(1, 0); | 3817 QuicAckFrame ack_frame = InitAckFrame(1, 0); |
| 3815 ProcessAckPacket(&ack_frame); | 3818 ProcessAckPacket(&ack_frame); |
| 3816 | 3819 |
| 3817 // Delegate is not notified again when the retransmit is acked. | 3820 // Delegate is not notified again when the retransmit is acked. |
| 3818 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); | 3821 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
| 3819 QuicAckFrame second_ack_frame = InitAckFrame(2, 0); | 3822 QuicAckFrame second_ack_frame = InitAckFrame(2, 0); |
| 3820 ProcessAckPacket(&second_ack_frame); | 3823 ProcessAckPacket(&second_ack_frame); |
| 3821 } | 3824 } |
| 3822 | 3825 |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4026 QuicBlockedFrame blocked; | 4029 QuicBlockedFrame blocked; |
| 4027 blocked.stream_id = 3; | 4030 blocked.stream_id = 3; |
| 4028 EXPECT_CALL(visitor_, OnBlockedFrames(_)); | 4031 EXPECT_CALL(visitor_, OnBlockedFrames(_)); |
| 4029 ProcessFramePacket(QuicFrame(&blocked)); | 4032 ProcessFramePacket(QuicFrame(&blocked)); |
| 4030 EXPECT_TRUE(ack_alarm->IsSet()); | 4033 EXPECT_TRUE(ack_alarm->IsSet()); |
| 4031 } | 4034 } |
| 4032 | 4035 |
| 4033 } // namespace | 4036 } // namespace |
| 4034 } // namespace test | 4037 } // namespace test |
| 4035 } // namespace net | 4038 } // namespace net |
| OLD | NEW |