Make QuicPacketCreator::ExpansionOnNewFrameWithLastFrame() static. This is so that it can be reused in Chromium's QuicTestPacketMaker, see https://crrev.com/c/2324109. No functional change PiperOrigin-RevId: 323787606 Change-Id: I82b950b59465271c3e1fb5bebe639973dc55e061
diff --git a/quic/core/quic_packet_creator.cc b/quic/core/quic_packet_creator.cc index a0f189c..109042f 100644 --- a/quic/core/quic_packet_creator.cc +++ b/quic/core/quic_packet_creator.cc
@@ -704,11 +704,14 @@ if (queued_frames_.empty()) { return 0; } - return ExpansionOnNewFrameWithLastFrame(queued_frames_.back()); + return ExpansionOnNewFrameWithLastFrame(queued_frames_.back(), + framer_->transport_version()); } +// static size_t QuicPacketCreator::ExpansionOnNewFrameWithLastFrame( - const QuicFrame& last_frame) const { + const QuicFrame& last_frame, + QuicTransportVersion version) { if (last_frame.type == MESSAGE_FRAME) { return QuicDataWriter::GetVarInt62Len( last_frame.message_frame->message_length); @@ -716,7 +719,7 @@ if (last_frame.type != STREAM_FRAME) { return 0; } - if (VersionHasIetfQuicFrames(framer_->transport_version())) { + if (VersionHasIetfQuicFrames(version)) { return QuicDataWriter::GetVarInt62Len(last_frame.stream_frame.data_length); } return kQuicStreamPayloadLengthSize; @@ -1592,9 +1595,9 @@ size_t bytes_free = BytesFree() - serialized_frame_length; // Extra bytes needed (this is NOT padding needed) should be at least 1 // padding + expansion. - const size_t extra_bytes_needed = - std::max(1 + ExpansionOnNewFrameWithLastFrame(frame), - MinPlaintextPacketSize(framer_->version()) - frame_bytes); + const size_t extra_bytes_needed = std::max( + 1 + ExpansionOnNewFrameWithLastFrame(frame, framer_->transport_version()), + MinPlaintextPacketSize(framer_->version()) - frame_bytes); if (bytes_free < extra_bytes_needed) { // This frame does not fit. return 0;
diff --git a/quic/core/quic_packet_creator.h b/quic/core/quic_packet_creator.h index 7f3aa51..3cc7b64 100644 --- a/quic/core/quic_packet_creator.h +++ b/quic/core/quic_packet_creator.h
@@ -199,7 +199,8 @@ // Returns the number of bytes that the packet will expand by when a new frame // is going to be added. |last_frame| is the last frame of the packet. - size_t ExpansionOnNewFrameWithLastFrame(const QuicFrame& last_frame) const; + static size_t ExpansionOnNewFrameWithLastFrame(const QuicFrame& last_frame, + QuicTransportVersion version); // Returns the number of bytes in the current packet, including the header, // if serialized with the current frames. Adding a frame to the packet