Remove QuicPacketCreator::AddSavedFrame() and make QuicPacketCreator::AddFrame() public. gfe-relnote: no behavior change. Not protected. PiperOrigin-RevId: 281456340 Change-Id: I53bccacca15c04573e3b3fca17f591414e997ba9
diff --git a/quic/core/quic_dispatcher.cc b/quic/core/quic_dispatcher.cc index 31faade..b9252c8 100644 --- a/quic/core/quic_dispatcher.cc +++ b/quic/core/quic_dispatcher.cc
@@ -176,7 +176,7 @@ framer_.transport_version(), error_code, error_details, /*transport_close_frame_type=*/0); - if (!creator_.AddSavedFrame(QuicFrame(frame), NOT_RETRANSMISSION)) { + if (!creator_.AddFrame(QuicFrame(frame), NOT_RETRANSMISSION)) { QUIC_BUG << "Unable to add frame to an empty packet"; delete frame; return;
diff --git a/quic/core/quic_packet_creator.cc b/quic/core/quic_packet_creator.cc index 8c17421..1a957f8 100644 --- a/quic/core/quic_packet_creator.cc +++ b/quic/core/quic_packet_creator.cc
@@ -675,11 +675,6 @@ return packet_size_; } -bool QuicPacketCreator::AddSavedFrame(const QuicFrame& frame, - TransmissionType transmission_type) { - return AddFrame(frame, transmission_type); -} - bool QuicPacketCreator::AddPaddedSavedFrame( const QuicFrame& frame, TransmissionType transmission_type) { @@ -1098,7 +1093,7 @@ DCHECK(QuicUtils::IsRetransmittableFrame(frame.type)) << frame; MaybeBundleAckOpportunistically(); if (HasPendingFrames()) { - if (AddSavedFrame(frame, next_transmission_type_)) { + if (AddFrame(frame, next_transmission_type_)) { // There is pending frames and current frame fits. return true; } @@ -1110,7 +1105,7 @@ // Do not check congestion window for ping or connection close frames. return false; } - const bool success = AddSavedFrame(frame, next_transmission_type_); + const bool success = AddFrame(frame, next_transmission_type_); QUIC_BUG_IF(!success) << "Failed to add frame:" << frame << " transmission_type:" << next_transmission_type_; return success; @@ -1328,7 +1323,7 @@ for (const auto& frame : frames) { DCHECK(frame.type == ACK_FRAME || frame.type == STOP_WAITING_FRAME); if (HasPendingFrames()) { - if (AddSavedFrame(frame, next_transmission_type_)) { + if (AddFrame(frame, next_transmission_type_)) { // There is pending frames and current frame fits. continue; } @@ -1340,7 +1335,7 @@ NOT_HANDSHAKE)) { return false; } - const bool success = AddSavedFrame(frame, next_transmission_type_); + const bool success = AddFrame(frame, next_transmission_type_); QUIC_BUG_IF(!success) << "Failed to flush " << frame; } return true; @@ -1407,7 +1402,7 @@ FlushCurrentPacket(); } QuicMessageFrame* frame = new QuicMessageFrame(message_id, message); - const bool success = AddSavedFrame(QuicFrame(frame), next_transmission_type_); + const bool success = AddFrame(QuicFrame(frame), next_transmission_type_); if (!success) { QUIC_BUG << "Failed to send message " << message_id; delete frame;
diff --git a/quic/core/quic_packet_creator.h b/quic/core/quic_packet_creator.h index 7460502..8e066a9 100644 --- a/quic/core/quic_packet_creator.h +++ b/quic/core/quic_packet_creator.h
@@ -195,8 +195,7 @@ // Tries to add |frame| to the packet creator's list of frames to be // serialized. If the frame does not fit into the current packet, flushes the // packet and returns false. - bool AddSavedFrame(const QuicFrame& frame, - TransmissionType transmission_type); + bool AddFrame(const QuicFrame& frame, TransmissionType transmission_type); // Identical to AddSavedFrame, but allows the frame to be padded. bool AddPaddedSavedFrame(const QuicFrame& frame, @@ -446,11 +445,6 @@ void FillPacketHeader(QuicPacketHeader* header); - // Adds a |frame| if there is space and returns false and flushes all pending - // frames if there isn't room. - bool AddFrame(const QuicFrame& frame, - TransmissionType transmission_type); - // Adds a padding frame to the current packet (if there is space) when (1) // current packet needs full padding or (2) there are pending paddings. void MaybeAddPadding();
diff --git a/quic/core/quic_packet_creator_test.cc b/quic/core/quic_packet_creator_test.cc index c7a38b2..b609413 100644 --- a/quic/core/quic_packet_creator_test.cc +++ b/quic/core/quic_packet_creator_test.cc
@@ -1464,8 +1464,7 @@ // Add a variety of frame types and then a padding frame. QuicAckFrame ack_frame(InitAckFrame(10u)); EXPECT_CALL(debug, OnFrameAddedToPacket(_)); - EXPECT_TRUE( - creator_.AddSavedFrame(QuicFrame(&ack_frame), NOT_RETRANSMISSION)); + EXPECT_TRUE(creator_.AddFrame(QuicFrame(&ack_frame), NOT_RETRANSMISSION)); EXPECT_TRUE(creator_.HasPendingFrames()); EXPECT_FALSE(creator_.HasPendingStreamFramesOfStream(stream_id)); @@ -1482,16 +1481,14 @@ QuicPaddingFrame padding_frame; EXPECT_CALL(debug, OnFrameAddedToPacket(_)); - EXPECT_TRUE( - creator_.AddSavedFrame(QuicFrame(padding_frame), NOT_RETRANSMISSION)); + EXPECT_TRUE(creator_.AddFrame(QuicFrame(padding_frame), NOT_RETRANSMISSION)); EXPECT_TRUE(creator_.HasPendingFrames()); EXPECT_EQ(0u, creator_.BytesFree()); // Packet is full. Creator will flush. EXPECT_CALL(delegate_, OnSerializedPacket(_)) .WillOnce(Invoke(this, &QuicPacketCreatorTest::SaveSerializedPacket)); - EXPECT_FALSE( - creator_.AddSavedFrame(QuicFrame(&ack_frame), NOT_RETRANSMISSION)); + EXPECT_FALSE(creator_.AddFrame(QuicFrame(&ack_frame), NOT_RETRANSMISSION)); // Ensure the packet is successfully created. ASSERT_TRUE(serialized_packet_.encrypted_buffer); @@ -1600,7 +1597,7 @@ QuicStreamFrame stream_frame(GetNthClientInitiatedStreamId(0), /*fin=*/false, 0u, QuicStringPiece()); EXPECT_QUIC_BUG( - creator_.AddSavedFrame(QuicFrame(stream_frame), NOT_RETRANSMISSION), + creator_.AddFrame(QuicFrame(stream_frame), NOT_RETRANSMISSION), "Cannot send stream data with level: ENCRYPTION_INITIAL"); } @@ -1615,7 +1612,7 @@ QuicStreamFrame stream_frame(GetNthClientInitiatedStreamId(0), /*fin=*/false, 0u, QuicStringPiece()); EXPECT_QUIC_BUG( - creator_.AddSavedFrame(QuicFrame(stream_frame), NOT_RETRANSMISSION), + creator_.AddFrame(QuicFrame(stream_frame), NOT_RETRANSMISSION), "Cannot send stream data with level: ENCRYPTION_HANDSHAKE"); } @@ -1791,20 +1788,19 @@ std::string message(creator_.GetCurrentLargestMessagePayload(), 'a'); QuicMessageFrame* message_frame = new QuicMessageFrame(1, MakeSpan(&allocator_, message, &storage)); - EXPECT_TRUE( - creator_.AddSavedFrame(QuicFrame(message_frame), NOT_RETRANSMISSION)); + EXPECT_TRUE(creator_.AddFrame(QuicFrame(message_frame), NOT_RETRANSMISSION)); EXPECT_TRUE(creator_.HasPendingFrames()); creator_.FlushCurrentPacket(); QuicMessageFrame* frame2 = new QuicMessageFrame(2, MakeSpan(&allocator_, "message", &storage)); - EXPECT_TRUE(creator_.AddSavedFrame(QuicFrame(frame2), NOT_RETRANSMISSION)); + EXPECT_TRUE(creator_.AddFrame(QuicFrame(frame2), NOT_RETRANSMISSION)); EXPECT_TRUE(creator_.HasPendingFrames()); // Verify if a new frame is added, 1 byte message length will be added. EXPECT_EQ(1u, creator_.ExpansionOnNewFrame()); QuicMessageFrame* frame3 = new QuicMessageFrame(3, MakeSpan(&allocator_, "message2", &storage)); - EXPECT_TRUE(creator_.AddSavedFrame(QuicFrame(frame3), NOT_RETRANSMISSION)); + EXPECT_TRUE(creator_.AddFrame(QuicFrame(frame3), NOT_RETRANSMISSION)); EXPECT_EQ(1u, creator_.ExpansionOnNewFrame()); creator_.FlushCurrentPacket(); @@ -1817,14 +1813,14 @@ NOT_RETRANSMISSION, &frame)); QuicMessageFrame* frame4 = new QuicMessageFrame(4, MakeSpan(&allocator_, "message", &storage)); - EXPECT_TRUE(creator_.AddSavedFrame(QuicFrame(frame4), NOT_RETRANSMISSION)); + EXPECT_TRUE(creator_.AddFrame(QuicFrame(frame4), NOT_RETRANSMISSION)); EXPECT_TRUE(creator_.HasPendingFrames()); // Verify there is not enough room for largest payload. EXPECT_FALSE(creator_.HasRoomForMessageFrame( creator_.GetCurrentLargestMessagePayload())); // Add largest message will causes the flush of the stream frame. QuicMessageFrame frame5(5, MakeSpan(&allocator_, message, &storage)); - EXPECT_FALSE(creator_.AddSavedFrame(QuicFrame(&frame5), NOT_RETRANSMISSION)); + EXPECT_FALSE(creator_.AddFrame(QuicFrame(&frame5), NOT_RETRANSMISSION)); EXPECT_FALSE(creator_.HasPendingFrames()); } @@ -1847,7 +1843,7 @@ 0, MakeSpan(&allocator_, QuicStringPiece(message_buffer.data(), message_size), &storage)); - EXPECT_TRUE(creator_.AddSavedFrame(QuicFrame(frame), NOT_RETRANSMISSION)); + EXPECT_TRUE(creator_.AddFrame(QuicFrame(frame), NOT_RETRANSMISSION)); EXPECT_TRUE(creator_.HasPendingFrames()); size_t expansion_bytes = message_size >= 64 ? 2 : 1; @@ -1908,13 +1904,13 @@ EXPECT_CALL(delegate_, OnSerializedPacket(_)) .WillOnce(Invoke(this, &QuicPacketCreatorTest::SaveSerializedPacket)); - EXPECT_TRUE(creator_.AddSavedFrame(ack_frame, LOSS_RETRANSMISSION)); + EXPECT_TRUE(creator_.AddFrame(ack_frame, LOSS_RETRANSMISSION)); ASSERT_FALSE(serialized_packet_.encrypted_buffer); - EXPECT_TRUE(creator_.AddSavedFrame(stream_frame, RTO_RETRANSMISSION)); + EXPECT_TRUE(creator_.AddFrame(stream_frame, RTO_RETRANSMISSION)); ASSERT_FALSE(serialized_packet_.encrypted_buffer); - EXPECT_TRUE(creator_.AddSavedFrame(padding_frame, TLP_RETRANSMISSION)); + EXPECT_TRUE(creator_.AddFrame(padding_frame, TLP_RETRANSMISSION)); creator_.FlushCurrentPacket(); ASSERT_TRUE(serialized_packet_.encrypted_buffer); @@ -2237,8 +2233,7 @@ creator_.SetSoftMaxPacketLength(overhead); EXPECT_EQ(overhead, creator_.max_packet_length()); QuicAckFrame ack_frame(InitAckFrame(10u)); - EXPECT_TRUE( - creator_.AddSavedFrame(QuicFrame(&ack_frame), NOT_RETRANSMISSION)); + EXPECT_TRUE(creator_.AddFrame(QuicFrame(&ack_frame), NOT_RETRANSMISSION)); EXPECT_TRUE(creator_.HasPendingFrames()); }