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

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

Issue 2599143003: Add a new QUIC platform API quic_aligned.h for the alignment macro definitions. (Closed)
Patch Set: windows Created 3 years, 12 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_framer.cc ('k') | net/quic/core/quic_types.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/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/logging.h" 10 #include "base/logging.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "net/quic/core/crypto/crypto_protocol.h" 12 #include "net/quic/core/crypto/crypto_protocol.h"
13 #include "net/quic/core/quic_bug_tracker.h" 13 #include "net/quic/core/quic_bug_tracker.h"
14 #include "net/quic/core/quic_data_writer.h" 14 #include "net/quic/core/quic_data_writer.h"
15 #include "net/quic/core/quic_flags.h" 15 #include "net/quic/core/quic_flags.h"
16 #include "net/quic/core/quic_utils.h" 16 #include "net/quic/core/quic_utils.h"
17 #include "net/quic/platform/api/quic_aligned.h"
17 18
18 using base::StringPiece; 19 using base::StringPiece;
19 using std::string; 20 using std::string;
20 21
21 // If true, enforce that QUIC CHLOs fit in one packet. 22 // If true, enforce that QUIC CHLOs fit in one packet.
22 bool FLAGS_quic_enforce_single_packet_chlo = true; 23 bool FLAGS_quic_enforce_single_packet_chlo = true;
23 24
24 namespace net { 25 namespace net {
25 26
26 QuicPacketCreator::QuicPacketCreator(QuicConnectionId connection_id, 27 QuicPacketCreator::QuicPacketCreator(QuicConnectionId connection_id,
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 OnSerializedPacket(); 307 OnSerializedPacket();
307 // Restore old values. 308 // Restore old values.
308 packet_.encryption_level = default_encryption_level; 309 packet_.encryption_level = default_encryption_level;
309 } 310 }
310 311
311 void QuicPacketCreator::Flush() { 312 void QuicPacketCreator::Flush() {
312 if (!HasPendingFrames()) { 313 if (!HasPendingFrames()) {
313 return; 314 return;
314 } 315 }
315 316
316 // TODO(rtenneti): Change the default 64 alignas value (used the default 317 QUIC_CACHELINE_ALIGNED char seralized_packet_buffer[kMaxPacketSize];
317 // value from CACHELINE_SIZE).
318 ALIGNAS(64) char seralized_packet_buffer[kMaxPacketSize];
319 SerializePacket(seralized_packet_buffer, kMaxPacketSize); 318 SerializePacket(seralized_packet_buffer, kMaxPacketSize);
320 OnSerializedPacket(); 319 OnSerializedPacket();
321 } 320 }
322 321
323 void QuicPacketCreator::OnSerializedPacket() { 322 void QuicPacketCreator::OnSerializedPacket() {
324 if (packet_.encrypted_buffer == nullptr) { 323 if (packet_.encrypted_buffer == nullptr) {
325 const string error_details = "Failed to SerializePacket."; 324 const string error_details = "Failed to SerializePacket.";
326 QUIC_BUG << error_details; 325 QUIC_BUG << error_details;
327 delegate_->OnUnrecoverableError(QUIC_FAILED_TO_SERIALIZE_PACKET, 326 delegate_->OnUnrecoverableError(QUIC_FAILED_TO_SERIALIZE_PACKET,
328 error_details, 327 error_details,
(...skipping 24 matching lines...) Expand all
353 const QuicIOVector& iov, 352 const QuicIOVector& iov,
354 QuicStreamOffset iov_offset, 353 QuicStreamOffset iov_offset,
355 QuicStreamOffset stream_offset, 354 QuicStreamOffset stream_offset,
356 bool fin, 355 bool fin,
357 QuicReferenceCountedPointer<QuicAckListenerInterface> ack_listener, 356 QuicReferenceCountedPointer<QuicAckListenerInterface> ack_listener,
358 size_t* num_bytes_consumed) { 357 size_t* num_bytes_consumed) {
359 DCHECK(queued_frames_.empty()); 358 DCHECK(queued_frames_.empty());
360 // Write out the packet header 359 // Write out the packet header
361 QuicPacketHeader header; 360 QuicPacketHeader header;
362 FillPacketHeader(&header); 361 FillPacketHeader(&header);
363 ALIGNAS(64) char encrypted_buffer[kMaxPacketSize]; 362 QUIC_CACHELINE_ALIGNED char encrypted_buffer[kMaxPacketSize];
364 QuicDataWriter writer(arraysize(encrypted_buffer), encrypted_buffer); 363 QuicDataWriter writer(arraysize(encrypted_buffer), encrypted_buffer);
365 if (!framer_->AppendPacketHeader(header, &writer)) { 364 if (!framer_->AppendPacketHeader(header, &writer)) {
366 QUIC_BUG << "AppendPacketHeader failed"; 365 QUIC_BUG << "AppendPacketHeader failed";
367 return; 366 return;
368 } 367 }
369 368
370 // Create a Stream frame with the remaining space. 369 // Create a Stream frame with the remaining space.
371 QUIC_BUG_IF(iov_offset == iov.total_length && !fin) 370 QUIC_BUG_IF(iov_offset == iov.total_length && !fin)
372 << "Creating a stream frame with no data or fin."; 371 << "Creating a stream frame with no data or fin.";
373 const size_t remaining_data_size = iov.total_length - iov_offset; 372 const size_t remaining_data_size = iov.total_length - iov_offset;
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 // Switching path needs to update packet number length. 656 // Switching path needs to update packet number length.
658 UpdatePacketNumberLength(least_packet_awaited_by_peer, max_packets_in_flight); 657 UpdatePacketNumberLength(least_packet_awaited_by_peer, max_packets_in_flight);
659 } 658 }
660 659
661 bool QuicPacketCreator::IncludeNonceInPublicHeader() { 660 bool QuicPacketCreator::IncludeNonceInPublicHeader() {
662 return have_diversification_nonce_ && 661 return have_diversification_nonce_ &&
663 packet_.encryption_level == ENCRYPTION_INITIAL; 662 packet_.encryption_level == ENCRYPTION_INITIAL;
664 } 663 }
665 664
666 } // namespace net 665 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/core/quic_framer.cc ('k') | net/quic/core/quic_types.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698