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

Unified Diff: net/quic/quic_packet_creator.cc

Issue 1470713003: Landing Recent QUIC changes until and including Mon Nov 16 14:15:48 2015 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adding NET_EXPORT_PRIVATE to DelegateInterface. Created 5 years, 1 month 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
Index: net/quic/quic_packet_creator.cc
diff --git a/net/quic/quic_packet_creator.cc b/net/quic/quic_packet_creator.cc
index c2a400b6c9c86a2c175096bf595b41aeec093f45..d76488ea1870ad3182fb209c6f43fd49143ed7e9 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)),
@@ -237,6 +239,28 @@ void QuicPacketCreator::UpdatePacketNumberLength(
QuicFramer::GetMinSequenceNumberLength(delta * 4);
}
+bool QuicPacketCreator::ConsumeData(QuicStreamId id,
+ QuicIOVector iov,
+ size_t iov_offset,
+ QuicStreamOffset offset,
+ 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);
+
+ bool success = AddFrame(*frame,
+ /*save_retransmittable_frames=*/true, needs_padding,
+ std::move(buffer));
+ DCHECK(success);
+ return true;
+}
+
bool QuicPacketCreator::HasRoomForStreamFrame(QuicStreamId id,
QuicStreamOffset offset) const {
// TODO(jri): This is a simple safe decision for now, but make
@@ -413,6 +437,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();
}
@@ -649,6 +686,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_);

Powered by Google App Engine
This is Rietveld 408576698