OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef NET_QUIC_QUARTC_QUARTC_SESSION_H_ |
| 6 #define NET_QUIC_QUARTC_QUARTC_SESSION_H_ |
| 7 |
| 8 #include "net/quic/core/quic_crypto_client_stream.h" |
| 9 #include "net/quic/core/quic_crypto_server_stream.h" |
| 10 #include "net/quic/core/quic_crypto_stream.h" |
| 11 #include "net/quic/core/quic_session.h" |
| 12 #include "net/quic/quartc/quartc_session_interface.h" |
| 13 #include "net/quic/quartc/quartc_stream.h" |
| 14 |
| 15 namespace net { |
| 16 |
| 17 // A helper class is used by the QuicCryptoServerStream. |
| 18 class QuartcCryptoServerStreamHelper : public QuicCryptoServerStream::Helper { |
| 19 public: |
| 20 QuicConnectionId GenerateConnectionIdForReject( |
| 21 QuicConnectionId connection_id) const override; |
| 22 |
| 23 bool CanAcceptClientHello(const CryptoHandshakeMessage& message, |
| 24 const IPEndPoint& self_address, |
| 25 std::string* error_details) const override; |
| 26 }; |
| 27 |
| 28 class NET_EXPORT_PRIVATE QuartcSession |
| 29 : public QuicSession, |
| 30 public QuartcSessionInterface, |
| 31 public QuicCryptoClientStream::ProofHandler { |
| 32 public: |
| 33 QuartcSession(std::unique_ptr<QuicConnection> connection, |
| 34 const QuicConfig& config, |
| 35 const std::string& unique_remote_server_id, |
| 36 Perspective perspective, |
| 37 QuicConnectionHelperInterface* helper); |
| 38 ~QuartcSession() override; |
| 39 |
| 40 // QuicSession overrides. |
| 41 QuicCryptoStream* GetCryptoStream() override; |
| 42 |
| 43 QuartcStream* CreateOutgoingDynamicStream(SpdyPriority priority) override; |
| 44 |
| 45 void OnCryptoHandshakeEvent(CryptoHandshakeEvent event) override; |
| 46 |
| 47 void CloseStream(QuicStreamId stream_id) override; |
| 48 |
| 49 // QuicConnectionVisitorInterface overrides. |
| 50 void OnConnectionClosed(QuicErrorCode error, |
| 51 const std::string& error_details, |
| 52 ConnectionCloseSource source) override; |
| 53 |
| 54 // QuartcSessionInterface overrides |
| 55 void StartCryptoHandshake() override; |
| 56 |
| 57 bool ExportKeyingMaterial(const std::string& label, |
| 58 const uint8_t* context, |
| 59 size_t context_len, |
| 60 bool used_context, |
| 61 uint8_t* result, |
| 62 size_t result_len) override; |
| 63 |
| 64 QuartcStreamInterface* CreateOutgoingStream( |
| 65 const OutgoingStreamParameters& param) override; |
| 66 |
| 67 void SetDelegate(QuartcSessionInterface::Delegate* session_delegate) override; |
| 68 |
| 69 void OnTransportCanWrite() override; |
| 70 |
| 71 // Decrypts an incoming QUIC packet to a data stream. |
| 72 bool OnTransportReceived(const char* data, size_t data_len) override; |
| 73 |
| 74 // ProofHandler overrides. |
| 75 void OnProofValid(const QuicCryptoClientConfig::CachedState& cached) override; |
| 76 |
| 77 // Called by the client crypto handshake when proof verification details |
| 78 // become available, either because proof verification is complete, or when |
| 79 // cached details are used. |
| 80 void OnProofVerifyDetailsAvailable( |
| 81 const ProofVerifyDetails& verify_details) override; |
| 82 |
| 83 // Override the default crypto configuration. |
| 84 // The session will take the ownership of the configurations. |
| 85 void SetClientCryptoConfig(QuicCryptoClientConfig* client_config); |
| 86 |
| 87 void SetServerCryptoConfig(QuicCryptoServerConfig* server_config); |
| 88 |
| 89 protected: |
| 90 // QuicSession override. |
| 91 ReliableQuicStream* CreateIncomingDynamicStream(QuicStreamId id) override; |
| 92 |
| 93 QuartcStream* CreateDataStream(QuicStreamId id, SpdyPriority priority); |
| 94 |
| 95 private: |
| 96 // For crypto handshake. |
| 97 std::unique_ptr<QuicCryptoStream> crypto_stream_; |
| 98 // For recording packet receipt time |
| 99 QuicClock clock_; |
| 100 const std::string unique_remote_server_id_; |
| 101 Perspective perspective_; |
| 102 // Take the ownership of the QuicConnection. |
| 103 std::unique_ptr<QuicConnection> connection_; |
| 104 // Not owned by QuartcSession. From the QuartcFactory. |
| 105 QuicConnectionHelperInterface* helper_; |
| 106 // Not owned by QuartcSession. |
| 107 QuartcSessionInterface::Delegate* session_delegate_ = nullptr; |
| 108 // Used by QUIC crypto server stream to track most recently compressed certs. |
| 109 std::unique_ptr<QuicCompressedCertsCache> quic_compressed_certs_cache_; |
| 110 // This helper is needed when create QuicCryptoServerStream. |
| 111 QuartcCryptoServerStreamHelper stream_helper_; |
| 112 // Config for QUIC crypto client stream, used by the client. |
| 113 std::unique_ptr<QuicCryptoClientConfig> quic_crypto_client_config_; |
| 114 // Config for QUIC crypto server stream, used by the server. |
| 115 std::unique_ptr<QuicCryptoServerConfig> quic_crypto_server_config_; |
| 116 |
| 117 DISALLOW_COPY_AND_ASSIGN(QuartcSession); |
| 118 }; |
| 119 |
| 120 } // namespace net |
| 121 |
| 122 #endif // NET_QUIC_QUARTC_QUARTC_SESSION_H_ |
OLD | NEW |