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 "net/base/net_errors.h" | 9 #include "net/base/net_errors.h" |
10 #include "net/quic/congestion_control/receive_algorithm_interface.h" | 10 #include "net/quic/congestion_control/receive_algorithm_interface.h" |
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
469 TestConnectionHelper::TestAlarm* GetRetransmissionAlarm() { | 469 TestConnectionHelper::TestAlarm* GetRetransmissionAlarm() { |
470 return reinterpret_cast<TestConnectionHelper::TestAlarm*>( | 470 return reinterpret_cast<TestConnectionHelper::TestAlarm*>( |
471 QuicConnectionPeer::GetRetransmissionAlarm(this)); | 471 QuicConnectionPeer::GetRetransmissionAlarm(this)); |
472 } | 472 } |
473 | 473 |
474 TestConnectionHelper::TestAlarm* GetSendAlarm() { | 474 TestConnectionHelper::TestAlarm* GetSendAlarm() { |
475 return reinterpret_cast<TestConnectionHelper::TestAlarm*>( | 475 return reinterpret_cast<TestConnectionHelper::TestAlarm*>( |
476 QuicConnectionPeer::GetSendAlarm(this)); | 476 QuicConnectionPeer::GetSendAlarm(this)); |
477 } | 477 } |
478 | 478 |
| 479 TestConnectionHelper::TestAlarm* GetResumeWritesAlarm() { |
| 480 return reinterpret_cast<TestConnectionHelper::TestAlarm*>( |
| 481 QuicConnectionPeer::GetResumeWritesAlarm(this)); |
| 482 } |
| 483 |
479 TestConnectionHelper::TestAlarm* GetTimeoutAlarm() { | 484 TestConnectionHelper::TestAlarm* GetTimeoutAlarm() { |
480 return reinterpret_cast<TestConnectionHelper::TestAlarm*>( | 485 return reinterpret_cast<TestConnectionHelper::TestAlarm*>( |
481 QuicConnectionPeer::GetTimeoutAlarm(this)); | 486 QuicConnectionPeer::GetTimeoutAlarm(this)); |
482 } | 487 } |
483 | 488 |
484 using QuicConnection::SelectMutualVersion; | 489 using QuicConnection::SelectMutualVersion; |
485 | 490 |
486 private: | 491 private: |
487 TestConnectionHelper* helper_; | 492 TestConnectionHelper* helper_; |
488 | 493 |
(...skipping 1203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1692 helper_->set_blocked(false); | 1697 helper_->set_blocked(false); |
1693 clock_.AdvanceTime(QuicTime::Delta::FromMicroseconds( | 1698 clock_.AdvanceTime(QuicTime::Delta::FromMicroseconds( |
1694 2 * DefaultRetransmissionTime().ToMicroseconds())); | 1699 2 * DefaultRetransmissionTime().ToMicroseconds())); |
1695 // Retransmit already retransmitted packets event though the sequence number | 1700 // Retransmit already retransmitted packets event though the sequence number |
1696 // greater than the largest observed. | 1701 // greater than the largest observed. |
1697 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(10); | 1702 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(10); |
1698 connection_.GetRetransmissionAlarm()->Fire(); | 1703 connection_.GetRetransmissionAlarm()->Fire(); |
1699 connection_.OnCanWrite(); | 1704 connection_.OnCanWrite(); |
1700 } | 1705 } |
1701 | 1706 |
| 1707 TEST_P(QuicConnectionTest, ResumptionAlarmThenWriteBlocked) { |
| 1708 // Set the send and resumption alarm, then block the connection. |
| 1709 connection_.GetResumeWritesAlarm()->Set(clock_.ApproximateNow()); |
| 1710 connection_.GetSendAlarm()->Set(clock_.ApproximateNow()); |
| 1711 QuicConnectionPeer::SetIsWriteBlocked(&connection_, true); |
| 1712 |
| 1713 // Fire the alarms and ensure the connection is still write blocked. |
| 1714 connection_.GetResumeWritesAlarm()->Fire(); |
| 1715 connection_.GetSendAlarm()->Fire(); |
| 1716 EXPECT_TRUE(QuicConnectionPeer::IsWriteBlocked(&connection_)); |
| 1717 } |
| 1718 |
1702 TEST_P(QuicConnectionTest, LimitPacketsPerNack) { | 1719 TEST_P(QuicConnectionTest, LimitPacketsPerNack) { |
1703 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 1720 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
1704 EXPECT_CALL(*send_algorithm_, OnIncomingAck(12, _, _)).Times(1); | 1721 EXPECT_CALL(*send_algorithm_, OnIncomingAck(12, _, _)).Times(1); |
1705 EXPECT_CALL(*send_algorithm_, OnIncomingLoss(_)).Times(1); | 1722 EXPECT_CALL(*send_algorithm_, OnIncomingLoss(_)).Times(1); |
1706 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(_, _)).Times(11); | 1723 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(_, _)).Times(11); |
1707 int offset = 0; | 1724 int offset = 0; |
1708 // Send packets 1 to 12. | 1725 // Send packets 1 to 12. |
1709 for (int i = 0; i < 12; ++i) { | 1726 for (int i = 0; i < 12; ++i) { |
1710 SendStreamDataToPeer(1, "foo", offset, !kFin, NULL); | 1727 SendStreamDataToPeer(1, "foo", offset, !kFin, NULL); |
1711 offset += 3; | 1728 offset += 3; |
(...skipping 1449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3161 scoped_ptr<MockQuicConnectionDebugVisitor> | 3178 scoped_ptr<MockQuicConnectionDebugVisitor> |
3162 debug_visitor(new StrictMock<MockQuicConnectionDebugVisitor>); | 3179 debug_visitor(new StrictMock<MockQuicConnectionDebugVisitor>); |
3163 connection_.set_debug_visitor(debug_visitor.get()); | 3180 connection_.set_debug_visitor(debug_visitor.get()); |
3164 EXPECT_CALL(*debug_visitor, OnPacketHeader(Ref(header))).Times(1); | 3181 EXPECT_CALL(*debug_visitor, OnPacketHeader(Ref(header))).Times(1); |
3165 connection_.OnPacketHeader(header); | 3182 connection_.OnPacketHeader(header); |
3166 } | 3183 } |
3167 | 3184 |
3168 } // namespace | 3185 } // namespace |
3169 } // namespace test | 3186 } // namespace test |
3170 } // namespace net | 3187 } // namespace net |
OLD | NEW |