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

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

Issue 483093004: Rename QuicConnection::OnPacketSent to OnWriteError, to reflect it's (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Refactor_async_write_behavior_73648585
Patch Set: Created 6 years, 3 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_default_packet_writer.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 1910 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1);
1928 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, NULL); 1928 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, NULL);
1929 EXPECT_TRUE(connection_.GetRetransmissionAlarm()->IsSet()); 1929 EXPECT_TRUE(connection_.GetRetransmissionAlarm()->IsSet());
1930 1930
1931 connection_.OnPacketSent(WriteResult(WRITE_STATUS_OK, 0)); 1931 writer_->SetWritable();
1932 connection_.OnCanWrite();
1932 EXPECT_TRUE(connection_.GetRetransmissionAlarm()->IsSet()); 1933 EXPECT_TRUE(connection_.GetRetransmissionAlarm()->IsSet());
1933 } 1934 }
1934 1935
1935 TEST_P(QuicConnectionTest, RetransmitWriteBlockedAckedOriginalThenSent) { 1936 TEST_P(QuicConnectionTest, RetransmitWriteBlockedAckedOriginalThenSent) {
1936 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); 1937 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
1937 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, NULL); 1938 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, NULL);
1938 EXPECT_TRUE(connection_.GetRetransmissionAlarm()->IsSet()); 1939 EXPECT_TRUE(connection_.GetRetransmissionAlarm()->IsSet());
1939 1940
1940 BlockOnNextWrite(); 1941 BlockOnNextWrite();
1941 writer_->set_is_write_blocked_data_buffered(true); 1942 writer_->set_is_write_blocked_data_buffered(true);
1942 // Simulate the retransmission alarm firing. 1943 // Simulate the retransmission alarm firing.
1943 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(_)); 1944 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(_));
1944 clock_.AdvanceTime(DefaultRetransmissionTime()); 1945 clock_.AdvanceTime(DefaultRetransmissionTime());
1945 connection_.GetRetransmissionAlarm()->Fire(); 1946 connection_.GetRetransmissionAlarm()->Fire();
1946 1947
1947 // Ack the sent packet before the callback returns, which happens in 1948 // Ack the sent packet before the callback returns, which happens in
1948 // rare circumstances with write blocked sockets. 1949 // rare circumstances with write blocked sockets.
1949 QuicAckFrame ack = InitAckFrame(1); 1950 QuicAckFrame ack = InitAckFrame(1);
1950 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); 1951 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _));
1951 EXPECT_CALL(*send_algorithm_, RevertRetransmissionTimeout()); 1952 EXPECT_CALL(*send_algorithm_, RevertRetransmissionTimeout());
1952 ProcessAckPacket(&ack); 1953 ProcessAckPacket(&ack);
1953 1954
1954 connection_.OnPacketSent(WriteResult(WRITE_STATUS_OK, 0)); 1955 writer_->SetWritable();
1956 connection_.OnCanWrite();
1955 // There is now a pending packet, but with no retransmittable frames. 1957 // There is now a pending packet, but with no retransmittable frames.
1956 EXPECT_TRUE(connection_.GetRetransmissionAlarm()->IsSet()); 1958 EXPECT_TRUE(connection_.GetRetransmissionAlarm()->IsSet());
1957 EXPECT_FALSE(connection_.sent_packet_manager().HasRetransmittableFrames(2)); 1959 EXPECT_FALSE(connection_.sent_packet_manager().HasRetransmittableFrames(2));
1958 } 1960 }
1959 1961
1960 TEST_P(QuicConnectionTest, AlarmsWhenWriteBlocked) { 1962 TEST_P(QuicConnectionTest, AlarmsWhenWriteBlocked) {
1961 // Block the connection. 1963 // Block the connection.
1962 BlockOnNextWrite(); 1964 BlockOnNextWrite();
1963 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, NULL); 1965 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, NULL);
1964 EXPECT_EQ(1u, writer_->packets_write_attempts()); 1966 EXPECT_EQ(1u, writer_->packets_write_attempts());
(...skipping 1973 matching lines...) Expand 10 before | Expand all | Expand 10 after
3938 QuicBlockedFrame blocked; 3940 QuicBlockedFrame blocked;
3939 blocked.stream_id = 3; 3941 blocked.stream_id = 3;
3940 EXPECT_CALL(visitor_, OnBlockedFrames(_)); 3942 EXPECT_CALL(visitor_, OnBlockedFrames(_));
3941 ProcessFramePacket(QuicFrame(&blocked)); 3943 ProcessFramePacket(QuicFrame(&blocked));
3942 EXPECT_TRUE(ack_alarm->IsSet()); 3944 EXPECT_TRUE(ack_alarm->IsSet());
3943 } 3945 }
3944 3946
3945 } // namespace 3947 } // namespace
3946 } // namespace test 3948 } // namespace test
3947 } // namespace net 3949 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_connection.cc ('k') | net/quic/quic_default_packet_writer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698