| 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 3499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3510 // Don't send missing FEC packet 3. | 3510 // Don't send missing FEC packet 3. |
| 3511 ASSERT_EQ(1u, connection_.NumFecGroups()); | 3511 ASSERT_EQ(1u, connection_.NumFecGroups()); |
| 3512 | 3512 |
| 3513 // Now send non-fec protected ack packet and close the group. | 3513 // Now send non-fec protected ack packet and close the group. |
| 3514 QuicPacketCreatorPeer::SetPacketNumber(&peer_creator_, 4); | 3514 QuicPacketCreatorPeer::SetPacketNumber(&peer_creator_, 4); |
| 3515 QuicStopWaitingFrame frame = InitStopWaitingFrame(5); | 3515 QuicStopWaitingFrame frame = InitStopWaitingFrame(5); |
| 3516 ProcessStopWaitingPacket(&frame); | 3516 ProcessStopWaitingPacket(&frame); |
| 3517 ASSERT_EQ(0u, connection_.NumFecGroups()); | 3517 ASSERT_EQ(0u, connection_.NumFecGroups()); |
| 3518 } | 3518 } |
| 3519 | 3519 |
| 3520 TEST_P(QuicConnectionTest, FailedToCloseFecGroupWithFecProtectedStopWaiting) { | |
| 3521 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | |
| 3522 ValueRestore<bool> old_flag(&FLAGS_quic_drop_non_awaited_packets, false); | |
| 3523 // Don't send missing packet 1. | |
| 3524 ProcessFecProtectedPacket(kDefaultPathId, 2, false, !kEntropyFlag, | |
| 3525 !kHasStopWaiting); | |
| 3526 EXPECT_EQ(1u, connection_.NumFecGroups()); | |
| 3527 stop_waiting_ = InitStopWaitingFrame(3); | |
| 3528 ProcessFecProtectedPacket(kDefaultPathId, 3, false, !kEntropyFlag, | |
| 3529 kHasStopWaiting); | |
| 3530 // This Fec group would be closed but created again. | |
| 3531 EXPECT_EQ(1u, connection_.NumFecGroups()); | |
| 3532 } | |
| 3533 | |
| 3534 TEST_P(QuicConnectionTest, | 3520 TEST_P(QuicConnectionTest, |
| 3535 CloseFecGroupUnderStopWaitingAndWaitingForPacketsBelowStopWaiting) { | 3521 CloseFecGroupUnderStopWaitingAndWaitingForPacketsBelowStopWaiting) { |
| 3536 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 3522 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 3537 ValueRestore<bool> old_flag(&FLAGS_quic_drop_non_awaited_packets, true); | |
| 3538 // Don't send missing packet 1. | 3523 // Don't send missing packet 1. |
| 3539 ProcessFecProtectedPacket(kDefaultPathId, 2, false, !kEntropyFlag, | 3524 ProcessFecProtectedPacket(kDefaultPathId, 2, false, !kEntropyFlag, |
| 3540 !kHasStopWaiting); | 3525 !kHasStopWaiting); |
| 3541 EXPECT_EQ(1u, connection_.NumFecGroups()); | 3526 EXPECT_EQ(1u, connection_.NumFecGroups()); |
| 3542 stop_waiting_ = InitStopWaitingFrame(2); | 3527 stop_waiting_ = InitStopWaitingFrame(2); |
| 3543 ProcessFecProtectedPacket(kDefaultPathId, 3, false, !kEntropyFlag, | 3528 ProcessFecProtectedPacket(kDefaultPathId, 3, false, !kEntropyFlag, |
| 3544 kHasStopWaiting); | 3529 kHasStopWaiting); |
| 3545 // This Fec group would be closed. | 3530 // This Fec group would be closed. |
| 3546 EXPECT_EQ(0u, connection_.NumFecGroups()); | 3531 EXPECT_EQ(0u, connection_.NumFecGroups()); |
| 3547 } | 3532 } |
| 3548 | 3533 |
| 3549 TEST_P(QuicConnectionTest, | 3534 TEST_P(QuicConnectionTest, |
| 3550 DoNotCloseFecGroupUnderStopWaitingButNotWaitingForPacketsBelow) { | 3535 DoNotCloseFecGroupUnderStopWaitingButNotWaitingForPacketsBelow) { |
| 3551 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 3536 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 3552 ValueRestore<bool> old_flag(&FLAGS_quic_drop_non_awaited_packets, true); | |
| 3553 ProcessFecProtectedPacket(kDefaultPathId, 1, false, !kEntropyFlag, | 3537 ProcessFecProtectedPacket(kDefaultPathId, 1, false, !kEntropyFlag, |
| 3554 !kHasStopWaiting); | 3538 !kHasStopWaiting); |
| 3555 ProcessFecProtectedPacket(kDefaultPathId, 2, false, !kEntropyFlag, | 3539 ProcessFecProtectedPacket(kDefaultPathId, 2, false, !kEntropyFlag, |
| 3556 !kHasStopWaiting); | 3540 !kHasStopWaiting); |
| 3557 // Don't send missing packet 3. | 3541 // Don't send missing packet 3. |
| 3558 EXPECT_EQ(1u, connection_.NumFecGroups()); | 3542 EXPECT_EQ(1u, connection_.NumFecGroups()); |
| 3559 stop_waiting_ = InitStopWaitingFrame(2); | 3543 stop_waiting_ = InitStopWaitingFrame(2); |
| 3560 ProcessFecProtectedPacket(kDefaultPathId, 3, false, !kEntropyFlag, | 3544 ProcessFecProtectedPacket(kDefaultPathId, 3, false, !kEntropyFlag, |
| 3561 kHasStopWaiting); | 3545 kHasStopWaiting); |
| 3562 // This group will not be closed because this group is not waiting for packets | 3546 // This group will not be closed because this group is not waiting for packets |
| (...skipping 1815 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5378 QuicPacketCreatorPeer::GetFecTimeout(creator_)); | 5362 QuicPacketCreatorPeer::GetFecTimeout(creator_)); |
| 5379 } | 5363 } |
| 5380 | 5364 |
| 5381 TEST_P(QuicConnectionTest, OnPacketHeaderDebugVisitor) { | 5365 TEST_P(QuicConnectionTest, OnPacketHeaderDebugVisitor) { |
| 5382 QuicPacketHeader header; | 5366 QuicPacketHeader header; |
| 5383 | 5367 |
| 5384 scoped_ptr<MockQuicConnectionDebugVisitor> debug_visitor( | 5368 scoped_ptr<MockQuicConnectionDebugVisitor> debug_visitor( |
| 5385 new MockQuicConnectionDebugVisitor()); | 5369 new MockQuicConnectionDebugVisitor()); |
| 5386 connection_.set_debug_visitor(debug_visitor.get()); | 5370 connection_.set_debug_visitor(debug_visitor.get()); |
| 5387 EXPECT_CALL(*debug_visitor, OnPacketHeader(Ref(header))).Times(1); | 5371 EXPECT_CALL(*debug_visitor, OnPacketHeader(Ref(header))).Times(1); |
| 5388 if (FLAGS_quic_drop_non_awaited_packets) { | 5372 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)).Times(1); |
| 5389 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)).Times(1); | 5373 EXPECT_CALL(*debug_visitor, OnSuccessfulVersionNegotiation(_)).Times(1); |
| 5390 EXPECT_CALL(*debug_visitor, OnSuccessfulVersionNegotiation(_)).Times(1); | |
| 5391 } | |
| 5392 connection_.OnPacketHeader(header); | 5374 connection_.OnPacketHeader(header); |
| 5393 } | 5375 } |
| 5394 | 5376 |
| 5395 TEST_P(QuicConnectionTest, Pacing) { | 5377 TEST_P(QuicConnectionTest, Pacing) { |
| 5396 TestConnection server(connection_id_, kSelfAddress, helper_.get(), | 5378 TestConnection server(connection_id_, kSelfAddress, helper_.get(), |
| 5397 writer_.get(), Perspective::IS_SERVER, version()); | 5379 writer_.get(), Perspective::IS_SERVER, version()); |
| 5398 TestConnection client(connection_id_, kPeerAddress, helper_.get(), | 5380 TestConnection client(connection_id_, kPeerAddress, helper_.get(), |
| 5399 writer_.get(), Perspective::IS_CLIENT, version()); | 5381 writer_.get(), Perspective::IS_CLIENT, version()); |
| 5400 EXPECT_FALSE(client.sent_packet_manager().using_pacing()); | 5382 EXPECT_FALSE(client.sent_packet_manager().using_pacing()); |
| 5401 EXPECT_FALSE(server.sent_packet_manager().using_pacing()); | 5383 EXPECT_FALSE(server.sent_packet_manager().using_pacing()); |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5614 // result in multiple attempts to close the connection - it will be marked as | 5596 // result in multiple attempts to close the connection - it will be marked as |
| 5615 // disconnected after the first call. | 5597 // disconnected after the first call. |
| 5616 EXPECT_CALL(visitor_, OnConnectionClosed(_, _)).Times(1); | 5598 EXPECT_CALL(visitor_, OnConnectionClosed(_, _)).Times(1); |
| 5617 connection_.SendConnectionCloseWithDetails(QUIC_NO_ERROR, "no reason"); | 5599 connection_.SendConnectionCloseWithDetails(QUIC_NO_ERROR, "no reason"); |
| 5618 connection_.SendConnectionCloseWithDetails(QUIC_NO_ERROR, "no reason"); | 5600 connection_.SendConnectionCloseWithDetails(QUIC_NO_ERROR, "no reason"); |
| 5619 } | 5601 } |
| 5620 | 5602 |
| 5621 } // namespace | 5603 } // namespace |
| 5622 } // namespace test | 5604 } // namespace test |
| 5623 } // namespace net | 5605 } // namespace net |
| OLD | NEW |