Index: net/quic/quic_packet_creator_test.cc |
diff --git a/net/quic/quic_packet_creator_test.cc b/net/quic/quic_packet_creator_test.cc |
index 9b1ff0307a092396401afb0585c219f4ca7eeafd..aba6f2e4e76bd4d7568e9fddc98ea500126220d0 100644 |
--- a/net/quic/quic_packet_creator_test.cc |
+++ b/net/quic/quic_packet_creator_test.cc |
@@ -109,6 +109,8 @@ class QuicPacketCreatorTest : public ::testing::TestWithParam<TestParams> { |
serialized_packet->retransmittable_frames.clear(); |
} |
+ void DeleteSerializedPacket() { ClearSerializedPacket(&serialized_packet_); } |
+ |
protected: |
QuicPacketCreatorTest() |
: server_framer_(SupportedVersions(GetParam().version), |
@@ -148,8 +150,8 @@ class QuicPacketCreatorTest : public ::testing::TestWithParam<TestParams> { |
return packet; |
} |
- void ProcessPacket(QuicEncryptedPacket* encrypted) { |
- server_framer_.ProcessPacket(*encrypted); |
+ void ProcessPacket(const SerializedPacket& packet) { |
+ server_framer_.ProcessPacket(*packet.packet); |
} |
void CheckStreamFrame(const QuicFrame& frame, |
@@ -258,7 +260,7 @@ TEST_P(QuicPacketCreatorTest, SerializeFrames) { |
EXPECT_CALL(framer_visitor_, OnStreamFrame(_)); |
EXPECT_CALL(framer_visitor_, OnPacketComplete()); |
} |
- ProcessPacket(serialized.packet); |
+ ProcessPacket(serialized); |
delete serialized.packet; |
} |
} |
@@ -291,8 +293,8 @@ TEST_P(QuicPacketCreatorTest, SerializeWithFEC) { |
EXPECT_CALL(framer_visitor_, OnStreamFrame(_)); |
EXPECT_CALL(framer_visitor_, OnPacketComplete()); |
} |
- ProcessPacket(serialized_packet_.packet); |
- ClearSerializedPacket(&serialized_packet_); |
+ ProcessPacket(serialized_packet_); |
+ DeleteSerializedPacket(); |
// Should return false since we do not have enough packets in the FEC group to |
// trigger an FEC packet. |
@@ -315,8 +317,8 @@ TEST_P(QuicPacketCreatorTest, SerializeWithFEC) { |
EXPECT_CALL(framer_visitor_, OnFecData(_)); |
EXPECT_CALL(framer_visitor_, OnPacketComplete()); |
} |
- ProcessPacket(serialized_packet_.packet); |
- ClearSerializedPacket(&serialized_packet_); |
+ ProcessPacket(serialized_packet_); |
+ DeleteSerializedPacket(); |
} |
TEST_P(QuicPacketCreatorTest, SerializeChangingSequenceNumberLength) { |
@@ -343,8 +345,8 @@ TEST_P(QuicPacketCreatorTest, SerializeChangingSequenceNumberLength) { |
EXPECT_CALL(framer_visitor_, OnAckFrame(_)); |
EXPECT_CALL(framer_visitor_, OnPacketComplete()); |
} |
- ProcessPacket(serialized_packet_.packet); |
- ClearSerializedPacket(&serialized_packet_); |
+ ProcessPacket(serialized_packet_); |
+ DeleteSerializedPacket(); |
creator_.AddSavedFrame(frames_[0]); |
creator_.Flush(); |
@@ -363,8 +365,8 @@ TEST_P(QuicPacketCreatorTest, SerializeChangingSequenceNumberLength) { |
EXPECT_CALL(framer_visitor_, OnAckFrame(_)); |
EXPECT_CALL(framer_visitor_, OnPacketComplete()); |
} |
- ProcessPacket(serialized_packet_.packet); |
- ClearSerializedPacket(&serialized_packet_); |
+ ProcessPacket(serialized_packet_); |
+ DeleteSerializedPacket(); |
} |
TEST_P(QuicPacketCreatorTest, ChangeSequenceNumberLengthMidPacket) { |
@@ -411,10 +413,10 @@ TEST_P(QuicPacketCreatorTest, ChangeSequenceNumberLengthMidPacket) { |
EXPECT_CALL(framer_visitor_, OnStopWaitingFrame(_)); |
EXPECT_CALL(framer_visitor_, OnPacketComplete()); |
} |
- ProcessPacket(serialized_packet_.packet); |
+ ProcessPacket(serialized_packet_); |
EXPECT_EQ(PACKET_1BYTE_PACKET_NUMBER, |
header.public_header.packet_number_length); |
- ClearSerializedPacket(&serialized_packet_); |
+ DeleteSerializedPacket(); |
// Packet 2. |
EXPECT_FALSE(creator_.HasPendingFrames()); |
@@ -441,11 +443,11 @@ TEST_P(QuicPacketCreatorTest, ChangeSequenceNumberLengthMidPacket) { |
EXPECT_CALL(framer_visitor_, OnStopWaitingFrame(_)); |
EXPECT_CALL(framer_visitor_, OnPacketComplete()); |
} |
- ProcessPacket(serialized_packet_.packet); |
+ ProcessPacket(serialized_packet_); |
EXPECT_EQ(PACKET_4BYTE_PACKET_NUMBER, |
header.public_header.packet_number_length); |
- ClearSerializedPacket(&serialized_packet_); |
+ DeleteSerializedPacket(); |
delete ack_frame.ack_frame; |
} |
@@ -487,8 +489,8 @@ TEST_P(QuicPacketCreatorTest, SerializeWithFECChangingSequenceNumberLength) { |
EXPECT_CALL(framer_visitor_, OnStreamFrame(_)); |
EXPECT_CALL(framer_visitor_, OnPacketComplete()); |
} |
- ProcessPacket(serialized_packet_.packet); |
- ClearSerializedPacket(&serialized_packet_); |
+ ProcessPacket(serialized_packet_); |
+ DeleteSerializedPacket(); |
// Generate Packet 2. |
ASSERT_TRUE(creator_.ConsumeData(2u, io_vector, 0u, 0u, false, false, &frame, |
@@ -508,8 +510,8 @@ TEST_P(QuicPacketCreatorTest, SerializeWithFECChangingSequenceNumberLength) { |
EXPECT_CALL(framer_visitor_, OnStreamFrame(_)); |
EXPECT_CALL(framer_visitor_, OnPacketComplete()); |
} |
- ProcessPacket(serialized_packet_.packet); |
- ClearSerializedPacket(&serialized_packet_); |
+ ProcessPacket(serialized_packet_); |
+ DeleteSerializedPacket(); |
// Should return false since we do not have enough packets in the FEC group to |
// trigger an FEC packet. |
@@ -537,8 +539,8 @@ TEST_P(QuicPacketCreatorTest, SerializeWithFECChangingSequenceNumberLength) { |
EXPECT_CALL(framer_visitor_, OnFecData(_)); |
EXPECT_CALL(framer_visitor_, OnPacketComplete()); |
} |
- ProcessPacket(serialized_packet_.packet); |
- ClearSerializedPacket(&serialized_packet_); |
+ ProcessPacket(serialized_packet_); |
+ DeleteSerializedPacket(); |
// Ensure the next FEC group starts using the new packet number length. |
ASSERT_TRUE(creator_.ConsumeData(3u, io_vector, 0u, 0u, false, false, &frame, |
@@ -549,7 +551,7 @@ TEST_P(QuicPacketCreatorTest, SerializeWithFECChangingSequenceNumberLength) { |
creator_.Flush(); |
EXPECT_EQ(PACKET_4BYTE_PACKET_NUMBER, |
serialized_packet_.packet_number_length); |
- ClearSerializedPacket(&serialized_packet_); |
+ DeleteSerializedPacket(); |
} |
TEST_P(QuicPacketCreatorTest, ReserializeFramesWithSequenceNumberLength) { |
@@ -593,7 +595,7 @@ TEST_P(QuicPacketCreatorTest, ReserializeFramesWithSequenceNumberLength) { |
EXPECT_CALL(framer_visitor_, OnStreamFrame(_)); |
EXPECT_CALL(framer_visitor_, OnPacketComplete()); |
} |
- ProcessPacket(serialized.packet); |
+ ProcessPacket(serialized); |
delete serialized.packet; |
delete stream_frame; |
} |
@@ -742,7 +744,7 @@ TEST_P(QuicPacketCreatorTest, SerializeConnectionClose) { |
EXPECT_CALL(framer_visitor_, OnConnectionCloseFrame(_)); |
EXPECT_CALL(framer_visitor_, OnPacketComplete()); |
- ProcessPacket(serialized.packet); |
+ ProcessPacket(serialized); |
delete serialized.packet; |
} |
@@ -913,7 +915,7 @@ TEST_P(QuicPacketCreatorTest, StreamFrameConsumption) { |
.WillOnce(Invoke(this, &QuicPacketCreatorTest::SaveSerializedPacket)); |
creator_.Flush(); |
ASSERT_TRUE(serialized_packet_.packet); |
- ClearSerializedPacket(&serialized_packet_); |
+ DeleteSerializedPacket(); |
} |
} |
@@ -965,7 +967,7 @@ TEST_P(QuicPacketCreatorTest, StreamFrameConsumptionWithFec) { |
} |
creator_.Flush(); |
ASSERT_TRUE(serialized_packet_.packet); |
- ClearSerializedPacket(&serialized_packet_); |
+ DeleteSerializedPacket(); |
} |
} |
@@ -1002,7 +1004,7 @@ TEST_P(QuicPacketCreatorTest, CryptoStreamFramePacketPadding) { |
} else { |
EXPECT_EQ(kDefaultMaxPacketSize, serialized_packet_.packet->length()); |
} |
- ClearSerializedPacket(&serialized_packet_); |
+ DeleteSerializedPacket(); |
} |
} |
@@ -1036,7 +1038,7 @@ TEST_P(QuicPacketCreatorTest, NonCryptoStreamFramePacketNonPadding) { |
} else { |
EXPECT_EQ(kDefaultMaxPacketSize, serialized_packet_.packet->length()); |
} |
- ClearSerializedPacket(&serialized_packet_); |
+ DeleteSerializedPacket(); |
} |
} |
@@ -1133,7 +1135,7 @@ TEST_P(QuicPacketCreatorTest, SerializeFrame) { |
EXPECT_CALL(framer_visitor_, OnStreamFrame(_)); |
EXPECT_CALL(framer_visitor_, OnPacketComplete()); |
} |
- ProcessPacket(serialized.packet); |
+ ProcessPacket(serialized); |
EXPECT_EQ(GetParam().version_serialization, |
header.public_header.version_flag); |
delete serialized.packet; |
@@ -1164,7 +1166,7 @@ TEST_P(QuicPacketCreatorTest, ConsumeDataLargerThanOneStreamFrame) { |
const string payload(payload_length, 'a'); |
CheckStreamFrame(frame, 1u, payload, 0u, false); |
creator_.Flush(); |
- ClearSerializedPacket(&serialized_packet_); |
+ DeleteSerializedPacket(); |
} |
TEST_P(QuicPacketCreatorTest, AddFrameAndFlush) { |
@@ -1213,7 +1215,7 @@ TEST_P(QuicPacketCreatorTest, AddFrameAndFlush) { |
ASSERT_EQ(1u, retransmittable.size()); |
EXPECT_EQ(STREAM_FRAME, retransmittable[0].type); |
ASSERT_TRUE(retransmittable[0].stream_frame); |
- ClearSerializedPacket(&serialized_packet_); |
+ DeleteSerializedPacket(); |
EXPECT_FALSE(creator_.HasPendingFrames()); |
EXPECT_EQ(max_plaintext_size - |
@@ -1266,7 +1268,7 @@ TEST_P(QuicPacketCreatorTest, SerializeTruncatedAckFrameWithLargePacketSize) { |
ASSERT_TRUE(serialized_packet_.packet); |
EXPECT_EQ(est_packet_size, client_framer_.GetMaxPlaintextSize( |
serialized_packet_.packet->length())); |
- ClearSerializedPacket(&serialized_packet_); |
+ DeleteSerializedPacket(); |
} |
TEST_P(QuicPacketCreatorTest, SerializeTruncatedAckFrameWithSmallPacketSize) { |
@@ -1304,7 +1306,7 @@ TEST_P(QuicPacketCreatorTest, SerializeTruncatedAckFrameWithSmallPacketSize) { |
ASSERT_TRUE(serialized_packet_.packet); |
EXPECT_GE(est_packet_size, client_framer_.GetMaxPlaintextSize( |
serialized_packet_.packet->length())); |
- ClearSerializedPacket(&serialized_packet_); |
+ DeleteSerializedPacket(); |
} |
TEST_P(QuicPacketCreatorTest, EntropyFlag) { |
@@ -1396,7 +1398,7 @@ TEST_P(QuicPacketCreatorTest, ResetFecGroup) { |
creator_.MaybeSendFecPacketAndCloseGroup(/*force_send_fec=*/true, |
/*is_fec_timeout=*/false); |
ASSERT_EQ(3u, serialized_packet_.packet_number); |
- ClearSerializedPacket(&serialized_packet_); |
+ DeleteSerializedPacket(); |
} |
TEST_P(QuicPacketCreatorTest, ResetFecGroupWithQueuedFrames) { |
@@ -1615,7 +1617,7 @@ TEST_P(QuicPacketCreatorTest, SerializePacketOnDifferentPath) { |
EXPECT_EQ(1u, creator_.packet_number()); |
// Verify serialized data packet's path id. |
EXPECT_EQ(kDefaultPathId, serialized_packet_.path_id); |
- ClearSerializedPacket(&serialized_packet_); |
+ DeleteSerializedPacket(); |
// Change to path 1. |
QuicPathId kPathId1 = 1; |
@@ -1636,7 +1638,7 @@ TEST_P(QuicPacketCreatorTest, SerializePacketOnDifferentPath) { |
creator_.Flush(); |
// Verify serialized data packet's path id. |
EXPECT_EQ(kPathId1, serialized_packet_.path_id); |
- ClearSerializedPacket(&serialized_packet_); |
+ DeleteSerializedPacket(); |
} |
TEST_P(QuicPacketCreatorTest, AddUnencryptedStreamDataClosesConnection) { |