| OLD | NEW |
| 1 // Copyright (c) 2017 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2017 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 #ifndef NET_QUIC_QUARTC_QUARTC_SESSION_H_ | 5 #ifndef NET_QUIC_QUARTC_QUARTC_SESSION_H_ |
| 6 #define NET_QUIC_QUARTC_QUARTC_SESSION_H_ | 6 #define NET_QUIC_QUARTC_QUARTC_SESSION_H_ |
| 7 | 7 |
| 8 #include "net/quic/core/quic_crypto_client_stream.h" | 8 #include "net/quic/core/quic_crypto_client_stream.h" |
| 9 #include "net/quic/core/quic_crypto_server_stream.h" | 9 #include "net/quic/core/quic_crypto_server_stream.h" |
| 10 #include "net/quic/core/quic_crypto_stream.h" | 10 #include "net/quic/core/quic_crypto_stream.h" |
| 11 #include "net/quic/core/quic_error_codes.h" |
| 11 #include "net/quic/core/quic_session.h" | 12 #include "net/quic/core/quic_session.h" |
| 12 #include "net/quic/quartc/quartc_clock_interface.h" | 13 #include "net/quic/quartc/quartc_clock_interface.h" |
| 13 #include "net/quic/quartc/quartc_session_interface.h" | 14 #include "net/quic/quartc/quartc_session_interface.h" |
| 14 #include "net/quic/quartc/quartc_stream.h" | 15 #include "net/quic/quartc/quartc_stream.h" |
| 15 | 16 |
| 16 namespace net { | 17 namespace net { |
| 17 | 18 |
| 18 // A helper class is used by the QuicCryptoServerStream. | 19 // A helper class is used by the QuicCryptoServerStream. |
| 19 class QuartcCryptoServerStreamHelper : public QuicCryptoServerStream::Helper { | 20 class QuartcCryptoServerStreamHelper : public QuicCryptoServerStream::Helper { |
| 20 public: | 21 public: |
| 21 QuicConnectionId GenerateConnectionIdForReject( | 22 QuicConnectionId GenerateConnectionIdForReject( |
| 22 QuicConnectionId connection_id) const override; | 23 QuicConnectionId connection_id) const override; |
| 23 | 24 |
| 24 bool CanAcceptClientHello(const CryptoHandshakeMessage& message, | 25 bool CanAcceptClientHello(const CryptoHandshakeMessage& message, |
| 25 const QuicSocketAddress& self_address, | 26 const QuicSocketAddress& self_address, |
| 26 std::string* error_details) const override; | 27 std::string* error_details) const override; |
| 27 }; | 28 }; |
| 28 | 29 |
| 29 class QuartcSession : public QuicSession, | 30 class QUIC_EXPORT_PRIVATE QuartcSession |
| 30 public QuartcSessionInterface, | 31 : public QuicSession, |
| 31 public QuicCryptoClientStream::ProofHandler { | 32 public QuartcSessionInterface, |
| 33 public QuicCryptoClientStream::ProofHandler { |
| 32 public: | 34 public: |
| 33 QuartcSession(std::unique_ptr<QuicConnection> connection, | 35 QuartcSession(std::unique_ptr<QuicConnection> connection, |
| 34 const QuicConfig& config, | 36 const QuicConfig& config, |
| 35 const std::string& unique_remote_server_id, | 37 const std::string& unique_remote_server_id, |
| 36 Perspective perspective, | 38 Perspective perspective, |
| 37 QuicConnectionHelperInterface* helper, | 39 QuicConnectionHelperInterface* helper, |
| 38 QuicClock* clock); | 40 QuicClock* clock); |
| 39 ~QuartcSession() override; | 41 ~QuartcSession() override; |
| 40 | 42 |
| 41 // QuicSession overrides. | 43 // QuicSession overrides. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 60 bool ExportKeyingMaterial(const std::string& label, | 62 bool ExportKeyingMaterial(const std::string& label, |
| 61 const uint8_t* context, | 63 const uint8_t* context, |
| 62 size_t context_len, | 64 size_t context_len, |
| 63 bool used_context, | 65 bool used_context, |
| 64 uint8_t* result, | 66 uint8_t* result, |
| 65 size_t result_len) override; | 67 size_t result_len) override; |
| 66 | 68 |
| 67 QuartcStreamInterface* CreateOutgoingStream( | 69 QuartcStreamInterface* CreateOutgoingStream( |
| 68 const OutgoingStreamParameters& param) override; | 70 const OutgoingStreamParameters& param) override; |
| 69 | 71 |
| 72 void CancelStream(QuicStreamId stream_id) override; |
| 73 |
| 70 void SetDelegate(QuartcSessionInterface::Delegate* session_delegate) override; | 74 void SetDelegate(QuartcSessionInterface::Delegate* session_delegate) override; |
| 71 | 75 |
| 72 void OnTransportCanWrite() override; | 76 void OnTransportCanWrite() override; |
| 73 | 77 |
| 74 // Decrypts an incoming QUIC packet to a data stream. | 78 // Decrypts an incoming QUIC packet to a data stream. |
| 75 bool OnTransportReceived(const char* data, size_t data_len) override; | 79 bool OnTransportReceived(const char* data, size_t data_len) override; |
| 76 | 80 |
| 77 // ProofHandler overrides. | 81 // ProofHandler overrides. |
| 78 void OnProofValid(const QuicCryptoClientConfig::CachedState& cached) override; | 82 void OnProofValid(const QuicCryptoClientConfig::CachedState& cached) override; |
| 79 | 83 |
| 80 // Called by the client crypto handshake when proof verification details | 84 // Called by the client crypto handshake when proof verification details |
| 81 // become available, either because proof verification is complete, or when | 85 // become available, either because proof verification is complete, or when |
| 82 // cached details are used. | 86 // cached details are used. |
| 83 void OnProofVerifyDetailsAvailable( | 87 void OnProofVerifyDetailsAvailable( |
| 84 const ProofVerifyDetails& verify_details) override; | 88 const ProofVerifyDetails& verify_details) override; |
| 85 | 89 |
| 86 // Override the default crypto configuration. | 90 // Override the default crypto configuration. |
| 87 // The session will take the ownership of the configurations. | 91 // The session will take the ownership of the configurations. |
| 88 void SetClientCryptoConfig(QuicCryptoClientConfig* client_config); | 92 void SetClientCryptoConfig(QuicCryptoClientConfig* client_config); |
| 89 | 93 |
| 90 void SetServerCryptoConfig(QuicCryptoServerConfig* server_config); | 94 void SetServerCryptoConfig(QuicCryptoServerConfig* server_config); |
| 91 | 95 |
| 92 protected: | 96 protected: |
| 93 // QuicSession override. | 97 // QuicSession override. |
| 94 QuicStream* CreateIncomingDynamicStream(QuicStreamId id) override; | 98 QuicStream* CreateIncomingDynamicStream(QuicStreamId id) override; |
| 95 std::unique_ptr<QuicStream> CreateStream(QuicStreamId id) override; | 99 std::unique_ptr<QuicStream> CreateStream(QuicStreamId id) override; |
| 96 | 100 |
| 97 QuartcStream* CreateDataStream(QuicStreamId id, SpdyPriority priority); | 101 std::unique_ptr<QuartcStream> CreateDataStream(QuicStreamId id, |
| 102 SpdyPriority priority); |
| 103 // Activates a QuartcStream. The session takes ownership of the stream, but |
| 104 // returns an unowned pointer to the stream for convenience. |
| 105 QuartcStream* ActivateDataStream(std::unique_ptr<QuartcStream> stream); |
| 106 |
| 107 void ResetStream(QuicStreamId stream_id, QuicRstStreamErrorCode error); |
| 98 | 108 |
| 99 private: | 109 private: |
| 100 // For crypto handshake. | 110 // For crypto handshake. |
| 101 std::unique_ptr<QuicCryptoStream> crypto_stream_; | 111 std::unique_ptr<QuicCryptoStream> crypto_stream_; |
| 102 const std::string unique_remote_server_id_; | 112 const std::string unique_remote_server_id_; |
| 103 Perspective perspective_; | 113 Perspective perspective_; |
| 104 // Take the ownership of the QuicConnection. | 114 // Take the ownership of the QuicConnection. |
| 105 std::unique_ptr<QuicConnection> connection_; | 115 std::unique_ptr<QuicConnection> connection_; |
| 106 // Not owned by QuartcSession. From the QuartcFactory. | 116 // Not owned by QuartcSession. From the QuartcFactory. |
| 107 QuicConnectionHelperInterface* helper_; | 117 QuicConnectionHelperInterface* helper_; |
| 108 // For recording packet receipt time | 118 // For recording packet receipt time |
| 109 QuicClock* clock_; | 119 QuicClock* clock_; |
| 110 // Not owned by QuartcSession. | 120 // Not owned by QuartcSession. |
| 111 QuartcSessionInterface::Delegate* session_delegate_ = nullptr; | 121 QuartcSessionInterface::Delegate* session_delegate_ = nullptr; |
| 112 // Used by QUIC crypto server stream to track most recently compressed certs. | 122 // Used by QUIC crypto server stream to track most recently compressed certs. |
| 113 std::unique_ptr<QuicCompressedCertsCache> quic_compressed_certs_cache_; | 123 std::unique_ptr<QuicCompressedCertsCache> quic_compressed_certs_cache_; |
| 114 // This helper is needed when create QuicCryptoServerStream. | 124 // This helper is needed when create QuicCryptoServerStream. |
| 115 QuartcCryptoServerStreamHelper stream_helper_; | 125 QuartcCryptoServerStreamHelper stream_helper_; |
| 116 // Config for QUIC crypto client stream, used by the client. | 126 // Config for QUIC crypto client stream, used by the client. |
| 117 std::unique_ptr<QuicCryptoClientConfig> quic_crypto_client_config_; | 127 std::unique_ptr<QuicCryptoClientConfig> quic_crypto_client_config_; |
| 118 // Config for QUIC crypto server stream, used by the server. | 128 // Config for QUIC crypto server stream, used by the server. |
| 119 std::unique_ptr<QuicCryptoServerConfig> quic_crypto_server_config_; | 129 std::unique_ptr<QuicCryptoServerConfig> quic_crypto_server_config_; |
| 120 | 130 |
| 121 DISALLOW_COPY_AND_ASSIGN(QuartcSession); | 131 DISALLOW_COPY_AND_ASSIGN(QuartcSession); |
| 122 }; | 132 }; |
| 123 | 133 |
| 124 } // namespace net | 134 } // namespace net |
| 125 | 135 |
| 126 #endif // NET_QUIC_QUARTC_QUARTC_SESSION_H_ | 136 #endif // NET_QUIC_QUARTC_QUARTC_SESSION_H_ |
| OLD | NEW |