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_creator.h" | 5 #include "net/quic/quic_packet_creator.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 const size_t data_size = iov.total_length - iov_offset; | 316 const size_t data_size = iov.total_length - iov_offset; |
317 size_t min_frame_size = QuicFramer::GetMinStreamFrameSize( | 317 size_t min_frame_size = QuicFramer::GetMinStreamFrameSize( |
318 id, offset, /* last_frame_in_packet= */ true, is_in_fec_group); | 318 id, offset, /* last_frame_in_packet= */ true, is_in_fec_group); |
319 size_t bytes_consumed = min<size_t>(BytesFree() - min_frame_size, data_size); | 319 size_t bytes_consumed = min<size_t>(BytesFree() - min_frame_size, data_size); |
320 | 320 |
321 bool set_fin = fin && bytes_consumed == data_size; // Last frame. | 321 bool set_fin = fin && bytes_consumed == data_size; // Last frame. |
322 UniqueStreamBuffer buffer = NewStreamBuffer(bytes_consumed); | 322 UniqueStreamBuffer buffer = NewStreamBuffer(bytes_consumed); |
323 CopyToBuffer(iov, iov_offset, bytes_consumed, buffer.get()); | 323 CopyToBuffer(iov, iov_offset, bytes_consumed, buffer.get()); |
324 // TODO(zhongyi): figure out the lifetime of data. Crashes on windows only. | 324 // TODO(zhongyi): figure out the lifetime of data. Crashes on windows only. |
325 StringPiece data(buffer.get(), bytes_consumed); | 325 StringPiece data(buffer.get(), bytes_consumed); |
326 *frame = | 326 *frame = QuicFrame( |
327 QuicFrame(new QuicStreamFrame(id, set_fin, offset, data, buffer.Pass())); | 327 new QuicStreamFrame(id, set_fin, offset, data, std::move(buffer))); |
328 return bytes_consumed; | 328 return bytes_consumed; |
329 } | 329 } |
330 | 330 |
331 // static | 331 // static |
332 void QuicPacketCreator::CopyToBuffer(QuicIOVector iov, | 332 void QuicPacketCreator::CopyToBuffer(QuicIOVector iov, |
333 size_t iov_offset, | 333 size_t iov_offset, |
334 size_t length, | 334 size_t length, |
335 char* buffer) { | 335 char* buffer) { |
336 int iovnum = 0; | 336 int iovnum = 0; |
337 while (iovnum < iov.iov_count && iov_offset >= iov.iov[iovnum].iov_len) { | 337 while (iovnum < iov.iov_count && iov_offset >= iov.iov[iovnum].iov_len) { |
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
769 QuicPacketCount max_packets_in_flight) { | 769 QuicPacketCount max_packets_in_flight) { |
770 set_max_packets_per_fec_group(static_cast<size_t>( | 770 set_max_packets_per_fec_group(static_cast<size_t>( |
771 kMaxPacketsInFlightMultiplierForFecGroupSize * max_packets_in_flight)); | 771 kMaxPacketsInFlightMultiplierForFecGroupSize * max_packets_in_flight)); |
772 } | 772 } |
773 | 773 |
774 void QuicPacketCreator::OnRttChange(QuicTime::Delta rtt) { | 774 void QuicPacketCreator::OnRttChange(QuicTime::Delta rtt) { |
775 fec_timeout_ = rtt.Multiply(rtt_multiplier_for_fec_timeout_); | 775 fec_timeout_ = rtt.Multiply(rtt_multiplier_for_fec_timeout_); |
776 } | 776 } |
777 | 777 |
778 } // namespace net | 778 } // namespace net |
OLD | NEW |