| OLD | NEW |
| 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_framer.h" | 5 #include "net/quic/core/quic_framer.h" |
| 6 | 6 |
| 7 #include <cstdint> | 7 #include <cstdint> |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/stl_util.h" | |
| 12 #include "net/quic/core/crypto/crypto_framer.h" | 11 #include "net/quic/core/crypto/crypto_framer.h" |
| 13 #include "net/quic/core/crypto/crypto_handshake_message.h" | 12 #include "net/quic/core/crypto/crypto_handshake_message.h" |
| 14 #include "net/quic/core/crypto/crypto_protocol.h" | 13 #include "net/quic/core/crypto/crypto_protocol.h" |
| 15 #include "net/quic/core/crypto/null_decrypter.h" | 14 #include "net/quic/core/crypto/null_decrypter.h" |
| 16 #include "net/quic/core/crypto/null_encrypter.h" | 15 #include "net/quic/core/crypto/null_encrypter.h" |
| 17 #include "net/quic/core/crypto/quic_decrypter.h" | 16 #include "net/quic/core/crypto/quic_decrypter.h" |
| 18 #include "net/quic/core/crypto/quic_encrypter.h" | 17 #include "net/quic/core/crypto/quic_encrypter.h" |
| 19 #include "net/quic/core/quic_data_reader.h" | 18 #include "net/quic/core/quic_data_reader.h" |
| 20 #include "net/quic/core/quic_data_writer.h" | 19 #include "net/quic/core/quic_data_writer.h" |
| 21 #include "net/quic/core/quic_flags.h" | 20 #include "net/quic/core/quic_flags.h" |
| 22 #include "net/quic/core/quic_socket_address_coder.h" | 21 #include "net/quic/core/quic_socket_address_coder.h" |
| 23 #include "net/quic/core/quic_utils.h" | 22 #include "net/quic/core/quic_utils.h" |
| 24 #include "net/quic/platform/api/quic_aligned.h" | 23 #include "net/quic/platform/api/quic_aligned.h" |
| 25 #include "net/quic/platform/api/quic_bug_tracker.h" | 24 #include "net/quic/platform/api/quic_bug_tracker.h" |
| 26 #include "net/quic/platform/api/quic_logging.h" | 25 #include "net/quic/platform/api/quic_logging.h" |
| 26 #include "net/quic/platform/api/quic_map_util.h" |
| 27 #include "net/quic/platform/api/quic_ptr_util.h" | 27 #include "net/quic/platform/api/quic_ptr_util.h" |
| 28 | 28 |
| 29 using base::ContainsKey; | |
| 30 using base::StringPiece; | 29 using base::StringPiece; |
| 31 using std::string; | 30 using std::string; |
| 32 #define PREDICT_FALSE(x) (x) | 31 #define PREDICT_FALSE(x) (x) |
| 33 | 32 |
| 34 namespace net { | 33 namespace net { |
| 35 | 34 |
| 36 namespace { | 35 namespace { |
| 37 | 36 |
| 38 #define ENDPOINT \ | 37 #define ENDPOINT \ |
| 39 (perspective_ == Perspective::IS_SERVER ? "Server: " : "Client: ") | 38 (perspective_ == Perspective::IS_SERVER ? "Server: " : "Client: ") |
| (...skipping 700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 740 uint64_t time = ClosestTo( | 739 uint64_t time = ClosestTo( |
| 741 last_timestamp_.ToMicroseconds(), epoch + time_delta_us, | 740 last_timestamp_.ToMicroseconds(), epoch + time_delta_us, |
| 742 ClosestTo(last_timestamp_.ToMicroseconds(), prev_epoch + time_delta_us, | 741 ClosestTo(last_timestamp_.ToMicroseconds(), prev_epoch + time_delta_us, |
| 743 next_epoch + time_delta_us)); | 742 next_epoch + time_delta_us)); |
| 744 | 743 |
| 745 return QuicTime::Delta::FromMicroseconds(time); | 744 return QuicTime::Delta::FromMicroseconds(time); |
| 746 } | 745 } |
| 747 | 746 |
| 748 bool QuicFramer::IsValidPath(QuicPathId path_id, | 747 bool QuicFramer::IsValidPath(QuicPathId path_id, |
| 749 QuicPacketNumber* base_packet_number) { | 748 QuicPacketNumber* base_packet_number) { |
| 750 if (ContainsKey(closed_paths_, path_id)) { | 749 if (QuicContainsKey(closed_paths_, path_id)) { |
| 751 // Path is closed. | 750 // Path is closed. |
| 752 return false; | 751 return false; |
| 753 } | 752 } |
| 754 | 753 |
| 755 if (path_id == last_path_id_) { | 754 if (path_id == last_path_id_) { |
| 756 *base_packet_number = largest_packet_number_; | 755 *base_packet_number = largest_packet_number_; |
| 757 return true; | 756 return true; |
| 758 } | 757 } |
| 759 | 758 |
| 760 if (ContainsKey(largest_packet_numbers_, path_id)) { | 759 if (QuicContainsKey(largest_packet_numbers_, path_id)) { |
| 761 *base_packet_number = largest_packet_numbers_[path_id]; | 760 *base_packet_number = largest_packet_numbers_[path_id]; |
| 762 } else { | 761 } else { |
| 763 *base_packet_number = 0; | 762 *base_packet_number = 0; |
| 764 } | 763 } |
| 765 | 764 |
| 766 return true; | 765 return true; |
| 767 } | 766 } |
| 768 | 767 |
| 769 void QuicFramer::SetLastPacketNumber(const QuicPacketHeader& header) { | 768 void QuicFramer::SetLastPacketNumber(const QuicPacketHeader& header) { |
| 770 if (header.public_header.multipath_flag && header.path_id != last_path_id_) { | 769 if (header.public_header.multipath_flag && header.path_id != last_path_id_) { |
| (...skipping 1439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2210 | 2209 |
| 2211 bool QuicFramer::RaiseError(QuicErrorCode error) { | 2210 bool QuicFramer::RaiseError(QuicErrorCode error) { |
| 2212 QUIC_DLOG(INFO) << ENDPOINT << "Error: " << QuicErrorCodeToString(error) | 2211 QUIC_DLOG(INFO) << ENDPOINT << "Error: " << QuicErrorCodeToString(error) |
| 2213 << " detail: " << detailed_error_; | 2212 << " detail: " << detailed_error_; |
| 2214 set_error(error); | 2213 set_error(error); |
| 2215 visitor_->OnError(this); | 2214 visitor_->OnError(this); |
| 2216 return false; | 2215 return false; |
| 2217 } | 2216 } |
| 2218 | 2217 |
| 2219 } // namespace net | 2218 } // namespace net |
| OLD | NEW |