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

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

Issue 1493483002: relnote: Refactor stream buffer allocation out into a unique_ptr with a custom deleter. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add back a comment for deleter Created 5 years 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
« no previous file with comments | « no previous file | net/quic/quic_protocol.h » ('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_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
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
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
OLDNEW
« no previous file with comments | « no previous file | net/quic/quic_protocol.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698