| 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/core/quic_connection.h" | 5 #include "net/quic/core/quic_connection.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <ostream> | 9 #include <ostream> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 3269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3280 SendStreamDataToPeer(kClientDataStreamId1, "foo", 0, kFin, nullptr); | 3280 SendStreamDataToPeer(kClientDataStreamId1, "foo", 0, kFin, nullptr); |
| 3281 EXPECT_EQ(default_timeout, connection_.GetTimeoutAlarm()->deadline()); | 3281 EXPECT_EQ(default_timeout, connection_.GetTimeoutAlarm()->deadline()); |
| 3282 | 3282 |
| 3283 // The original alarm will fire. We should not time out because we had a | 3283 // The original alarm will fire. We should not time out because we had a |
| 3284 // network event at t=5ms. The alarm will reregister. | 3284 // network event at t=5ms. The alarm will reregister. |
| 3285 clock_.AdvanceTime(initial_idle_timeout - five_ms - five_ms); | 3285 clock_.AdvanceTime(initial_idle_timeout - five_ms - five_ms); |
| 3286 EXPECT_EQ(default_timeout, clock_.ApproximateNow()); | 3286 EXPECT_EQ(default_timeout, clock_.ApproximateNow()); |
| 3287 connection_.GetTimeoutAlarm()->Fire(); | 3287 connection_.GetTimeoutAlarm()->Fire(); |
| 3288 EXPECT_TRUE(connection_.GetTimeoutAlarm()->IsSet()); | 3288 EXPECT_TRUE(connection_.GetTimeoutAlarm()->IsSet()); |
| 3289 EXPECT_TRUE(connection_.connected()); | 3289 EXPECT_TRUE(connection_.connected()); |
| 3290 if (FLAGS_quic_better_last_send_for_timeout) { | 3290 EXPECT_EQ(default_timeout + five_ms, |
| 3291 EXPECT_EQ(default_timeout + five_ms, | 3291 connection_.GetTimeoutAlarm()->deadline()); |
| 3292 connection_.GetTimeoutAlarm()->deadline()); | |
| 3293 } else { | |
| 3294 EXPECT_EQ(default_timeout + five_ms + five_ms, | |
| 3295 connection_.GetTimeoutAlarm()->deadline()); | |
| 3296 } | |
| 3297 | 3292 |
| 3298 // This time, we should time out. | 3293 // This time, we should time out. |
| 3299 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_NETWORK_IDLE_TIMEOUT, _, | 3294 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_NETWORK_IDLE_TIMEOUT, _, |
| 3300 ConnectionCloseSource::FROM_SELF)); | 3295 ConnectionCloseSource::FROM_SELF)); |
| 3301 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)); | 3296 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)); |
| 3302 clock_.AdvanceTime(five_ms); | 3297 clock_.AdvanceTime(five_ms); |
| 3303 EXPECT_EQ(default_timeout + five_ms, clock_.ApproximateNow()); | 3298 EXPECT_EQ(default_timeout + five_ms, clock_.ApproximateNow()); |
| 3304 connection_.GetTimeoutAlarm()->Fire(); | 3299 connection_.GetTimeoutAlarm()->Fire(); |
| 3305 EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet()); | 3300 EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet()); |
| 3306 EXPECT_FALSE(connection_.connected()); | 3301 EXPECT_FALSE(connection_.connected()); |
| 3307 } | 3302 } |
| 3308 | 3303 |
| 3309 TEST_P(QuicConnectionTest, TimeoutAfterRetransmission) { | 3304 TEST_P(QuicConnectionTest, TimeoutAfterRetransmission) { |
| 3310 FLAGS_quic_better_last_send_for_timeout = true; | |
| 3311 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 3305 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 3312 EXPECT_TRUE(connection_.connected()); | 3306 EXPECT_TRUE(connection_.connected()); |
| 3313 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _)); | 3307 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _)); |
| 3314 QuicConfig config; | 3308 QuicConfig config; |
| 3315 connection_.SetFromConfig(config); | 3309 connection_.SetFromConfig(config); |
| 3316 EXPECT_FALSE(QuicConnectionPeer::IsSilentCloseEnabled(&connection_)); | 3310 EXPECT_FALSE(QuicConnectionPeer::IsSilentCloseEnabled(&connection_)); |
| 3317 | 3311 |
| 3318 const QuicTime start_time = clock_.Now(); | 3312 const QuicTime start_time = clock_.Now(); |
| 3319 const QuicTime::Delta initial_idle_timeout = | 3313 const QuicTime::Delta initial_idle_timeout = |
| 3320 QuicTime::Delta::FromSeconds(kInitialIdleTimeoutSecs - 1); | 3314 QuicTime::Delta::FromSeconds(kInitialIdleTimeoutSecs - 1); |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3423 SendStreamDataToPeer(kClientDataStreamId1, "foo", 0, kFin, nullptr); | 3417 SendStreamDataToPeer(kClientDataStreamId1, "foo", 0, kFin, nullptr); |
| 3424 EXPECT_EQ(default_timeout, connection_.GetTimeoutAlarm()->deadline()); | 3418 EXPECT_EQ(default_timeout, connection_.GetTimeoutAlarm()->deadline()); |
| 3425 | 3419 |
| 3426 // The original alarm will fire. We should not time out because we had a | 3420 // The original alarm will fire. We should not time out because we had a |
| 3427 // network event at t=5ms. The alarm will reregister. | 3421 // network event at t=5ms. The alarm will reregister. |
| 3428 clock_.AdvanceTime(default_idle_timeout - five_ms - five_ms); | 3422 clock_.AdvanceTime(default_idle_timeout - five_ms - five_ms); |
| 3429 EXPECT_EQ(default_timeout, clock_.ApproximateNow()); | 3423 EXPECT_EQ(default_timeout, clock_.ApproximateNow()); |
| 3430 connection_.GetTimeoutAlarm()->Fire(); | 3424 connection_.GetTimeoutAlarm()->Fire(); |
| 3431 EXPECT_TRUE(connection_.GetTimeoutAlarm()->IsSet()); | 3425 EXPECT_TRUE(connection_.GetTimeoutAlarm()->IsSet()); |
| 3432 EXPECT_TRUE(connection_.connected()); | 3426 EXPECT_TRUE(connection_.connected()); |
| 3433 if (FLAGS_quic_better_last_send_for_timeout) { | 3427 EXPECT_EQ(default_timeout + five_ms, |
| 3434 EXPECT_EQ(default_timeout + five_ms, | 3428 connection_.GetTimeoutAlarm()->deadline()); |
| 3435 connection_.GetTimeoutAlarm()->deadline()); | |
| 3436 } else { | |
| 3437 EXPECT_EQ(default_timeout + five_ms + five_ms, | |
| 3438 connection_.GetTimeoutAlarm()->deadline()); | |
| 3439 } | |
| 3440 | 3429 |
| 3441 // This time, we should time out. | 3430 // This time, we should time out. |
| 3442 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_NETWORK_IDLE_TIMEOUT, _, | 3431 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_NETWORK_IDLE_TIMEOUT, _, |
| 3443 ConnectionCloseSource::FROM_SELF)); | 3432 ConnectionCloseSource::FROM_SELF)); |
| 3444 clock_.AdvanceTime(five_ms); | 3433 clock_.AdvanceTime(five_ms); |
| 3445 EXPECT_EQ(default_timeout + five_ms, clock_.ApproximateNow()); | 3434 EXPECT_EQ(default_timeout + five_ms, clock_.ApproximateNow()); |
| 3446 connection_.GetTimeoutAlarm()->Fire(); | 3435 connection_.GetTimeoutAlarm()->Fire(); |
| 3447 EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet()); | 3436 EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet()); |
| 3448 EXPECT_FALSE(connection_.connected()); | 3437 EXPECT_FALSE(connection_.connected()); |
| 3449 } | 3438 } |
| (...skipping 1814 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5264 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, nullptr); | 5253 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, nullptr); |
| 5265 EXPECT_EQ(1u, writer_->frame_count()); | 5254 EXPECT_EQ(1u, writer_->frame_count()); |
| 5266 EXPECT_FALSE(writer_->connection_close_frames().empty()); | 5255 EXPECT_FALSE(writer_->connection_close_frames().empty()); |
| 5267 // Ack frame is not bundled in connection close packet. | 5256 // Ack frame is not bundled in connection close packet. |
| 5268 EXPECT_TRUE(writer_->ack_frames().empty()); | 5257 EXPECT_TRUE(writer_->ack_frames().empty()); |
| 5269 } | 5258 } |
| 5270 | 5259 |
| 5271 } // namespace | 5260 } // namespace |
| 5272 } // namespace test | 5261 } // namespace test |
| 5273 } // namespace net | 5262 } // namespace net |
| OLD | NEW |