| 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 3467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3478 InSequence s; | 3478 InSequence s; |
| 3479 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, first_packet_size, _)); | 3479 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, first_packet_size, _)); |
| 3480 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, second_packet_size, _)); | 3480 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, second_packet_size, _)); |
| 3481 } | 3481 } |
| 3482 connection_.GetRetransmissionAlarm()->Fire(); | 3482 connection_.GetRetransmissionAlarm()->Fire(); |
| 3483 | 3483 |
| 3484 // Advance again and expect the packets to be sent again in the same order. | 3484 // Advance again and expect the packets to be sent again in the same order. |
| 3485 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(20)); | 3485 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(20)); |
| 3486 { | 3486 { |
| 3487 InSequence s; | 3487 InSequence s; |
| 3488 EXPECT_CALL(visitor_, OnPathDegrading()); |
| 3488 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, first_packet_size, _)); | 3489 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, first_packet_size, _)); |
| 3489 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, second_packet_size, _)); | 3490 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, second_packet_size, _)); |
| 3490 } | 3491 } |
| 3491 connection_.GetRetransmissionAlarm()->Fire(); | 3492 connection_.GetRetransmissionAlarm()->Fire(); |
| 3492 } | 3493 } |
| 3493 | 3494 |
| 3494 TEST_P(QuicConnectionTest, SetRTOAfterWritingToSocket) { | 3495 TEST_P(QuicConnectionTest, SetRTOAfterWritingToSocket) { |
| 3495 BlockOnNextWrite(); | 3496 BlockOnNextWrite(); |
| 3496 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, nullptr); | 3497 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, nullptr); |
| 3497 // Make sure that RTO is not started when the packet is queued. | 3498 // Make sure that RTO is not started when the packet is queued. |
| (...skipping 2183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5681 EXPECT_TRUE(connection_.connected()); | 5682 EXPECT_TRUE(connection_.connected()); |
| 5682 EXPECT_FALSE(QuicConnectionPeer::IsMultipathEnabled(&connection_)); | 5683 EXPECT_FALSE(QuicConnectionPeer::IsMultipathEnabled(&connection_)); |
| 5683 peer_creator_.SetCurrentPath(/*path_id=*/1u, 1u, 10u); | 5684 peer_creator_.SetCurrentPath(/*path_id=*/1u, 1u, 10u); |
| 5684 QuicStreamFrame stream_frame(1u, false, 0u, StringPiece()); | 5685 QuicStreamFrame stream_frame(1u, false, 0u, StringPiece()); |
| 5685 EXPECT_DFATAL(ProcessFramePacket(QuicFrame(&stream_frame)), | 5686 EXPECT_DFATAL(ProcessFramePacket(QuicFrame(&stream_frame)), |
| 5686 "Received a packet with multipath flag on when multipath is " | 5687 "Received a packet with multipath flag on when multipath is " |
| 5687 "not enabled."); | 5688 "not enabled."); |
| 5688 EXPECT_FALSE(connection_.connected()); | 5689 EXPECT_FALSE(connection_.connected()); |
| 5689 } | 5690 } |
| 5690 | 5691 |
| 5692 TEST_P(QuicConnectionTest, OnPathDegrading) { |
| 5693 QuicByteCount packet_size; |
| 5694 const size_t kMinTimeoutsBeforePathDegrading = 2; |
| 5695 |
| 5696 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) |
| 5697 .WillOnce(DoAll(SaveArg<3>(&packet_size), Return(true))); |
| 5698 connection_.SendStreamDataWithString(3, "packet", 0, !kFin, nullptr); |
| 5699 for (size_t i = 1; i < kMinTimeoutsBeforePathDegrading; ++i) { |
| 5700 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(10 * i)); |
| 5701 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, packet_size, _)); |
| 5702 connection_.GetRetransmissionAlarm()->Fire(); |
| 5703 } |
| 5704 // Next RTO should cause OnPathDegrading to be called before the |
| 5705 // retransmission is sent out. |
| 5706 clock_.AdvanceTime( |
| 5707 QuicTime::Delta::FromSeconds(kMinTimeoutsBeforePathDegrading * 10)); |
| 5708 { |
| 5709 InSequence s; |
| 5710 EXPECT_CALL(visitor_, OnPathDegrading()); |
| 5711 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, packet_size, _)); |
| 5712 } |
| 5713 connection_.GetRetransmissionAlarm()->Fire(); |
| 5714 } |
| 5715 |
| 5691 } // namespace | 5716 } // namespace |
| 5692 } // namespace test | 5717 } // namespace test |
| 5693 } // namespace net | 5718 } // namespace net |
| OLD | NEW |