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

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

Issue 23691073: Land Recent QUIC changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Compiler/unittests fix Created 7 years, 3 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 } 63 }
64 64
65 void QuicPacketGenerator::AddControlFrame(const QuicFrame& frame) { 65 void QuicPacketGenerator::AddControlFrame(const QuicFrame& frame) {
66 queued_control_frames_.push_back(frame); 66 queued_control_frames_.push_back(frame);
67 SendQueuedFrames(); 67 SendQueuedFrames();
68 } 68 }
69 69
70 QuicConsumedData QuicPacketGenerator::ConsumeData(QuicStreamId id, 70 QuicConsumedData QuicPacketGenerator::ConsumeData(QuicStreamId id,
71 StringPiece data, 71 StringPiece data,
72 QuicStreamOffset offset, 72 QuicStreamOffset offset,
73 bool fin) {
74 return ConsumeData(id, data, offset, fin, NULL);
75 }
76
77 QuicConsumedData QuicPacketGenerator::ConsumeData(QuicStreamId id,
78 StringPiece data,
79 QuicStreamOffset offset,
80 bool fin, 73 bool fin,
81 QuicAckNotifier* notifier) { 74 QuicAckNotifier* notifier) {
82 IsHandshake handshake = id == kCryptoStreamId ? IS_HANDSHAKE : NOT_HANDSHAKE; 75 IsHandshake handshake = id == kCryptoStreamId ? IS_HANDSHAKE : NOT_HANDSHAKE;
83 // The caller should have flushed pending frames before sending handshake 76 // The caller should have flushed pending frames before sending handshake
84 // messages. 77 // messages.
85 DCHECK(handshake == NOT_HANDSHAKE || !HasPendingFrames()); 78 DCHECK(handshake == NOT_HANDSHAKE || !HasPendingFrames());
86 SendQueuedFrames(); 79 SendQueuedFrames();
87 80
88 size_t total_bytes_consumed = 0; 81 size_t total_bytes_consumed = 0;
89 bool fin_consumed = false; 82 bool fin_consumed = false;
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 return packet_creator_->HasPendingFrames() || HasPendingFrames(); 189 return packet_creator_->HasPendingFrames() || HasPendingFrames();
197 } 190 }
198 191
199 bool QuicPacketGenerator::HasPendingFrames() const { 192 bool QuicPacketGenerator::HasPendingFrames() const {
200 return should_send_ack_ || should_send_feedback_ || 193 return should_send_ack_ || should_send_feedback_ ||
201 !queued_control_frames_.empty(); 194 !queued_control_frames_.empty();
202 } 195 }
203 196
204 bool QuicPacketGenerator::AddNextPendingFrame() { 197 bool QuicPacketGenerator::AddNextPendingFrame() {
205 if (should_send_ack_) { 198 if (should_send_ack_) {
206 pending_ack_frame_.reset((delegate_->CreateAckFrame())); 199 pending_ack_frame_.reset(delegate_->CreateAckFrame());
207 // If we can't this add the frame now, then we still need to do so later. 200 // If we can't this add the frame now, then we still need to do so later.
208 should_send_ack_ = !AddFrame(QuicFrame(pending_ack_frame_.get())); 201 should_send_ack_ = !AddFrame(QuicFrame(pending_ack_frame_.get()));
209 // Return success if we have cleared out this flag (i.e., added the frame). 202 // Return success if we have cleared out this flag (i.e., added the frame).
210 // If we still need to send, then the frame is full, and we have failed. 203 // If we still need to send, then the frame is full, and we have failed.
211 return !should_send_ack_; 204 return !should_send_ack_;
212 } 205 }
213 206
214 if (should_send_feedback_) { 207 if (should_send_feedback_) {
215 pending_feedback_frame_.reset((delegate_->CreateFeedbackFrame())); 208 pending_feedback_frame_.reset(delegate_->CreateFeedbackFrame());
216 // If we can't this add the frame now, then we still need to do so later. 209 // If we can't this add the frame now, then we still need to do so later.
217 should_send_feedback_ = !AddFrame(QuicFrame(pending_feedback_frame_.get())); 210 should_send_feedback_ = !AddFrame(QuicFrame(pending_feedback_frame_.get()));
218 // Return success if we have cleared out this flag (i.e., added the frame). 211 // Return success if we have cleared out this flag (i.e., added the frame).
219 // If we still need to send, then the frame is full, and we have failed. 212 // If we still need to send, then the frame is full, and we have failed.
220 return !should_send_feedback_; 213 return !should_send_feedback_;
221 } 214 }
222 215
223 DCHECK(!queued_control_frames_.empty()); 216 DCHECK(!queued_control_frames_.empty());
224 if (!AddFrame(queued_control_frames_.back())) { 217 if (!AddFrame(queued_control_frames_.back())) {
225 // Packet was full. 218 // Packet was full.
(...skipping 18 matching lines...) Expand all
244 237
245 if (packet_creator_->ShouldSendFec(false)) { 238 if (packet_creator_->ShouldSendFec(false)) {
246 SerializedPacket serialized_fec = packet_creator_->SerializeFec(); 239 SerializedPacket serialized_fec = packet_creator_->SerializeFec();
247 DCHECK(serialized_fec.packet); 240 DCHECK(serialized_fec.packet);
248 delegate_->OnSerializedPacket(serialized_fec); 241 delegate_->OnSerializedPacket(serialized_fec);
249 packet_creator_->MaybeStartFEC(); 242 packet_creator_->MaybeStartFEC();
250 } 243 }
251 } 244 }
252 245
253 } // namespace net 246 } // 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