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

Unified Diff: net/quic/quic_packet_generator.cc

Issue 20227003: Land Recent QUIC changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Land Recent QUIC changes Created 7 years, 5 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_generator.h ('k') | net/quic/quic_packet_generator_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/quic_packet_generator.cc
diff --git a/net/quic/quic_packet_generator.cc b/net/quic/quic_packet_generator.cc
index e6aeac76f07ba4b11396928edd5cf25f914c08fb..08bad9476c2bf033167875250615631af5e9d770 100644
--- a/net/quic/quic_packet_generator.cc
+++ b/net/quic/quic_packet_generator.cc
@@ -112,11 +112,21 @@ QuicConsumedData QuicPacketGenerator::ConsumeData(QuicStreamId id,
return QuicConsumedData(total_bytes_consumed, fin_consumed);
}
+bool QuicPacketGenerator::CanSendWithNextPendingFrameAddition() const {
+ DCHECK(HasPendingFrames());
+ HasRetransmittableData retransmittable =
+ (should_send_ack_ || should_send_feedback_) ? NO_RETRANSMITTABLE_DATA
+ : HAS_RETRANSMITTABLE_DATA;
+ if (retransmittable == HAS_RETRANSMITTABLE_DATA) {
+ DCHECK(!queued_control_frames_.empty()); // These are retransmittable.
+ }
+ return delegate_->CanWrite(NOT_RETRANSMISSION, retransmittable);
+}
+
void QuicPacketGenerator::SendQueuedFrames() {
packet_creator_->MaybeStartFEC();
- while (HasPendingFrames() && delegate_->CanWrite(NOT_RETRANSMISSION,
- packet_creator_->HasPendingFrames() ?
- HAS_RETRANSMITTABLE_DATA : NO_RETRANSMITTABLE_DATA)) {
+ // Only add pending frames if we are SURE we can then send the whole packet.
+ while (HasPendingFrames() && CanSendWithNextPendingFrameAddition()) {
if (!AddNextPendingFrame()) {
// Packet was full, so serialize and send it.
SerializeAndSendPacket();
@@ -159,28 +169,26 @@ bool QuicPacketGenerator::HasPendingFrames() const {
bool QuicPacketGenerator::AddNextPendingFrame() {
if (should_send_ack_) {
- pending_ack_frame_.reset(delegate_->CreateAckFrame());
- if (!AddFrame(QuicFrame(pending_ack_frame_.get()))) {
- // packet was full
- return false;
- }
- should_send_ack_ = false;
- return true;
+ pending_ack_frame_.reset((delegate_->CreateAckFrame()));
+ // If we can't this add the frame now, then we still need to do so later.
+ should_send_ack_ = !AddFrame(QuicFrame(pending_ack_frame_.get()));
+ // Return success if we have cleared out this flag (i.e., added the frame).
+ // If we still need to send, then the frame is full, and we have failed.
+ return !should_send_ack_;
}
if (should_send_feedback_) {
- pending_feedback_frame_.reset(delegate_->CreateFeedbackFrame());
- if (!AddFrame(QuicFrame(pending_feedback_frame_.get()))) {
- // packet was full
- return false;
- }
- should_send_feedback_ = false;
- return true;
+ pending_feedback_frame_.reset((delegate_->CreateFeedbackFrame()));
+ // If we can't this add the frame now, then we still need to do so later.
+ should_send_feedback_ = !AddFrame(QuicFrame(pending_feedback_frame_.get()));
+ // Return success if we have cleared out this flag (i.e., added the frame).
+ // If we still need to send, then the frame is full, and we have failed.
+ return !should_send_feedback_;
}
DCHECK(!queued_control_frames_.empty());
if (!AddFrame(queued_control_frames_.back())) {
- // packet was full
+ // Packet was full.
return false;
}
queued_control_frames_.pop_back();
« no previous file with comments | « net/quic/quic_packet_generator.h ('k') | net/quic/quic_packet_generator_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698