| 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 3355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3366 InSequence s; | 3366 InSequence s; |
| 3367 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, first_packet_size, _)); | 3367 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, first_packet_size, _)); |
| 3368 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, second_packet_size, _)); | 3368 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, second_packet_size, _)); |
| 3369 } | 3369 } |
| 3370 connection_.GetRetransmissionAlarm()->Fire(); | 3370 connection_.GetRetransmissionAlarm()->Fire(); |
| 3371 | 3371 |
| 3372 // Advance again and expect the packets to be sent again in the same order. | 3372 // Advance again and expect the packets to be sent again in the same order. |
| 3373 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(20)); | 3373 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(20)); |
| 3374 { | 3374 { |
| 3375 InSequence s; | 3375 InSequence s; |
| 3376 EXPECT_CALL(visitor_, OnPathDegrading()); |
| 3376 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, first_packet_size, _)); | 3377 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, first_packet_size, _)); |
| 3377 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, second_packet_size, _)); | 3378 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, second_packet_size, _)); |
| 3378 } | 3379 } |
| 3379 connection_.GetRetransmissionAlarm()->Fire(); | 3380 connection_.GetRetransmissionAlarm()->Fire(); |
| 3380 } | 3381 } |
| 3381 | 3382 |
| 3382 TEST_P(QuicConnectionTest, SetRTOAfterWritingToSocket) { | 3383 TEST_P(QuicConnectionTest, SetRTOAfterWritingToSocket) { |
| 3383 BlockOnNextWrite(); | 3384 BlockOnNextWrite(); |
| 3384 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, nullptr); | 3385 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, nullptr); |
| 3385 // Make sure that RTO is not started when the packet is queued. | 3386 // Make sure that RTO is not started when the packet is queued. |
| (...skipping 2117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5503 EXPECT_TRUE(connection_.connected()); | 5504 EXPECT_TRUE(connection_.connected()); |
| 5504 EXPECT_FALSE(QuicConnectionPeer::IsMultipathEnabled(&connection_)); | 5505 EXPECT_FALSE(QuicConnectionPeer::IsMultipathEnabled(&connection_)); |
| 5505 peer_creator_.SetCurrentPath(/*path_id=*/1u, 1u, 10u); | 5506 peer_creator_.SetCurrentPath(/*path_id=*/1u, 1u, 10u); |
| 5506 QuicStreamFrame stream_frame(1u, false, 0u, StringPiece()); | 5507 QuicStreamFrame stream_frame(1u, false, 0u, StringPiece()); |
| 5507 EXPECT_DFATAL(ProcessFramePacket(QuicFrame(&stream_frame)), | 5508 EXPECT_DFATAL(ProcessFramePacket(QuicFrame(&stream_frame)), |
| 5508 "Received a packet with multipath flag on when multipath is " | 5509 "Received a packet with multipath flag on when multipath is " |
| 5509 "not enabled."); | 5510 "not enabled."); |
| 5510 EXPECT_FALSE(connection_.connected()); | 5511 EXPECT_FALSE(connection_.connected()); |
| 5511 } | 5512 } |
| 5512 | 5513 |
| 5514 TEST_P(QuicConnectionTest, OnPathDegrading) { |
| 5515 QuicByteCount packet_size; |
| 5516 const size_t kMinTimeoutsBeforePathDegrading = 2; |
| 5517 |
| 5518 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) |
| 5519 .WillOnce(DoAll(SaveArg<3>(&packet_size), Return(true))); |
| 5520 connection_.SendStreamDataWithString(3, "packet", 0, !kFin, nullptr); |
| 5521 for (size_t i = 1; i < kMinTimeoutsBeforePathDegrading; ++i) { |
| 5522 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(10 * i)); |
| 5523 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, packet_size, _)); |
| 5524 connection_.GetRetransmissionAlarm()->Fire(); |
| 5525 } |
| 5526 // Next RTO should cause OnPathDegrading to be called before the |
| 5527 // retransmission is sent out. |
| 5528 clock_.AdvanceTime( |
| 5529 QuicTime::Delta::FromSeconds(kMinTimeoutsBeforePathDegrading * 10)); |
| 5530 { |
| 5531 InSequence s; |
| 5532 EXPECT_CALL(visitor_, OnPathDegrading()); |
| 5533 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, packet_size, _)); |
| 5534 } |
| 5535 connection_.GetRetransmissionAlarm()->Fire(); |
| 5536 } |
| 5537 |
| 5513 } // namespace | 5538 } // namespace |
| 5514 } // namespace test | 5539 } // namespace test |
| 5515 } // namespace net | 5540 } // namespace net |
| OLD | NEW |