Index: net/quic/quic_connection_test.cc |
diff --git a/net/quic/quic_connection_test.cc b/net/quic/quic_connection_test.cc |
index dbdb86f4b6e111abaf43173fbb63fcdbe1351122..31d2c2fc7d25e076e8d3632178703bfd13944094 100644 |
--- a/net/quic/quic_connection_test.cc |
+++ b/net/quic/quic_connection_test.cc |
@@ -273,7 +273,7 @@ class TestPacketWriter : public QuicPacketWriter { |
public: |
TestPacketWriter() |
: last_packet_size_(0), |
- blocked_(false), |
+ write_blocked_(false), |
is_write_blocked_data_buffered_(false), |
is_server_(true), |
final_bytes_of_last_packet_(0), |
@@ -304,7 +304,7 @@ class TestPacketWriter : public QuicPacketWriter { |
visitor_.Reset(); |
framer.set_visitor(&visitor_); |
EXPECT_TRUE(framer.ProcessPacket(packet)); |
- if (blocked_) { |
+ if (IsWriteBlocked()) { |
return WriteResult(WRITE_STATUS_BLOCKED, -1); |
} |
last_packet_size_ = packet.length(); |
@@ -315,6 +315,12 @@ class TestPacketWriter : public QuicPacketWriter { |
return is_write_blocked_data_buffered_; |
} |
+ virtual bool IsWriteBlocked() const { return write_blocked_; } |
+ |
+ virtual void SetWritable() { write_blocked_ = false; } |
+ |
+ void SetWriteBlocked() { write_blocked_ = true; } |
+ |
// Resets the visitor's state by clearing out the headers and frames. |
void Reset() { |
visitor_.Reset(); |
@@ -342,8 +348,6 @@ class TestPacketWriter : public QuicPacketWriter { |
return visitor_.version_negotiation_packet(); |
} |
- void set_blocked(bool blocked) { blocked_ = blocked; } |
- |
void set_is_write_blocked_data_buffered(bool buffered) { |
is_write_blocked_data_buffered_ = buffered; |
} |
@@ -370,7 +374,7 @@ class TestPacketWriter : public QuicPacketWriter { |
private: |
FramerVisitorCapturingFrames visitor_; |
size_t last_packet_size_; |
- bool blocked_; |
+ bool write_blocked_; |
bool is_write_blocked_data_buffered_; |
bool is_server_; |
uint32 final_bytes_of_last_packet_; |
@@ -1305,7 +1309,7 @@ TEST_F(QuicConnectionTest, FECQueueing) { |
connection_.options()->max_packets_per_fec_group = 2; |
EXPECT_EQ(0u, connection_.NumQueuedPackets()); |
- writer_->set_blocked(true); |
+ writer_->SetWriteBlocked(); |
const string payload(payload_length, 'a'); |
connection_.SendStreamDataWithString(1, payload, 0, !kFin, NULL); |
EXPECT_FALSE(creator_.ShouldSendFec(true)); |
@@ -1573,7 +1577,7 @@ TEST_F(QuicConnectionTest, FramePackingSendvQueued) { |
// Try to send two stream frames in 1 packet by using writev. |
EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, NOT_RETRANSMISSION, _)); |
- writer_->set_blocked(true); |
+ writer_->SetWriteBlocked(); |
char data[] = "ABCD"; |
IOVector data_iov; |
data_iov.AppendNoCoalesce(data, 2); |
@@ -1589,7 +1593,7 @@ TEST_F(QuicConnectionTest, FramePackingSendvQueued) { |
EXPECT_EQ(1u, connection_.NumQueuedPackets()); |
// Unblock the writes and actually send. |
- writer_->set_blocked(false); |
+ writer_->SetWritable(); |
EXPECT_TRUE(connection_.OnCanWrite()); |
EXPECT_EQ(0u, connection_.NumQueuedPackets()); |
@@ -1693,7 +1697,7 @@ TEST_F(QuicConnectionTest, DiscardRetransmit) { |
NackPacket(2, &nack_two); |
// The first nack should trigger a fast retransmission, but we'll be |
// write blocked, so the packet will be queued. |
- writer_->set_blocked(true); |
+ writer_->SetWriteBlocked(); |
ProcessAckPacket(&nack_two); |
EXPECT_EQ(1u, connection_.NumQueuedPackets()); |
@@ -1708,7 +1712,7 @@ TEST_F(QuicConnectionTest, DiscardRetransmit) { |
EXPECT_CALL(*send_algorithm_, |
OnPacketSent(_, _, _, _, _)).Times(0); |
- writer_->set_blocked(false); |
+ writer_->SetWritable(); |
connection_.OnCanWrite(); |
EXPECT_EQ(0u, connection_.NumQueuedPackets()); |
@@ -1740,7 +1744,7 @@ TEST_F(QuicConnectionTest, QueueAfterTwoRTOs) { |
} |
// Block the congestion window and ensure they're queued. |
- writer_->set_blocked(true); |
+ writer_->SetWriteBlocked(); |
clock_.AdvanceTime(DefaultRetransmissionTime()); |
// Only one packet should be retransmitted. |
EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true)); |
@@ -1748,7 +1752,7 @@ TEST_F(QuicConnectionTest, QueueAfterTwoRTOs) { |
EXPECT_TRUE(connection_.HasQueuedData()); |
// Unblock the congestion window. |
- writer_->set_blocked(false); |
+ writer_->SetWritable(); |
clock_.AdvanceTime(QuicTime::Delta::FromMicroseconds( |
2 * DefaultRetransmissionTime().ToMicroseconds())); |
// Retransmit already retransmitted packets event though the sequence number |
@@ -1759,7 +1763,7 @@ TEST_F(QuicConnectionTest, QueueAfterTwoRTOs) { |
} |
TEST_F(QuicConnectionTest, WriteBlockedThenSent) { |
- writer_->set_blocked(true); |
+ writer_->SetWriteBlocked(); |
writer_->set_is_write_blocked_data_buffered(true); |
connection_.SendStreamDataWithString(1, "foo", 0, !kFin, NULL); |
@@ -2168,13 +2172,13 @@ TEST_F(QuicConnectionTest, RetransmissionCountCalculation) { |
} |
TEST_F(QuicConnectionTest, SetRTOAfterWritingToSocket) { |
- writer_->set_blocked(true); |
+ writer_->SetWriteBlocked(); |
connection_.SendStreamDataWithString(1, "foo", 0, !kFin, NULL); |
// Make sure that RTO is not started when the packet is queued. |
EXPECT_FALSE(connection_.GetRetransmissionAlarm()->IsSet()); |
// Test that RTO is started once we write to the socket. |
- writer_->set_blocked(false); |
+ writer_->SetWritable(); |
connection_.OnCanWrite(); |
EXPECT_TRUE(connection_.GetRetransmissionAlarm()->IsSet()); |
} |
@@ -2218,7 +2222,7 @@ TEST_F(QuicConnectionTest, DelayRTOWithAckReceipt) { |
TEST_F(QuicConnectionTest, TestQueued) { |
EXPECT_EQ(0u, connection_.NumQueuedPackets()); |
- writer_->set_blocked(true); |
+ writer_->SetWriteBlocked(); |
connection_.SendStreamDataWithString(1, "foo", 0, !kFin, NULL); |
EXPECT_EQ(1u, connection_.NumQueuedPackets()); |
@@ -2228,7 +2232,7 @@ TEST_F(QuicConnectionTest, TestQueued) { |
EXPECT_EQ(1u, connection_.NumQueuedPackets()); |
// Unblock the writes and actually send. |
- writer_->set_blocked(false); |
+ writer_->SetWritable(); |
EXPECT_TRUE(connection_.OnCanWrite()); |
EXPECT_EQ(0u, connection_.NumQueuedPackets()); |
} |
@@ -2378,7 +2382,7 @@ TEST_F(QuicConnectionTest, SendSchedulerForce) { |
TEST_F(QuicConnectionTest, SendSchedulerEAGAIN) { |
QuicPacket* packet = ConstructDataPacket(1, 0, !kEntropyFlag); |
- writer_->set_blocked(true); |
+ writer_->SetWriteBlocked(); |
EXPECT_CALL(*send_algorithm_, |
TimeUntilSend(_, NOT_RETRANSMISSION, _, _)).WillOnce( |
testing::Return(QuicTime::Delta::Zero())); |
@@ -2853,13 +2857,13 @@ TEST_F(QuicConnectionTest, ServerSendsVersionNegotiationPacketSocketBlocked) { |
framer_.set_version(QuicVersionMax()); |
connection_.set_is_server(true); |
- writer_->set_blocked(true); |
+ writer_->SetWriteBlocked(); |
connection_.ProcessUdpPacket(IPEndPoint(), IPEndPoint(), *encrypted); |
EXPECT_EQ(0u, writer_->last_packet_size()); |
EXPECT_TRUE(connection_.HasQueuedData()); |
EXPECT_TRUE(QuicConnectionPeer::IsWriteBlocked(&connection_)); |
- writer_->set_blocked(false); |
+ writer_->SetWritable(); |
connection_.OnCanWrite(); |
EXPECT_TRUE(writer_->version_negotiation_packet() != NULL); |
@@ -2898,7 +2902,7 @@ TEST_F(QuicConnectionTest, |
framer_.set_version(QuicVersionMax()); |
connection_.set_is_server(true); |
- writer_->set_blocked(true); |
+ writer_->SetWriteBlocked(); |
writer_->set_is_write_blocked_data_buffered(true); |
connection_.ProcessUdpPacket(IPEndPoint(), IPEndPoint(), *encrypted); |
EXPECT_EQ(0u, writer_->last_packet_size()); |
@@ -3133,7 +3137,7 @@ TEST_F(QuicConnectionTest, SelectMutualVersion) { |
} |
TEST_F(QuicConnectionTest, ConnectionCloseWhenNotWriteBlocked) { |
- writer_->set_blocked(false); // Already default. |
+ writer_->SetWritable(); // Already default. |
// Send a packet (but write will not block). |
connection_.SendStreamDataWithString(1, "foo", 0, !kFin, NULL); |
@@ -3148,7 +3152,7 @@ TEST_F(QuicConnectionTest, ConnectionCloseWhenNotWriteBlocked) { |
TEST_F(QuicConnectionTest, ConnectionCloseWhenWriteBlocked) { |
EXPECT_EQ(0u, connection_.NumQueuedPackets()); |
- writer_->set_blocked(true); |
+ writer_->SetWriteBlocked(); |
// Send a packet to so that write will really block. |
connection_.SendStreamDataWithString(1, "foo", 0, !kFin, NULL); |
@@ -3162,7 +3166,7 @@ TEST_F(QuicConnectionTest, ConnectionCloseWhenWriteBlocked) { |
} |
TEST_F(QuicConnectionTest, ConnectionCloseWhenNothingPending) { |
- writer_->set_blocked(true); |
+ writer_->SetWriteBlocked(); |
// Send an erroneous packet to close the connection. |
EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_INVALID_PACKET_HEADER, false)); |