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

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

Issue 2229703003: Introduce TTL in QuicReceivedPacket. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@129359661
Patch Set: git pull from upper stream Created 4 years, 4 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_protocol.h ('k') | net/tools/quic/quic_packet_reader.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_protocol.h" 5 #include "net/quic/core/quic_protocol.h"
6 6
7 #include "base/stl_util.h" 7 #include "base/stl_util.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "net/quic/core/quic_flags.h" 9 #include "net/quic/core/quic_flags.h"
10 #include "net/quic/core/quic_utils.h" 10 #include "net/quic/core/quic_utils.h"
(...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 QuicGoAwayFrame::QuicGoAwayFrame(QuicErrorCode error_code, 731 QuicGoAwayFrame::QuicGoAwayFrame(QuicErrorCode error_code,
732 QuicStreamId last_good_stream_id, 732 QuicStreamId last_good_stream_id,
733 const string& reason) 733 const string& reason)
734 : error_code(error_code), 734 : error_code(error_code),
735 last_good_stream_id(last_good_stream_id), 735 last_good_stream_id(last_good_stream_id),
736 reason_phrase(reason) {} 736 reason_phrase(reason) {}
737 737
738 QuicData::QuicData(const char* buffer, size_t length) 738 QuicData::QuicData(const char* buffer, size_t length)
739 : buffer_(buffer), length_(length), owns_buffer_(false) {} 739 : buffer_(buffer), length_(length), owns_buffer_(false) {}
740 740
741 QuicData::QuicData(char* buffer, size_t length, bool owns_buffer) 741 QuicData::QuicData(const char* buffer, size_t length, bool owns_buffer)
742 : buffer_(buffer), length_(length), owns_buffer_(owns_buffer) {} 742 : buffer_(buffer), length_(length), owns_buffer_(owns_buffer) {}
743 743
744 QuicData::~QuicData() { 744 QuicData::~QuicData() {
745 if (owns_buffer_) { 745 if (owns_buffer_) {
746 delete[] const_cast<char*>(buffer_); 746 delete[] const_cast<char*>(buffer_);
747 } 747 }
748 } 748 }
749 749
750 QuicWindowUpdateFrame::QuicWindowUpdateFrame(QuicStreamId stream_id, 750 QuicWindowUpdateFrame::QuicWindowUpdateFrame(QuicStreamId stream_id,
751 QuicStreamOffset byte_offset) 751 QuicStreamOffset byte_offset)
(...skipping 16 matching lines...) Expand all
768 buffer_(buffer), 768 buffer_(buffer),
769 connection_id_length_(connection_id_length), 769 connection_id_length_(connection_id_length),
770 includes_version_(includes_version), 770 includes_version_(includes_version),
771 includes_path_id_(includes_path_id), 771 includes_path_id_(includes_path_id),
772 includes_diversification_nonce_(includes_diversification_nonce), 772 includes_diversification_nonce_(includes_diversification_nonce),
773 packet_number_length_(packet_number_length) {} 773 packet_number_length_(packet_number_length) {}
774 774
775 QuicEncryptedPacket::QuicEncryptedPacket(const char* buffer, size_t length) 775 QuicEncryptedPacket::QuicEncryptedPacket(const char* buffer, size_t length)
776 : QuicData(buffer, length) {} 776 : QuicData(buffer, length) {}
777 777
778 QuicEncryptedPacket::QuicEncryptedPacket(char* buffer, 778 QuicEncryptedPacket::QuicEncryptedPacket(const char* buffer,
779 size_t length, 779 size_t length,
780 bool owns_buffer) 780 bool owns_buffer)
781 : QuicData(buffer, length, owns_buffer) {} 781 : QuicData(buffer, length, owns_buffer) {}
782 782
783 QuicEncryptedPacket* QuicEncryptedPacket::Clone() const { 783 QuicEncryptedPacket* QuicEncryptedPacket::Clone() const {
784 char* buffer = new char[this->length()]; 784 char* buffer = new char[this->length()];
785 memcpy(buffer, this->data(), this->length()); 785 memcpy(buffer, this->data(), this->length());
786 return new QuicEncryptedPacket(buffer, this->length(), true); 786 return new QuicEncryptedPacket(buffer, this->length(), true);
787 } 787 }
788 788
789 ostream& operator<<(ostream& os, const QuicEncryptedPacket& s) { 789 ostream& operator<<(ostream& os, const QuicEncryptedPacket& s) {
790 os << s.length() << "-byte data"; 790 os << s.length() << "-byte data";
791 return os; 791 return os;
792 } 792 }
793 793
794 QuicReceivedPacket::QuicReceivedPacket(const char* buffer, 794 QuicReceivedPacket::QuicReceivedPacket(const char* buffer,
795 size_t length, 795 size_t length,
796 QuicTime receipt_time) 796 QuicTime receipt_time)
797 : QuicEncryptedPacket(buffer, length), receipt_time_(receipt_time) {} 797 : QuicEncryptedPacket(buffer, length),
798 receipt_time_(receipt_time),
799 ttl_(0) {}
798 800
799 QuicReceivedPacket::QuicReceivedPacket(char* buffer, 801 QuicReceivedPacket::QuicReceivedPacket(const char* buffer,
800 size_t length, 802 size_t length,
801 QuicTime receipt_time, 803 QuicTime receipt_time,
802 bool owns_buffer) 804 bool owns_buffer)
803 : QuicEncryptedPacket(buffer, length, owns_buffer), 805 : QuicEncryptedPacket(buffer, length, owns_buffer),
804 receipt_time_(receipt_time) {} 806 receipt_time_(receipt_time),
807 ttl_(0) {}
808
809 QuicReceivedPacket::QuicReceivedPacket(const char* buffer,
810 size_t length,
811 QuicTime receipt_time,
812 bool owns_buffer,
813 int ttl,
814 bool ttl_valid)
815 : QuicEncryptedPacket(buffer, length, owns_buffer),
816 receipt_time_(receipt_time),
817 ttl_(ttl_valid ? ttl : -1) {}
805 818
806 QuicReceivedPacket* QuicReceivedPacket::Clone() const { 819 QuicReceivedPacket* QuicReceivedPacket::Clone() const {
807 char* buffer = new char[this->length()]; 820 char* buffer = new char[this->length()];
808 memcpy(buffer, this->data(), this->length()); 821 memcpy(buffer, this->data(), this->length());
809 return new QuicReceivedPacket(buffer, this->length(), receipt_time(), true); 822 return new QuicReceivedPacket(buffer, this->length(), receipt_time(), true,
823 ttl(), ttl() >= 0);
810 } 824 }
811 825
812 ostream& operator<<(ostream& os, const QuicReceivedPacket& s) { 826 ostream& operator<<(ostream& os, const QuicReceivedPacket& s) {
813 os << s.length() << "-byte data"; 827 os << s.length() << "-byte data";
814 return os; 828 return os;
815 } 829 }
816 830
817 StringPiece QuicPacket::AssociatedData(QuicVersion version) const { 831 StringPiece QuicPacket::AssociatedData(QuicVersion version) const {
818 return StringPiece( 832 return StringPiece(
819 data(), GetStartOfEncryptedData(version, connection_id_length_, 833 data(), GetStartOfEncryptedData(version, connection_id_length_,
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
916 is_unackable(false), 930 is_unackable(false),
917 has_crypto_handshake(has_crypto_handshake), 931 has_crypto_handshake(has_crypto_handshake),
918 num_padding_bytes(num_padding_bytes), 932 num_padding_bytes(num_padding_bytes),
919 retransmission(0) {} 933 retransmission(0) {}
920 934
921 TransmissionInfo::TransmissionInfo(const TransmissionInfo& other) = default; 935 TransmissionInfo::TransmissionInfo(const TransmissionInfo& other) = default;
922 936
923 TransmissionInfo::~TransmissionInfo() {} 937 TransmissionInfo::~TransmissionInfo() {}
924 938
925 } // namespace net 939 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/core/quic_protocol.h ('k') | net/tools/quic/quic_packet_reader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698