OLD | NEW |
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/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "net/quic/quic_fec_group.h" | 9 #include "net/quic/quic_fec_group.h" |
10 #include "net/quic/quic_utils.h" | 10 #include "net/quic/quic_utils.h" |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 // We're done writing the data. Exit the loop. | 139 // We're done writing the data. Exit the loop. |
140 // We don't make this a precondition because we could have 0 bytes of data | 140 // We don't make this a precondition because we could have 0 bytes of data |
141 // if we're simply writing a fin. | 141 // if we're simply writing a fin. |
142 break; | 142 break; |
143 } | 143 } |
144 } | 144 } |
145 | 145 |
146 // Ensure the FEC group is closed at the end of this method if not in batch | 146 // Ensure the FEC group is closed at the end of this method if not in batch |
147 // mode. | 147 // mode. |
148 if (!InBatchMode() && packet_creator_->ShouldSendFec(true)) { | 148 if (!InBatchMode() && packet_creator_->ShouldSendFec(true)) { |
| 149 // TODO(jri): SerializeFec can return a NULL packet, and this should |
| 150 // cause an early return, with a call to delegate_->OnPacketGenerationError. |
149 SerializedPacket serialized_fec = packet_creator_->SerializeFec(); | 151 SerializedPacket serialized_fec = packet_creator_->SerializeFec(); |
150 DCHECK(serialized_fec.packet); | 152 DCHECK(serialized_fec.packet); |
151 delegate_->OnSerializedPacket(serialized_fec); | 153 delegate_->OnSerializedPacket(serialized_fec); |
152 } | 154 } |
153 | 155 |
154 DCHECK(InBatchMode() || !packet_creator_->HasPendingFrames()); | 156 DCHECK(InBatchMode() || !packet_creator_->HasPendingFrames()); |
155 return QuicConsumedData(total_bytes_consumed, fin_consumed); | 157 return QuicConsumedData(total_bytes_consumed, fin_consumed); |
156 } | 158 } |
157 | 159 |
158 bool QuicPacketGenerator::CanSendWithNextPendingFrameAddition() const { | 160 bool QuicPacketGenerator::CanSendWithNextPendingFrameAddition() const { |
(...skipping 19 matching lines...) Expand all Loading... |
178 } | 180 } |
179 | 181 |
180 if (!InBatchMode() || flush) { | 182 if (!InBatchMode() || flush) { |
181 if (packet_creator_->HasPendingFrames()) { | 183 if (packet_creator_->HasPendingFrames()) { |
182 SerializeAndSendPacket(); | 184 SerializeAndSendPacket(); |
183 } | 185 } |
184 | 186 |
185 // Ensure the FEC group is closed at the end of this method unless other | 187 // Ensure the FEC group is closed at the end of this method unless other |
186 // writes are pending. | 188 // writes are pending. |
187 if (packet_creator_->ShouldSendFec(true)) { | 189 if (packet_creator_->ShouldSendFec(true)) { |
| 190 // TODO(jri): SerializeFec can return a NULL packet, and this should |
| 191 // cause an early return, with a call to |
| 192 // delegate_->OnPacketGenerationError. |
188 SerializedPacket serialized_fec = packet_creator_->SerializeFec(); | 193 SerializedPacket serialized_fec = packet_creator_->SerializeFec(); |
189 DCHECK(serialized_fec.packet); | 194 DCHECK(serialized_fec.packet); |
190 delegate_->OnSerializedPacket(serialized_fec); | 195 delegate_->OnSerializedPacket(serialized_fec); |
191 } | 196 } |
192 } | 197 } |
193 } | 198 } |
194 | 199 |
195 bool QuicPacketGenerator::InBatchMode() { | 200 bool QuicPacketGenerator::InBatchMode() { |
196 return batch_mode_; | 201 return batch_mode_; |
197 } | 202 } |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 } | 269 } |
265 return success; | 270 return success; |
266 } | 271 } |
267 | 272 |
268 void QuicPacketGenerator::SerializeAndSendPacket() { | 273 void QuicPacketGenerator::SerializeAndSendPacket() { |
269 SerializedPacket serialized_packet = packet_creator_->SerializePacket(); | 274 SerializedPacket serialized_packet = packet_creator_->SerializePacket(); |
270 DCHECK(serialized_packet.packet); | 275 DCHECK(serialized_packet.packet); |
271 delegate_->OnSerializedPacket(serialized_packet); | 276 delegate_->OnSerializedPacket(serialized_packet); |
272 | 277 |
273 if (packet_creator_->ShouldSendFec(false)) { | 278 if (packet_creator_->ShouldSendFec(false)) { |
| 279 // TODO(jri): SerializeFec can return a NULL packet, and this should |
| 280 // cause an early return, with a call to delegate_->OnPacketGenerationError. |
274 SerializedPacket serialized_fec = packet_creator_->SerializeFec(); | 281 SerializedPacket serialized_fec = packet_creator_->SerializeFec(); |
275 DCHECK(serialized_fec.packet); | 282 DCHECK(serialized_fec.packet); |
276 delegate_->OnSerializedPacket(serialized_fec); | 283 delegate_->OnSerializedPacket(serialized_fec); |
277 } | 284 } |
278 } | 285 } |
279 | 286 |
280 } // namespace net | 287 } // namespace net |
OLD | NEW |