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

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

Issue 23597045: Land Recent QUIC changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merged QuicPriority to RequestPriority changes 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 QuicAckNotifier* notifier) { 81 QuicAckNotifier* notifier) {
82 IsHandshake handshake = id == kCryptoStreamId ? IS_HANDSHAKE : NOT_HANDSHAKE; 82 IsHandshake handshake = id == kCryptoStreamId ? IS_HANDSHAKE : NOT_HANDSHAKE;
83 // The caller should have flushed pending frames before sending handshake 83 // The caller should have flushed pending frames before sending handshake
84 // messages. 84 // messages.
85 DCHECK(handshake == NOT_HANDSHAKE || !HasPendingFrames()); 85 DCHECK(handshake == NOT_HANDSHAKE || !HasPendingFrames());
86 SendQueuedFrames(); 86 SendQueuedFrames();
87 87
88 size_t total_bytes_consumed = 0; 88 size_t total_bytes_consumed = 0;
89 bool fin_consumed = false; 89 bool fin_consumed = false;
90 90
91 if (!packet_creator_->HasRoomForStreamFrame(id, offset)) {
92 SerializeAndSendPacket();
93 }
91 while (delegate_->CanWrite(NOT_RETRANSMISSION, HAS_RETRANSMITTABLE_DATA, 94 while (delegate_->CanWrite(NOT_RETRANSMISSION, HAS_RETRANSMITTABLE_DATA,
92 handshake)) { 95 handshake)) {
93 QuicFrame frame; 96 QuicFrame frame;
94 size_t bytes_consumed; 97 size_t bytes_consumed;
95 if (notifier != NULL) { 98 if (notifier != NULL) {
96 // We want to track which packet this stream frame ends up in. 99 // We want to track which packet this stream frame ends up in.
97 bytes_consumed = packet_creator_->CreateStreamFrameWithNotifier( 100 bytes_consumed = packet_creator_->CreateStreamFrameWithNotifier(
98 id, data, offset + total_bytes_consumed, fin, notifier, &frame); 101 id, data, offset + total_bytes_consumed, fin, notifier, &frame);
99 } else { 102 } else {
100 bytes_consumed = packet_creator_->CreateStreamFrame( 103 bytes_consumed = packet_creator_->CreateStreamFrame(
101 id, data, offset + total_bytes_consumed, fin, &frame); 104 id, data, offset + total_bytes_consumed, fin, &frame);
102 } 105 }
103 bool success = AddFrame(frame); 106 if (!AddFrame(frame)) {
104 DCHECK(success); 107 LOG(DFATAL) << "Failed to add stream frame.";
108 // Inability to add a STREAM frame creates an unrecoverable hole in a
109 // the stream, so it's best to close the connection.
110 delegate_->CloseConnection(QUIC_INTERNAL_ERROR, false);
111 return QuicConsumedData(0, false);
112 }
105 113
106 total_bytes_consumed += bytes_consumed; 114 total_bytes_consumed += bytes_consumed;
107 fin_consumed = fin && bytes_consumed == data.size(); 115 fin_consumed = fin && bytes_consumed == data.size();
108 data.remove_prefix(bytes_consumed); 116 data.remove_prefix(bytes_consumed);
109 DCHECK(data.empty() || packet_creator_->BytesFree() == 0u); 117 DCHECK(data.empty() || packet_creator_->BytesFree() == 0u);
110 118
111 // TODO(ianswett): Restore packet reordering. 119 // TODO(ianswett): Restore packet reordering.
112 if (!InBatchMode() || !packet_creator_->HasRoomForStreamFrame(id, offset)) { 120 if (!InBatchMode() || !packet_creator_->HasRoomForStreamFrame(id, offset)) {
113 SerializeAndSendPacket(); 121 SerializeAndSendPacket();
114 } 122 }
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 244
237 if (packet_creator_->ShouldSendFec(false)) { 245 if (packet_creator_->ShouldSendFec(false)) {
238 SerializedPacket serialized_fec = packet_creator_->SerializeFec(); 246 SerializedPacket serialized_fec = packet_creator_->SerializeFec();
239 DCHECK(serialized_fec.packet); 247 DCHECK(serialized_fec.packet);
240 delegate_->OnSerializedPacket(serialized_fec); 248 delegate_->OnSerializedPacket(serialized_fec);
241 packet_creator_->MaybeStartFEC(); 249 packet_creator_->MaybeStartFEC();
242 } 250 }
243 } 251 }
244 252
245 } // namespace net 253 } // 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