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

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

Issue 473763004: Refactor QuicConnection's async write behavior to record a packet as (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cleanup_release
Patch Set: Created 6 years, 4 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
« 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 1906 matching lines...) Expand 10 before | Expand all | Expand 10 after
1917 // Retransmit already retransmitted packets event though the sequence number 1917 // Retransmit already retransmitted packets event though the sequence number
1918 // greater than the largest observed. 1918 // greater than the largest observed.
1919 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(10); 1919 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(10);
1920 connection_.GetRetransmissionAlarm()->Fire(); 1920 connection_.GetRetransmissionAlarm()->Fire();
1921 connection_.OnCanWrite(); 1921 connection_.OnCanWrite();
1922 } 1922 }
1923 1923
1924 TEST_P(QuicConnectionTest, WriteBlockedThenSent) { 1924 TEST_P(QuicConnectionTest, WriteBlockedThenSent) {
1925 BlockOnNextWrite(); 1925 BlockOnNextWrite();
1926 writer_->set_is_write_blocked_data_buffered(true); 1926 writer_->set_is_write_blocked_data_buffered(true);
1927 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1);
1927 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, NULL); 1928 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, NULL);
1928 EXPECT_FALSE(connection_.GetRetransmissionAlarm()->IsSet()); 1929 EXPECT_TRUE(connection_.GetRetransmissionAlarm()->IsSet());
1929 1930
1930 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1);
1931 connection_.OnPacketSent(WriteResult(WRITE_STATUS_OK, 0)); 1931 connection_.OnPacketSent(WriteResult(WRITE_STATUS_OK, 0));
1932 EXPECT_TRUE(connection_.GetRetransmissionAlarm()->IsSet()); 1932 EXPECT_TRUE(connection_.GetRetransmissionAlarm()->IsSet());
1933 } 1933 }
1934 1934
1935 TEST_P(QuicConnectionTest, WriteBlockedAckedThenSent) {
1936 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
1937 BlockOnNextWrite();
1938 writer_->set_is_write_blocked_data_buffered(true);
1939 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, NULL);
1940 EXPECT_FALSE(connection_.GetRetransmissionAlarm()->IsSet());
1941
1942 // Ack the sent packet before the callback returns, which happens in
1943 // rare circumstances with write blocked sockets.
1944 QuicAckFrame ack = InitAckFrame(1);
1945 ProcessAckPacket(&ack);
1946
1947 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(0);
1948 connection_.OnPacketSent(WriteResult(WRITE_STATUS_OK, 0));
1949 EXPECT_FALSE(connection_.GetRetransmissionAlarm()->IsSet());
1950 }
1951
1952 TEST_P(QuicConnectionTest, RetransmitWriteBlockedAckedOriginalThenSent) { 1935 TEST_P(QuicConnectionTest, RetransmitWriteBlockedAckedOriginalThenSent) {
1953 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); 1936 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
1954 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, NULL); 1937 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, NULL);
1955 EXPECT_TRUE(connection_.GetRetransmissionAlarm()->IsSet()); 1938 EXPECT_TRUE(connection_.GetRetransmissionAlarm()->IsSet());
1956 1939
1957 BlockOnNextWrite(); 1940 BlockOnNextWrite();
1958 writer_->set_is_write_blocked_data_buffered(true); 1941 writer_->set_is_write_blocked_data_buffered(true);
1959 // Simulate the retransmission alarm firing. 1942 // Simulate the retransmission alarm firing.
1960 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(_)); 1943 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(_));
1961 clock_.AdvanceTime(DefaultRetransmissionTime()); 1944 clock_.AdvanceTime(DefaultRetransmissionTime());
(...skipping 1993 matching lines...) Expand 10 before | Expand all | Expand 10 after
3955 QuicBlockedFrame blocked; 3938 QuicBlockedFrame blocked;
3956 blocked.stream_id = 3; 3939 blocked.stream_id = 3;
3957 EXPECT_CALL(visitor_, OnBlockedFrames(_)); 3940 EXPECT_CALL(visitor_, OnBlockedFrames(_));
3958 ProcessFramePacket(QuicFrame(&blocked)); 3941 ProcessFramePacket(QuicFrame(&blocked));
3959 EXPECT_TRUE(ack_alarm->IsSet()); 3942 EXPECT_TRUE(ack_alarm->IsSet());
3960 } 3943 }
3961 3944
3962 } // namespace 3945 } // namespace
3963 } // namespace test 3946 } // namespace test
3964 } // namespace net 3947 } // 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