| 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 <ostream> | 7 #include <ostream> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 3500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3511 | 3511 |
| 3512 // SetFromConfig sets the initial timeouts before negotiation. | 3512 // SetFromConfig sets the initial timeouts before negotiation. |
| 3513 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _)); | 3513 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _)); |
| 3514 QuicConfig config; | 3514 QuicConfig config; |
| 3515 connection_.SetFromConfig(config); | 3515 connection_.SetFromConfig(config); |
| 3516 // Subtract a second from the idle timeout on the client side. | 3516 // Subtract a second from the idle timeout on the client side. |
| 3517 QuicTime default_timeout = clock_.ApproximateNow().Add( | 3517 QuicTime default_timeout = clock_.ApproximateNow().Add( |
| 3518 QuicTime::Delta::FromSeconds(kInitialIdleTimeoutSecs - 1)); | 3518 QuicTime::Delta::FromSeconds(kInitialIdleTimeoutSecs - 1)); |
| 3519 EXPECT_EQ(default_timeout, connection_.GetTimeoutAlarm()->deadline()); | 3519 EXPECT_EQ(default_timeout, connection_.GetTimeoutAlarm()->deadline()); |
| 3520 | 3520 |
| 3521 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_CONNECTION_TIMED_OUT, false)); | 3521 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_NETWORK_IDLE_TIMEOUT, false)); |
| 3522 // Simulate the timeout alarm firing. | 3522 // Simulate the timeout alarm firing. |
| 3523 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(kInitialIdleTimeoutSecs - 1)); | 3523 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(kInitialIdleTimeoutSecs - 1)); |
| 3524 connection_.GetTimeoutAlarm()->Fire(); | 3524 connection_.GetTimeoutAlarm()->Fire(); |
| 3525 | 3525 |
| 3526 EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet()); | 3526 EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet()); |
| 3527 EXPECT_FALSE(connection_.connected()); | 3527 EXPECT_FALSE(connection_.connected()); |
| 3528 | 3528 |
| 3529 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); | 3529 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); |
| 3530 EXPECT_FALSE(connection_.GetPingAlarm()->IsSet()); | 3530 EXPECT_FALSE(connection_.GetPingAlarm()->IsSet()); |
| 3531 EXPECT_FALSE(connection_.GetFecAlarm()->IsSet()); | 3531 EXPECT_FALSE(connection_.GetFecAlarm()->IsSet()); |
| 3532 EXPECT_FALSE(connection_.GetResumeWritesAlarm()->IsSet()); | 3532 EXPECT_FALSE(connection_.GetResumeWritesAlarm()->IsSet()); |
| 3533 EXPECT_FALSE(connection_.GetRetransmissionAlarm()->IsSet()); | 3533 EXPECT_FALSE(connection_.GetRetransmissionAlarm()->IsSet()); |
| 3534 EXPECT_FALSE(connection_.GetSendAlarm()->IsSet()); | 3534 EXPECT_FALSE(connection_.GetSendAlarm()->IsSet()); |
| 3535 EXPECT_FALSE(connection_.GetMtuDiscoveryAlarm()->IsSet()); | 3535 EXPECT_FALSE(connection_.GetMtuDiscoveryAlarm()->IsSet()); |
| 3536 } | 3536 } |
| 3537 | 3537 |
| 3538 TEST_P(QuicConnectionTest, OverallTimeout) { | 3538 TEST_P(QuicConnectionTest, HandshakeTimeout) { |
| 3539 // Use a shorter overall connection timeout than idle timeout for this test. | 3539 // Use a shorter handshake timeout than idle timeout for this test. |
| 3540 const QuicTime::Delta timeout = QuicTime::Delta::FromSeconds(5); | 3540 const QuicTime::Delta timeout = QuicTime::Delta::FromSeconds(5); |
| 3541 connection_.SetNetworkTimeouts(timeout, timeout); | 3541 connection_.SetNetworkTimeouts(timeout, timeout); |
| 3542 EXPECT_TRUE(connection_.connected()); | 3542 EXPECT_TRUE(connection_.connected()); |
| 3543 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(AnyNumber()); | 3543 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(AnyNumber()); |
| 3544 | 3544 |
| 3545 QuicTime overall_timeout = clock_.ApproximateNow().Add(timeout).Subtract( | 3545 QuicTime handshake_timeout = clock_.ApproximateNow().Add(timeout).Subtract( |
| 3546 QuicTime::Delta::FromSeconds(1)); | 3546 QuicTime::Delta::FromSeconds(1)); |
| 3547 EXPECT_EQ(overall_timeout, connection_.GetTimeoutAlarm()->deadline()); | 3547 EXPECT_EQ(handshake_timeout, connection_.GetTimeoutAlarm()->deadline()); |
| 3548 EXPECT_TRUE(connection_.connected()); | 3548 EXPECT_TRUE(connection_.connected()); |
| 3549 | 3549 |
| 3550 // Send and ack new data 3 seconds later to lengthen the idle timeout. | 3550 // Send and ack new data 3 seconds later to lengthen the idle timeout. |
| 3551 SendStreamDataToPeer(1, "GET /", 0, kFin, nullptr); | 3551 SendStreamDataToPeer(1, "GET /", 0, kFin, nullptr); |
| 3552 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(3)); | 3552 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(3)); |
| 3553 QuicAckFrame frame = InitAckFrame(1); | 3553 QuicAckFrame frame = InitAckFrame(1); |
| 3554 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 3554 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 3555 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); | 3555 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
| 3556 ProcessAckPacket(&frame); | 3556 ProcessAckPacket(&frame); |
| 3557 | 3557 |
| 3558 // Fire early to verify it wouldn't timeout yet. | 3558 // Fire early to verify it wouldn't timeout yet. |
| 3559 connection_.GetTimeoutAlarm()->Fire(); | 3559 connection_.GetTimeoutAlarm()->Fire(); |
| 3560 EXPECT_TRUE(connection_.GetTimeoutAlarm()->IsSet()); | 3560 EXPECT_TRUE(connection_.GetTimeoutAlarm()->IsSet()); |
| 3561 EXPECT_TRUE(connection_.connected()); | 3561 EXPECT_TRUE(connection_.connected()); |
| 3562 | 3562 |
| 3563 clock_.AdvanceTime(timeout.Subtract(QuicTime::Delta::FromSeconds(2))); | 3563 clock_.AdvanceTime(timeout.Subtract(QuicTime::Delta::FromSeconds(2))); |
| 3564 | 3564 |
| 3565 EXPECT_CALL(visitor_, | 3565 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_HANDSHAKE_TIMEOUT, false)); |
| 3566 OnConnectionClosed(QUIC_CONNECTION_OVERALL_TIMED_OUT, false)); | |
| 3567 // Simulate the timeout alarm firing. | 3566 // Simulate the timeout alarm firing. |
| 3568 connection_.GetTimeoutAlarm()->Fire(); | 3567 connection_.GetTimeoutAlarm()->Fire(); |
| 3569 | 3568 |
| 3570 EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet()); | 3569 EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet()); |
| 3571 EXPECT_FALSE(connection_.connected()); | 3570 EXPECT_FALSE(connection_.connected()); |
| 3572 | 3571 |
| 3573 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); | 3572 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); |
| 3574 EXPECT_FALSE(connection_.GetPingAlarm()->IsSet()); | 3573 EXPECT_FALSE(connection_.GetPingAlarm()->IsSet()); |
| 3575 EXPECT_FALSE(connection_.GetFecAlarm()->IsSet()); | 3574 EXPECT_FALSE(connection_.GetFecAlarm()->IsSet()); |
| 3576 EXPECT_FALSE(connection_.GetResumeWritesAlarm()->IsSet()); | 3575 EXPECT_FALSE(connection_.GetResumeWritesAlarm()->IsSet()); |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3877 // network event at t=5ms. The alarm will reregister. | 3876 // network event at t=5ms. The alarm will reregister. |
| 3878 clock_.AdvanceTime(initial_idle_timeout.Subtract(five_ms)); | 3877 clock_.AdvanceTime(initial_idle_timeout.Subtract(five_ms)); |
| 3879 EXPECT_EQ(default_timeout, clock_.ApproximateNow()); | 3878 EXPECT_EQ(default_timeout, clock_.ApproximateNow()); |
| 3880 connection_.GetTimeoutAlarm()->Fire(); | 3879 connection_.GetTimeoutAlarm()->Fire(); |
| 3881 EXPECT_TRUE(connection_.GetTimeoutAlarm()->IsSet()); | 3880 EXPECT_TRUE(connection_.GetTimeoutAlarm()->IsSet()); |
| 3882 EXPECT_TRUE(connection_.connected()); | 3881 EXPECT_TRUE(connection_.connected()); |
| 3883 EXPECT_EQ(default_timeout.Add(five_ms), | 3882 EXPECT_EQ(default_timeout.Add(five_ms), |
| 3884 connection_.GetTimeoutAlarm()->deadline()); | 3883 connection_.GetTimeoutAlarm()->deadline()); |
| 3885 | 3884 |
| 3886 // This time, we should time out. | 3885 // This time, we should time out. |
| 3887 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_CONNECTION_TIMED_OUT, false)); | 3886 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_NETWORK_IDLE_TIMEOUT, false)); |
| 3888 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)); | 3887 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)); |
| 3889 clock_.AdvanceTime(five_ms); | 3888 clock_.AdvanceTime(five_ms); |
| 3890 EXPECT_EQ(default_timeout.Add(five_ms), clock_.ApproximateNow()); | 3889 EXPECT_EQ(default_timeout.Add(five_ms), clock_.ApproximateNow()); |
| 3891 connection_.GetTimeoutAlarm()->Fire(); | 3890 connection_.GetTimeoutAlarm()->Fire(); |
| 3892 EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet()); | 3891 EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet()); |
| 3893 EXPECT_FALSE(connection_.connected()); | 3892 EXPECT_FALSE(connection_.connected()); |
| 3894 } | 3893 } |
| 3895 | 3894 |
| 3896 TEST_P(QuicConnectionTest, OldTimeoutAfterSendSilentClose) { | 3895 TEST_P(QuicConnectionTest, OldTimeoutAfterSendSilentClose) { |
| 3897 ValueRestore<bool> old_flags(&FLAGS_quic_use_new_idle_timeout, false); | 3896 ValueRestore<bool> old_flags(&FLAGS_quic_use_new_idle_timeout, false); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3937 // network event at t=5ms. The alarm will reregister. | 3936 // network event at t=5ms. The alarm will reregister. |
| 3938 clock_.AdvanceTime(default_idle_timeout.Subtract(five_ms)); | 3937 clock_.AdvanceTime(default_idle_timeout.Subtract(five_ms)); |
| 3939 EXPECT_EQ(default_timeout, clock_.ApproximateNow()); | 3938 EXPECT_EQ(default_timeout, clock_.ApproximateNow()); |
| 3940 connection_.GetTimeoutAlarm()->Fire(); | 3939 connection_.GetTimeoutAlarm()->Fire(); |
| 3941 EXPECT_TRUE(connection_.GetTimeoutAlarm()->IsSet()); | 3940 EXPECT_TRUE(connection_.GetTimeoutAlarm()->IsSet()); |
| 3942 EXPECT_TRUE(connection_.connected()); | 3941 EXPECT_TRUE(connection_.connected()); |
| 3943 EXPECT_EQ(default_timeout.Add(five_ms), | 3942 EXPECT_EQ(default_timeout.Add(five_ms), |
| 3944 connection_.GetTimeoutAlarm()->deadline()); | 3943 connection_.GetTimeoutAlarm()->deadline()); |
| 3945 | 3944 |
| 3946 // This time, we should time out. | 3945 // This time, we should time out. |
| 3947 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_CONNECTION_TIMED_OUT, false)); | 3946 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_NETWORK_IDLE_TIMEOUT, false)); |
| 3948 clock_.AdvanceTime(five_ms); | 3947 clock_.AdvanceTime(five_ms); |
| 3949 EXPECT_EQ(default_timeout.Add(five_ms), clock_.ApproximateNow()); | 3948 EXPECT_EQ(default_timeout.Add(five_ms), clock_.ApproximateNow()); |
| 3950 connection_.GetTimeoutAlarm()->Fire(); | 3949 connection_.GetTimeoutAlarm()->Fire(); |
| 3951 EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet()); | 3950 EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet()); |
| 3952 EXPECT_FALSE(connection_.connected()); | 3951 EXPECT_FALSE(connection_.connected()); |
| 3953 } | 3952 } |
| 3954 | 3953 |
| 3955 TEST_P(QuicConnectionTest, TimeoutAfterSend) { | 3954 TEST_P(QuicConnectionTest, TimeoutAfterSend) { |
| 3956 ValueRestore<bool> old_flags(&FLAGS_quic_use_new_idle_timeout, true); | 3955 ValueRestore<bool> old_flags(&FLAGS_quic_use_new_idle_timeout, true); |
| 3957 EXPECT_TRUE(connection_.connected()); | 3956 EXPECT_TRUE(connection_.connected()); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 3981 // network event at t=5ms. The alarm will reregister. | 3980 // network event at t=5ms. The alarm will reregister. |
| 3982 clock_.AdvanceTime(initial_idle_timeout.Subtract(five_ms).Subtract(five_ms)); | 3981 clock_.AdvanceTime(initial_idle_timeout.Subtract(five_ms).Subtract(five_ms)); |
| 3983 EXPECT_EQ(default_timeout, clock_.ApproximateNow()); | 3982 EXPECT_EQ(default_timeout, clock_.ApproximateNow()); |
| 3984 connection_.GetTimeoutAlarm()->Fire(); | 3983 connection_.GetTimeoutAlarm()->Fire(); |
| 3985 EXPECT_TRUE(connection_.GetTimeoutAlarm()->IsSet()); | 3984 EXPECT_TRUE(connection_.GetTimeoutAlarm()->IsSet()); |
| 3986 EXPECT_TRUE(connection_.connected()); | 3985 EXPECT_TRUE(connection_.connected()); |
| 3987 EXPECT_EQ(default_timeout.Add(five_ms).Add(five_ms), | 3986 EXPECT_EQ(default_timeout.Add(five_ms).Add(five_ms), |
| 3988 connection_.GetTimeoutAlarm()->deadline()); | 3987 connection_.GetTimeoutAlarm()->deadline()); |
| 3989 | 3988 |
| 3990 // This time, we should time out. | 3989 // This time, we should time out. |
| 3991 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_CONNECTION_TIMED_OUT, false)); | 3990 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_NETWORK_IDLE_TIMEOUT, false)); |
| 3992 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)); | 3991 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)); |
| 3993 clock_.AdvanceTime(five_ms); | 3992 clock_.AdvanceTime(five_ms); |
| 3994 EXPECT_EQ(default_timeout.Add(five_ms), clock_.ApproximateNow()); | 3993 EXPECT_EQ(default_timeout.Add(five_ms), clock_.ApproximateNow()); |
| 3995 connection_.GetTimeoutAlarm()->Fire(); | 3994 connection_.GetTimeoutAlarm()->Fire(); |
| 3996 EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet()); | 3995 EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet()); |
| 3997 EXPECT_FALSE(connection_.connected()); | 3996 EXPECT_FALSE(connection_.connected()); |
| 3998 } | 3997 } |
| 3999 | 3998 |
| 4000 TEST_P(QuicConnectionTest, NewTimeoutAfterSendSilentClose) { | 3999 TEST_P(QuicConnectionTest, NewTimeoutAfterSendSilentClose) { |
| 4001 ValueRestore<bool> old_flags(&FLAGS_quic_use_new_idle_timeout, true); | 4000 ValueRestore<bool> old_flags(&FLAGS_quic_use_new_idle_timeout, true); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4045 // network event at t=5ms. The alarm will reregister. | 4044 // network event at t=5ms. The alarm will reregister. |
| 4046 clock_.AdvanceTime(default_idle_timeout.Subtract(five_ms).Subtract(five_ms)); | 4045 clock_.AdvanceTime(default_idle_timeout.Subtract(five_ms).Subtract(five_ms)); |
| 4047 EXPECT_EQ(default_timeout, clock_.ApproximateNow()); | 4046 EXPECT_EQ(default_timeout, clock_.ApproximateNow()); |
| 4048 connection_.GetTimeoutAlarm()->Fire(); | 4047 connection_.GetTimeoutAlarm()->Fire(); |
| 4049 EXPECT_TRUE(connection_.GetTimeoutAlarm()->IsSet()); | 4048 EXPECT_TRUE(connection_.GetTimeoutAlarm()->IsSet()); |
| 4050 EXPECT_TRUE(connection_.connected()); | 4049 EXPECT_TRUE(connection_.connected()); |
| 4051 EXPECT_EQ(default_timeout.Add(five_ms).Add(five_ms), | 4050 EXPECT_EQ(default_timeout.Add(five_ms).Add(five_ms), |
| 4052 connection_.GetTimeoutAlarm()->deadline()); | 4051 connection_.GetTimeoutAlarm()->deadline()); |
| 4053 | 4052 |
| 4054 // This time, we should time out. | 4053 // This time, we should time out. |
| 4055 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_CONNECTION_TIMED_OUT, false)); | 4054 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_NETWORK_IDLE_TIMEOUT, false)); |
| 4056 clock_.AdvanceTime(five_ms); | 4055 clock_.AdvanceTime(five_ms); |
| 4057 EXPECT_EQ(default_timeout.Add(five_ms), clock_.ApproximateNow()); | 4056 EXPECT_EQ(default_timeout.Add(five_ms), clock_.ApproximateNow()); |
| 4058 connection_.GetTimeoutAlarm()->Fire(); | 4057 connection_.GetTimeoutAlarm()->Fire(); |
| 4059 EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet()); | 4058 EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet()); |
| 4060 EXPECT_FALSE(connection_.connected()); | 4059 EXPECT_FALSE(connection_.connected()); |
| 4061 } | 4060 } |
| 4062 | 4061 |
| 4063 TEST_P(QuicConnectionTest, TimeoutAfterReceive) { | 4062 TEST_P(QuicConnectionTest, TimeoutAfterReceive) { |
| 4064 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 4063 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 4065 EXPECT_TRUE(connection_.connected()); | 4064 EXPECT_TRUE(connection_.connected()); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 4091 // network event at t=5ms. The alarm will reregister. | 4090 // network event at t=5ms. The alarm will reregister. |
| 4092 clock_.AdvanceTime(initial_idle_timeout.Subtract(five_ms)); | 4091 clock_.AdvanceTime(initial_idle_timeout.Subtract(five_ms)); |
| 4093 EXPECT_EQ(default_timeout, clock_.ApproximateNow()); | 4092 EXPECT_EQ(default_timeout, clock_.ApproximateNow()); |
| 4094 connection_.GetTimeoutAlarm()->Fire(); | 4093 connection_.GetTimeoutAlarm()->Fire(); |
| 4095 EXPECT_TRUE(connection_.connected()); | 4094 EXPECT_TRUE(connection_.connected()); |
| 4096 EXPECT_TRUE(connection_.GetTimeoutAlarm()->IsSet()); | 4095 EXPECT_TRUE(connection_.GetTimeoutAlarm()->IsSet()); |
| 4097 EXPECT_EQ(default_timeout.Add(five_ms), | 4096 EXPECT_EQ(default_timeout.Add(five_ms), |
| 4098 connection_.GetTimeoutAlarm()->deadline()); | 4097 connection_.GetTimeoutAlarm()->deadline()); |
| 4099 | 4098 |
| 4100 // This time, we should time out. | 4099 // This time, we should time out. |
| 4101 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_CONNECTION_TIMED_OUT, false)); | 4100 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_NETWORK_IDLE_TIMEOUT, false)); |
| 4102 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)); | 4101 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)); |
| 4103 clock_.AdvanceTime(five_ms); | 4102 clock_.AdvanceTime(five_ms); |
| 4104 EXPECT_EQ(default_timeout.Add(five_ms), clock_.ApproximateNow()); | 4103 EXPECT_EQ(default_timeout.Add(five_ms), clock_.ApproximateNow()); |
| 4105 connection_.GetTimeoutAlarm()->Fire(); | 4104 connection_.GetTimeoutAlarm()->Fire(); |
| 4106 EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet()); | 4105 EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet()); |
| 4107 EXPECT_FALSE(connection_.connected()); | 4106 EXPECT_FALSE(connection_.connected()); |
| 4108 } | 4107 } |
| 4109 | 4108 |
| 4110 TEST_P(QuicConnectionTest, TimeoutAfterReceiveNotSendWhenUnacked) { | 4109 TEST_P(QuicConnectionTest, TimeoutAfterReceiveNotSendWhenUnacked) { |
| 4111 ValueRestore<bool> old_flags(&FLAGS_quic_use_new_idle_timeout, true); | 4110 ValueRestore<bool> old_flags(&FLAGS_quic_use_new_idle_timeout, true); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4146 clock_.AdvanceTime(initial_idle_timeout.Subtract(five_ms)); | 4145 clock_.AdvanceTime(initial_idle_timeout.Subtract(five_ms)); |
| 4147 EXPECT_EQ(default_timeout, clock_.ApproximateNow()); | 4146 EXPECT_EQ(default_timeout, clock_.ApproximateNow()); |
| 4148 connection_.GetTimeoutAlarm()->Fire(); | 4147 connection_.GetTimeoutAlarm()->Fire(); |
| 4149 EXPECT_TRUE(connection_.connected()); | 4148 EXPECT_TRUE(connection_.connected()); |
| 4150 EXPECT_TRUE(connection_.GetTimeoutAlarm()->IsSet()); | 4149 EXPECT_TRUE(connection_.GetTimeoutAlarm()->IsSet()); |
| 4151 EXPECT_EQ(default_timeout.Add(five_ms), | 4150 EXPECT_EQ(default_timeout.Add(five_ms), |
| 4152 connection_.GetTimeoutAlarm()->deadline()); | 4151 connection_.GetTimeoutAlarm()->deadline()); |
| 4153 | 4152 |
| 4154 // Now, send packets while advancing the time and verify that the connection | 4153 // Now, send packets while advancing the time and verify that the connection |
| 4155 // eventually times out. | 4154 // eventually times out. |
| 4156 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_CONNECTION_TIMED_OUT, false)); | 4155 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_NETWORK_IDLE_TIMEOUT, false)); |
| 4157 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(AnyNumber()); | 4156 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(AnyNumber()); |
| 4158 for (int i = 0; i < 100 && connection_.connected(); ++i) { | 4157 for (int i = 0; i < 100 && connection_.connected(); ++i) { |
| 4159 VLOG(1) << "sending data packet"; | 4158 VLOG(1) << "sending data packet"; |
| 4160 connection_.SendStreamDataWithString(kClientDataStreamId1, "foo", 0, !kFin, | 4159 connection_.SendStreamDataWithString(kClientDataStreamId1, "foo", 0, !kFin, |
| 4161 nullptr); | 4160 nullptr); |
| 4162 connection_.GetTimeoutAlarm()->Fire(); | 4161 connection_.GetTimeoutAlarm()->Fire(); |
| 4163 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(1)); | 4162 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(1)); |
| 4164 } | 4163 } |
| 4165 EXPECT_FALSE(connection_.connected()); | 4164 EXPECT_FALSE(connection_.connected()); |
| 4166 EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet()); | 4165 EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet()); |
| (...skipping 1339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5506 QuicStreamFrame stream_frame(1u, false, 0u, StringPiece()); | 5505 QuicStreamFrame stream_frame(1u, false, 0u, StringPiece()); |
| 5507 EXPECT_DFATAL(ProcessFramePacket(QuicFrame(&stream_frame)), | 5506 EXPECT_DFATAL(ProcessFramePacket(QuicFrame(&stream_frame)), |
| 5508 "Received a packet with multipath flag on when multipath is " | 5507 "Received a packet with multipath flag on when multipath is " |
| 5509 "not enabled."); | 5508 "not enabled."); |
| 5510 EXPECT_FALSE(connection_.connected()); | 5509 EXPECT_FALSE(connection_.connected()); |
| 5511 } | 5510 } |
| 5512 | 5511 |
| 5513 } // namespace | 5512 } // namespace |
| 5514 } // namespace test | 5513 } // namespace test |
| 5515 } // namespace net | 5514 } // namespace net |
| OLD | NEW |