| Index: net/quic/quic_packet_creator.cc
|
| diff --git a/net/quic/quic_packet_creator.cc b/net/quic/quic_packet_creator.cc
|
| index c4b57a670b3b894a4d5724e589549043c03eadb0..3c27b9d857914800cd193c7111412c3512053adc 100644
|
| --- a/net/quic/quic_packet_creator.cc
|
| +++ b/net/quic/quic_packet_creator.cc
|
| @@ -69,8 +69,10 @@ class QuicRandomBoolSource {
|
|
|
| QuicPacketCreator::QuicPacketCreator(QuicConnectionId connection_id,
|
| QuicFramer* framer,
|
| - QuicRandom* random_generator)
|
| - : connection_id_(connection_id),
|
| + QuicRandom* random_generator,
|
| + DelegateInterface* delegate)
|
| + : delegate_(delegate),
|
| + connection_id_(connection_id),
|
| encryption_level_(ENCRYPTION_NONE),
|
| framer_(framer),
|
| random_bool_source_(new QuicRandomBoolSource(random_generator)),
|
| @@ -244,13 +246,20 @@ bool QuicPacketCreator::ConsumeData(QuicStreamId id,
|
| bool fin,
|
| bool needs_padding,
|
| QuicFrame* frame) {
|
| + if (!HasRoomForStreamFrame(id, offset)) {
|
| + Flush();
|
| + return false;
|
| + }
|
| +
|
| UniqueStreamBuffer buffer;
|
| CreateStreamFrame(id, iov, iov_offset, offset, fin, frame, &buffer);
|
|
|
| - return AddFrame(*frame,
|
| - /*save_retransmittable_frames=*/true,
|
| - needs_padding,
|
| - std::move(buffer));
|
| + bool success = AddFrame(*frame,
|
| + /*save_retransmittable_frames=*/true,
|
| + needs_padding,
|
| + std::move(buffer));
|
| + DCHECK(success);
|
| + return true;
|
| }
|
|
|
| bool QuicPacketCreator::HasRoomForStreamFrame(QuicStreamId id,
|
| @@ -429,6 +438,19 @@ SerializedPacket QuicPacketCreator::SerializeAllFrames(const QuicFrames& frames,
|
| return packet;
|
| }
|
|
|
| +void QuicPacketCreator::Flush() {
|
| + if (!HasPendingFrames()) {
|
| + return;
|
| + }
|
| +
|
| + // TODO(rtenneti): Change the default 64 alignas value (used the default
|
| + // value from CACHELINE_SIZE).
|
| + ALIGNAS(64) char seralized_packet_buffer[kMaxPacketSize];
|
| + SerializedPacket serialized_packet =
|
| + SerializePacket(seralized_packet_buffer, kMaxPacketSize);
|
| + delegate_->OnSerializedPacket(&serialized_packet);
|
| +}
|
| +
|
| bool QuicPacketCreator::HasPendingFrames() const {
|
| return !queued_frames_.empty();
|
| }
|
| @@ -665,6 +687,8 @@ bool QuicPacketCreator::AddFrame(const QuicFrame& frame,
|
| frame, BytesFree(), queued_frames_.empty(), true, is_in_fec_group,
|
| packet_number_length_);
|
| if (frame_len == 0) {
|
| + // Current open packet is full.
|
| + Flush();
|
| return false;
|
| }
|
| DCHECK_LT(0u, packet_size_);
|
|
|