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 2634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2645 SendAckPacketToPeer(); | 2645 SendAckPacketToPeer(); |
2646 // Process an FEC packet, and revive the missing data packet | 2646 // Process an FEC packet, and revive the missing data packet |
2647 // but only contact the receive_algorithm once. | 2647 // but only contact the receive_algorithm once. |
2648 EXPECT_CALL(*receive_algorithm_, RecordIncomingPacket(_, _, _)); | 2648 EXPECT_CALL(*receive_algorithm_, RecordIncomingPacket(_, _, _)); |
2649 ProcessFecPacket(2, 1, true, !kEntropyFlag, NULL); | 2649 ProcessFecPacket(2, 1, true, !kEntropyFlag, NULL); |
2650 } | 2650 } |
2651 | 2651 |
2652 TEST_P(QuicConnectionTest, InitialTimeout) { | 2652 TEST_P(QuicConnectionTest, InitialTimeout) { |
2653 EXPECT_TRUE(connection_.connected()); | 2653 EXPECT_TRUE(connection_.connected()); |
2654 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_CONNECTION_TIMED_OUT, false)); | 2654 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_CONNECTION_TIMED_OUT, false)); |
2655 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)); | 2655 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(AnyNumber()); |
2656 | 2656 |
2657 QuicTime default_timeout = clock_.ApproximateNow().Add( | 2657 QuicTime default_timeout = clock_.ApproximateNow().Add( |
2658 QuicTime::Delta::FromSeconds(kDefaultInitialTimeoutSecs)); | 2658 QuicTime::Delta::FromSeconds(kDefaultInitialTimeoutSecs)); |
2659 EXPECT_EQ(default_timeout, connection_.GetTimeoutAlarm()->deadline()); | 2659 EXPECT_EQ(default_timeout, connection_.GetTimeoutAlarm()->deadline()); |
2660 | 2660 |
| 2661 if (FLAGS_quic_timeouts_require_activity) { |
| 2662 // Simulate the timeout alarm firing. |
| 2663 clock_.AdvanceTime( |
| 2664 QuicTime::Delta::FromSeconds(kDefaultInitialTimeoutSecs)); |
| 2665 connection_.GetTimeoutAlarm()->Fire(); |
| 2666 // We should not actually timeout until a packet is sent. |
| 2667 EXPECT_TRUE(connection_.connected()); |
| 2668 SendStreamDataToPeer(1, "GET /", 0, kFin, NULL); |
| 2669 } |
| 2670 |
2661 // Simulate the timeout alarm firing. | 2671 // Simulate the timeout alarm firing. |
2662 clock_.AdvanceTime( | 2672 clock_.AdvanceTime( |
2663 QuicTime::Delta::FromSeconds(kDefaultInitialTimeoutSecs)); | 2673 QuicTime::Delta::FromSeconds(kDefaultInitialTimeoutSecs)); |
2664 connection_.GetTimeoutAlarm()->Fire(); | 2674 connection_.GetTimeoutAlarm()->Fire(); |
| 2675 |
2665 EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet()); | 2676 EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet()); |
2666 EXPECT_FALSE(connection_.connected()); | 2677 EXPECT_FALSE(connection_.connected()); |
2667 | 2678 |
2668 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); | 2679 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); |
2669 EXPECT_FALSE(connection_.GetPingAlarm()->IsSet()); | 2680 EXPECT_FALSE(connection_.GetPingAlarm()->IsSet()); |
2670 EXPECT_FALSE(connection_.GetResumeWritesAlarm()->IsSet()); | 2681 EXPECT_FALSE(connection_.GetResumeWritesAlarm()->IsSet()); |
2671 EXPECT_FALSE(connection_.GetRetransmissionAlarm()->IsSet()); | 2682 EXPECT_FALSE(connection_.GetRetransmissionAlarm()->IsSet()); |
2672 EXPECT_FALSE(connection_.GetSendAlarm()->IsSet()); | 2683 EXPECT_FALSE(connection_.GetSendAlarm()->IsSet()); |
2673 EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet()); | 2684 EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet()); |
2674 } | 2685 } |
(...skipping 1220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3895 QuicBlockedFrame blocked; | 3906 QuicBlockedFrame blocked; |
3896 blocked.stream_id = 3; | 3907 blocked.stream_id = 3; |
3897 EXPECT_CALL(visitor_, OnBlockedFrames(_)); | 3908 EXPECT_CALL(visitor_, OnBlockedFrames(_)); |
3898 ProcessFramePacket(QuicFrame(&blocked)); | 3909 ProcessFramePacket(QuicFrame(&blocked)); |
3899 EXPECT_TRUE(ack_alarm->IsSet()); | 3910 EXPECT_TRUE(ack_alarm->IsSet()); |
3900 } | 3911 } |
3901 | 3912 |
3902 } // namespace | 3913 } // namespace |
3903 } // namespace test | 3914 } // namespace test |
3904 } // namespace net | 3915 } // namespace net |
OLD | NEW |