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

Side by Side Diff: net/quic/quic_packet_generator.cc

Issue 12806002: Land Recent QUIC Changes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: minor comment fix Created 7 years, 9 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 unified diff | Download patch | Annotate | Revision Log
« 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/quic/quic_packet_generator.h" 5 #include "net/quic/quic_packet_generator.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "net/quic/quic_fec_group.h" 8 #include "net/quic/quic_fec_group.h"
9 #include "net/quic/quic_utils.h" 9 #include "net/quic/quic_utils.h"
10 10
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 } 65 }
66 66
67 QuicConsumedData QuicPacketGenerator::ConsumeData(QuicStreamId id, 67 QuicConsumedData QuicPacketGenerator::ConsumeData(QuicStreamId id,
68 StringPiece data, 68 StringPiece data,
69 QuicStreamOffset offset, 69 QuicStreamOffset offset,
70 bool fin) { 70 bool fin) {
71 SendQueuedData(); 71 SendQueuedData();
72 72
73 size_t total_bytes_consumed = 0; 73 size_t total_bytes_consumed = 0;
74 bool fin_consumed = false; 74 bool fin_consumed = false;
75 bool has_retransmittable_data = true;
75 76
76 while (delegate_->CanWrite(false)) { 77 while (delegate_->CanWrite(false, has_retransmittable_data)) {
77 // TODO(rch) figure out FEC. 78 // TODO(rch) figure out FEC.
78 // packet_creator_.MaybeStartFEC(); 79 // packet_creator_.MaybeStartFEC();
79 QuicFrame frame; 80 QuicFrame frame;
80 size_t bytes_consumed = packet_creator_->CreateStreamFrame( 81 size_t bytes_consumed = packet_creator_->CreateStreamFrame(
81 id, data, offset + total_bytes_consumed, fin, &frame); 82 id, data, offset + total_bytes_consumed, fin, &frame);
82 bool success = packet_creator_->AddSavedFrame(frame); 83 bool success = packet_creator_->AddSavedFrame(frame);
83 DCHECK(success); 84 DCHECK(success);
84 85
85 total_bytes_consumed += bytes_consumed; 86 total_bytes_consumed += bytes_consumed;
86 fin_consumed = fin && bytes_consumed == data.size(); 87 fin_consumed = fin && bytes_consumed == data.size();
(...skipping 19 matching lines...) Expand all
106 SerializedPacket serialized_fec = packet_creator_->SerializeFec(); 107 SerializedPacket serialized_fec = packet_creator_->SerializeFec();
107 DCHECK(serialized_fec.packet); 108 DCHECK(serialized_fec.packet);
108 delegate_->OnSerializedPacket(serialized_fec); 109 delegate_->OnSerializedPacket(serialized_fec);
109 } 110 }
110 111
111 DCHECK(!should_flush_ || !packet_creator_->HasPendingFrames()); 112 DCHECK(!should_flush_ || !packet_creator_->HasPendingFrames());
112 return QuicConsumedData(total_bytes_consumed, fin_consumed); 113 return QuicConsumedData(total_bytes_consumed, fin_consumed);
113 } 114 }
114 115
115 void QuicPacketGenerator::SendQueuedData() { 116 void QuicPacketGenerator::SendQueuedData() {
116 while (HasPendingData() && delegate_->CanWrite(false)) { 117 while (HasPendingData() &&
118 delegate_->CanWrite(false, packet_creator_->HasPendingFrames())) {
117 if (!AddNextPendingFrame()) { 119 if (!AddNextPendingFrame()) {
118 // Packet was full, so serialize and send it. 120 // Packet was full, so serialize and send it.
119 SerializeAndSendPacket(); 121 SerializeAndSendPacket();
120 } 122 }
121 } 123 }
122 124
123 if (should_flush_) { 125 if (should_flush_) {
124 if (packet_creator_->HasPendingFrames()) { 126 if (packet_creator_->HasPendingFrames()) {
125 SerializeAndSendPacket(); 127 SerializeAndSendPacket();
126 } 128 }
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 delegate_->OnSerializedPacket(serialized_packet); 193 delegate_->OnSerializedPacket(serialized_packet);
192 194
193 if (packet_creator_->ShouldSendFec(false)) { 195 if (packet_creator_->ShouldSendFec(false)) {
194 SerializedPacket serialized_fec = packet_creator_->SerializeFec(); 196 SerializedPacket serialized_fec = packet_creator_->SerializeFec();
195 DCHECK(serialized_fec.packet); 197 DCHECK(serialized_fec.packet);
196 delegate_->OnSerializedPacket(serialized_fec); 198 delegate_->OnSerializedPacket(serialized_fec);
197 } 199 }
198 } 200 }
199 201
200 } // namespace net 202 } // namespace net
OLDNEW
« 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