Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(23)

Side by Side Diff: net/quic/quic_connection_test.cc

Issue 133683010: Fix a bug where the packet was put into unacked packets when it was (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/quic/quic_connection.cc ('k') | net/quic/quic_sent_packet_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1756 matching lines...) Expand 10 before | Expand all | Expand 10 after
1767 1767
1768 writer_->set_is_write_blocked_data_buffered(true); 1768 writer_->set_is_write_blocked_data_buffered(true);
1769 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, NULL); 1769 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, NULL);
1770 EXPECT_FALSE(connection_.GetRetransmissionAlarm()->IsSet()); 1770 EXPECT_FALSE(connection_.GetRetransmissionAlarm()->IsSet());
1771 1771
1772 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1); 1772 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1);
1773 connection_.OnPacketSent(WriteResult(WRITE_STATUS_OK, 0)); 1773 connection_.OnPacketSent(WriteResult(WRITE_STATUS_OK, 0));
1774 EXPECT_TRUE(connection_.GetRetransmissionAlarm()->IsSet()); 1774 EXPECT_TRUE(connection_.GetRetransmissionAlarm()->IsSet());
1775 } 1775 }
1776 1776
1777 TEST_F(QuicConnectionTest, WriteBlockedAckedThenSent) {
1778 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
1779 writer_->SetWriteBlocked();
1780
1781 writer_->set_is_write_blocked_data_buffered(true);
1782 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, NULL);
1783 EXPECT_FALSE(connection_.GetRetransmissionAlarm()->IsSet());
1784
1785 // Ack the sent packet before the callback returns, which happens in
1786 // rare circumstances with write blocked sockets.
1787 QuicAckFrame ack = InitAckFrame(1, 0);
1788 ProcessAckPacket(&ack);
1789
1790 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(0);
1791 connection_.OnPacketSent(WriteResult(WRITE_STATUS_OK, 0));
1792 EXPECT_FALSE(connection_.GetRetransmissionAlarm()->IsSet());
1793 }
1794
1795 TEST_F(QuicConnectionTest, RetransmitWriteBlockedAckedOriginalThenSent) {
1796 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
1797 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, NULL);
1798 EXPECT_TRUE(connection_.GetRetransmissionAlarm()->IsSet());
1799
1800 writer_->SetWriteBlocked();
1801 writer_->set_is_write_blocked_data_buffered(true);
1802
1803 // Simulate the retransmission alarm firing.
1804 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(1, _));
1805 clock_.AdvanceTime(DefaultRetransmissionTime());
1806 connection_.GetRetransmissionAlarm()->Fire();
1807
1808 // Ack the sent packet before the callback returns, which happens in
1809 // rare circumstances with write blocked sockets.
1810 QuicAckFrame ack = InitAckFrame(1, 0);
1811 ProcessAckPacket(&ack);
1812
1813 connection_.OnPacketSent(WriteResult(WRITE_STATUS_OK, 0));
1814 EXPECT_TRUE(connection_.GetRetransmissionAlarm()->IsSet());
1815 }
1816
1777 TEST_F(QuicConnectionTest, ResumptionAlarmThenWriteBlocked) { 1817 TEST_F(QuicConnectionTest, ResumptionAlarmThenWriteBlocked) {
1778 // Set the send and resumption alarm, then block the connection. 1818 // Set the send and resumption alarm, then block the connection.
1779 connection_.GetResumeWritesAlarm()->Set(clock_.ApproximateNow()); 1819 connection_.GetResumeWritesAlarm()->Set(clock_.ApproximateNow());
1780 connection_.GetSendAlarm()->Set(clock_.ApproximateNow()); 1820 connection_.GetSendAlarm()->Set(clock_.ApproximateNow());
1781 QuicConnectionPeer::SetIsWriteBlocked(&connection_, true); 1821 QuicConnectionPeer::SetIsWriteBlocked(&connection_, true);
1782 1822
1783 // Fire the alarms and ensure the connection is still write blocked. 1823 // Fire the alarms and ensure the connection is still write blocked.
1784 connection_.GetResumeWritesAlarm()->Fire(); 1824 connection_.GetResumeWritesAlarm()->Fire();
1785 connection_.GetSendAlarm()->Fire(); 1825 connection_.GetSendAlarm()->Fire();
1786 EXPECT_TRUE(QuicConnectionPeer::IsWriteBlocked(&connection_)); 1826 EXPECT_TRUE(QuicConnectionPeer::IsWriteBlocked(&connection_));
(...skipping 1572 matching lines...) Expand 10 before | Expand all | Expand 10 after
3359 true); 3399 true);
3360 TestConnection client(guid_, IPEndPoint(), helper_.get(), writer_.get(), 3400 TestConnection client(guid_, IPEndPoint(), helper_.get(), writer_.get(),
3361 false); 3401 false);
3362 EXPECT_TRUE(client.sent_packet_manager().using_pacing()); 3402 EXPECT_TRUE(client.sent_packet_manager().using_pacing());
3363 EXPECT_FALSE(server.sent_packet_manager().using_pacing()); 3403 EXPECT_FALSE(server.sent_packet_manager().using_pacing());
3364 } 3404 }
3365 3405
3366 } // namespace 3406 } // namespace
3367 } // namespace test 3407 } // namespace test
3368 } // namespace net 3408 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_connection.cc ('k') | net/quic/quic_sent_packet_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698