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

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

Issue 2740453006: Add QuicStringPiece which is actually StringPiece. (Closed)
Patch Set: fix compile error and rebase Created 3 years, 9 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
« no previous file with comments | « net/quic/core/quic_packet_creator.h ('k') | net/quic/core/quic_packet_creator_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/core/quic_packet_creator.h" 5 #include "net/quic/core/quic_packet_creator.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cstdint> 8 #include <cstdint>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "net/quic/core/crypto/crypto_protocol.h" 11 #include "net/quic/core/crypto/crypto_protocol.h"
12 #include "net/quic/core/quic_data_writer.h" 12 #include "net/quic/core/quic_data_writer.h"
13 #include "net/quic/core/quic_flags.h" 13 #include "net/quic/core/quic_flags.h"
14 #include "net/quic/core/quic_utils.h" 14 #include "net/quic/core/quic_utils.h"
15 #include "net/quic/platform/api/quic_aligned.h" 15 #include "net/quic/platform/api/quic_aligned.h"
16 #include "net/quic/platform/api/quic_bug_tracker.h" 16 #include "net/quic/platform/api/quic_bug_tracker.h"
17 #include "net/quic/platform/api/quic_logging.h" 17 #include "net/quic/platform/api/quic_logging.h"
18 #include "net/quic/platform/api/quic_string_piece.h"
18 19
19 using base::StringPiece;
20 using std::string; 20 using std::string;
21 21
22 // If true, enforce that QUIC CHLOs fit in one packet. 22 // If true, enforce that QUIC CHLOs fit in one packet.
23 bool FLAGS_quic_enforce_single_packet_chlo = true; 23 bool FLAGS_quic_enforce_single_packet_chlo = true;
24 24
25 namespace net { 25 namespace net {
26 26
27 QuicPacketCreator::QuicPacketCreator(QuicConnectionId connection_id, 27 QuicPacketCreator::QuicPacketCreator(QuicConnectionId connection_id,
28 QuicFramer* framer, 28 QuicFramer* framer,
29 QuicBufferAllocator* buffer_allocator, 29 QuicBufferAllocator* buffer_allocator,
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 PACKET_6BYTE_PACKET_NUMBER, offset)); 185 PACKET_6BYTE_PACKET_NUMBER, offset));
186 186
187 QUIC_BUG_IF(!HasRoomForStreamFrame(id, offset)) 187 QUIC_BUG_IF(!HasRoomForStreamFrame(id, offset))
188 << "No room for Stream frame, BytesFree: " << BytesFree() 188 << "No room for Stream frame, BytesFree: " << BytesFree()
189 << " MinStreamFrameSize: " 189 << " MinStreamFrameSize: "
190 << QuicFramer::GetMinStreamFrameSize(id, offset, true); 190 << QuicFramer::GetMinStreamFrameSize(id, offset, true);
191 191
192 if (iov_offset == iov.total_length) { 192 if (iov_offset == iov.total_length) {
193 QUIC_BUG_IF(!fin) << "Creating a stream frame with no data or fin."; 193 QUIC_BUG_IF(!fin) << "Creating a stream frame with no data or fin.";
194 // Create a new packet for the fin, if necessary. 194 // Create a new packet for the fin, if necessary.
195 *frame = QuicFrame(new QuicStreamFrame(id, true, offset, StringPiece())); 195 *frame =
196 QuicFrame(new QuicStreamFrame(id, true, offset, QuicStringPiece()));
196 return; 197 return;
197 } 198 }
198 199
199 const size_t data_size = iov.total_length - iov_offset; 200 const size_t data_size = iov.total_length - iov_offset;
200 size_t min_frame_size = QuicFramer::GetMinStreamFrameSize( 201 size_t min_frame_size = QuicFramer::GetMinStreamFrameSize(
201 id, offset, /* last_frame_in_packet= */ true); 202 id, offset, /* last_frame_in_packet= */ true);
202 size_t bytes_consumed = 203 size_t bytes_consumed =
203 std::min<size_t>(BytesFree() - min_frame_size, data_size); 204 std::min<size_t>(BytesFree() - min_frame_size, data_size);
204 205
205 bool set_fin = fin && bytes_consumed == data_size; // Last frame. 206 bool set_fin = fin && bytes_consumed == data_size; // Last frame.
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 AddFrame(QuicFrame(QuicPaddingFrame(packet_.num_padding_bytes)), false); 625 AddFrame(QuicFrame(QuicPaddingFrame(packet_.num_padding_bytes)), false);
625 DCHECK(success); 626 DCHECK(success);
626 } 627 }
627 628
628 bool QuicPacketCreator::IncludeNonceInPublicHeader() { 629 bool QuicPacketCreator::IncludeNonceInPublicHeader() {
629 return have_diversification_nonce_ && 630 return have_diversification_nonce_ &&
630 packet_.encryption_level == ENCRYPTION_INITIAL; 631 packet_.encryption_level == ENCRYPTION_INITIAL;
631 } 632 }
632 633
633 } // namespace net 634 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/core/quic_packet_creator.h ('k') | net/quic/core/quic_packet_creator_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698