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

Unified Diff: net/quic/quic_packet_creator.cc

Issue 18307003: Implement the variable length changes necessary to easily accommodate (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merging with TOT Created 7 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/quic/quic_packet_creator.h ('k') | net/quic/quic_packet_creator_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/quic_packet_creator.cc
diff --git a/net/quic/quic_packet_creator.cc b/net/quic/quic_packet_creator.cc
index d1c3ca1ec0e35f353d1959aa9b767c7c7fc68841..139ed416d6a435d69cb157cd11fa8fcdf113ad4d 100644
--- a/net/quic/quic_packet_creator.cc
+++ b/net/quic/quic_packet_creator.cc
@@ -83,14 +83,14 @@ bool QuicPacketCreator::HasRoomForStreamFrame() const {
// static
size_t QuicPacketCreator::StreamFramePacketOverhead(
- int num_frames,
QuicGuidLength guid_length,
bool include_version,
QuicSequenceNumberLength sequence_number_length,
InFecGroup is_in_fec_group) {
return GetPacketHeaderSize(guid_length, include_version,
sequence_number_length, is_in_fec_group) +
- QuicFramer::GetMinStreamFrameSize() * num_frames;
+ // Assumes this is a stream with a single lone packet.
+ QuicFramer::GetMinStreamFrameSize(1, 0, true);
}
size_t QuicPacketCreator::CreateStreamFrame(QuicStreamId id,
@@ -100,7 +100,7 @@ size_t QuicPacketCreator::CreateStreamFrame(QuicStreamId id,
QuicFrame* frame) {
DCHECK_GT(options_.max_packet_length,
StreamFramePacketOverhead(
- 1, PACKET_8BYTE_GUID, kIncludeVersion,
+ PACKET_8BYTE_GUID, kIncludeVersion,
PACKET_6BYTE_SEQUENCE_NUMBER, IN_FEC_GROUP));
DCHECK(HasRoomForStreamFrame());
@@ -108,8 +108,19 @@ size_t QuicPacketCreator::CreateStreamFrame(QuicStreamId id,
size_t bytes_consumed = 0;
if (data.size() != 0) {
- size_t max_data_len = free_bytes - QuicFramer::GetMinStreamFrameSize();
- bytes_consumed = min<size_t>(max_data_len, data.size());
+ size_t min_last_stream_frame_size =
+ QuicFramer::GetMinStreamFrameSize(id, offset, true);
+ // Comparing against the last stream frame size including the length
+ // guarantees that all the bytes will fit. Otherwise there is a
+ // discontinuity where the packet goes one byte over due to the length data.
+ if (data.size() > free_bytes - min_last_stream_frame_size -
+ kQuicStreamPayloadLengthSize) {
+ // Its the last frame, put as much data as possible in.
+ bytes_consumed =
+ min<size_t>(free_bytes - min_last_stream_frame_size, data.size());
+ } else {
+ bytes_consumed = data.size();
+ }
bool set_fin = fin && bytes_consumed == data.size(); // Last frame.
StringPiece data_frame(data.data(), bytes_consumed);
« no previous file with comments | « net/quic/quic_packet_creator.h ('k') | net/quic/quic_packet_creator_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698