| 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/quic_framer.h" | 5 #include "net/quic/quic_framer.h" |
| 6 | 6 |
| 7 #include "base/containers/hash_tables.h" | 7 #include "base/containers/hash_tables.h" |
| 8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
| 9 #include "net/quic/crypto/crypto_framer.h" | 9 #include "net/quic/crypto/crypto_framer.h" |
| 10 #include "net/quic/crypto/crypto_handshake_message.h" | 10 #include "net/quic/crypto/crypto_handshake_message.h" |
| (...skipping 1591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1602 return alternative_decrypter_.get(); | 1602 return alternative_decrypter_.get(); |
| 1603 } | 1603 } |
| 1604 | 1604 |
| 1605 void QuicFramer::SetEncrypter(EncryptionLevel level, | 1605 void QuicFramer::SetEncrypter(EncryptionLevel level, |
| 1606 QuicEncrypter* encrypter) { | 1606 QuicEncrypter* encrypter) { |
| 1607 DCHECK_GE(level, 0); | 1607 DCHECK_GE(level, 0); |
| 1608 DCHECK_LT(level, NUM_ENCRYPTION_LEVELS); | 1608 DCHECK_LT(level, NUM_ENCRYPTION_LEVELS); |
| 1609 encrypter_[level].reset(encrypter); | 1609 encrypter_[level].reset(encrypter); |
| 1610 } | 1610 } |
| 1611 | 1611 |
| 1612 const QuicEncrypter* QuicFramer::encrypter(EncryptionLevel level) const { | |
| 1613 DCHECK_GE(level, 0); | |
| 1614 DCHECK_LT(level, NUM_ENCRYPTION_LEVELS); | |
| 1615 DCHECK(encrypter_[level].get() != nullptr); | |
| 1616 return encrypter_[level].get(); | |
| 1617 } | |
| 1618 | |
| 1619 QuicEncryptedPacket* QuicFramer::EncryptPacket( | 1612 QuicEncryptedPacket* QuicFramer::EncryptPacket( |
| 1620 EncryptionLevel level, | 1613 EncryptionLevel level, |
| 1621 QuicPacketSequenceNumber packet_sequence_number, | 1614 QuicPacketSequenceNumber packet_sequence_number, |
| 1622 const QuicPacket& packet) { | 1615 const QuicPacket& packet) { |
| 1623 DCHECK(encrypter_[level].get() != nullptr); | 1616 DCHECK(encrypter_[level].get() != nullptr); |
| 1624 | 1617 |
| 1625 // Allocate a large enough buffer for the header and the encrypted data. | 1618 // Allocate a large enough buffer for the header and the encrypted data. |
| 1626 const size_t encrypted_len = | 1619 const size_t encrypted_len = |
| 1627 encrypter_[level]->GetCiphertextSize(packet.Plaintext().length()); | 1620 encrypter_[level]->GetCiphertextSize(packet.Plaintext().length()); |
| 1628 StringPiece header_data = packet.BeforePlaintext(); | 1621 StringPiece header_data = packet.BeforePlaintext(); |
| (...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2214 | 2207 |
| 2215 bool QuicFramer::RaiseError(QuicErrorCode error) { | 2208 bool QuicFramer::RaiseError(QuicErrorCode error) { |
| 2216 DVLOG(1) << "Error detail: " << detailed_error_; | 2209 DVLOG(1) << "Error detail: " << detailed_error_; |
| 2217 set_error(error); | 2210 set_error(error); |
| 2218 visitor_->OnError(this); | 2211 visitor_->OnError(this); |
| 2219 reader_.reset(nullptr); | 2212 reader_.reset(nullptr); |
| 2220 return false; | 2213 return false; |
| 2221 } | 2214 } |
| 2222 | 2215 |
| 2223 } // namespace net | 2216 } // namespace net |
| OLD | NEW |