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

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

Issue 1667003002: Replace QuicEncryptedPacket's fields with equivalents in SerializedPacket. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@113395732
Patch Set: Created 4 years, 10 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/quic_utils.h ('k') | net/quic/test_tools/quic_packet_creator_peer.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/quic_utils.h" 5 #include "net/quic/quic_utils.h"
6 6
7 #include <ctype.h> 7 #include <ctype.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 delete it->stream_frame; 451 delete it->stream_frame;
452 it = frames->erase(it); 452 it = frames->erase(it);
453 } 453 }
454 } 454 }
455 455
456 // static 456 // static
457 void QuicUtils::ClearSerializedPacket(SerializedPacket* serialized_packet) { 457 void QuicUtils::ClearSerializedPacket(SerializedPacket* serialized_packet) {
458 if (!serialized_packet->retransmittable_frames.empty()) { 458 if (!serialized_packet->retransmittable_frames.empty()) {
459 DeleteFrames(&serialized_packet->retransmittable_frames); 459 DeleteFrames(&serialized_packet->retransmittable_frames);
460 } 460 }
461 delete serialized_packet->packet; 461 serialized_packet->encrypted_buffer = nullptr;
462 serialized_packet->packet = nullptr; 462 serialized_packet->encrypted_length = 0;
463 } 463 }
464 464
465 // static 465 // static
466 uint64_t QuicUtils::PackPathIdAndPacketNumber(QuicPathId path_id, 466 uint64_t QuicUtils::PackPathIdAndPacketNumber(QuicPathId path_id,
467 QuicPacketNumber packet_number) { 467 QuicPacketNumber packet_number) {
468 // Setting the nonce below relies on QuicPathId and QuicPacketNumber being 468 // Setting the nonce below relies on QuicPathId and QuicPacketNumber being
469 // specific sizes. 469 // specific sizes.
470 static_assert(sizeof(path_id) == 1, "Size of QuicPathId changed."); 470 static_assert(sizeof(path_id) == 1, "Size of QuicPathId changed.");
471 static_assert(sizeof(packet_number) == 8, 471 static_assert(sizeof(packet_number) == 8,
472 "Size of QuicPacketNumber changed."); 472 "Size of QuicPacketNumber changed.");
473 // Use path_id and lower 7 bytes of packet_number as lower 8 bytes of nonce. 473 // Use path_id and lower 7 bytes of packet_number as lower 8 bytes of nonce.
474 uint64_t path_id_packet_number = 474 uint64_t path_id_packet_number =
475 (static_cast<uint64_t>(path_id) << 56) | packet_number; 475 (static_cast<uint64_t>(path_id) << 56) | packet_number;
476 DCHECK(path_id != kDefaultPathId || path_id_packet_number == packet_number); 476 DCHECK(path_id != kDefaultPathId || path_id_packet_number == packet_number);
477 return path_id_packet_number; 477 return path_id_packet_number;
478 } 478 }
479 479
480 char* QuicUtils::CopyBuffer(const SerializedPacket& packet) {
481 char* dst_buffer = new char[packet.encrypted_length];
482 memcpy(dst_buffer, packet.encrypted_buffer, packet.encrypted_length);
483 return dst_buffer;
484 }
485
480 } // namespace net 486 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_utils.h ('k') | net/quic/test_tools/quic_packet_creator_peer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698