In QuicCryptoClientConfig: - Change session_cache_ from std::unique_ptr to std::shared_ptr. This allows multiple QuicCryptoClientConfig(s) to use the same Session Cache. - Add set_session_cache(). So a caller can change Session Cache after construction. - Remove mutable_session_cache(). It is the same as session_cache(). PiperOrigin-RevId: 546066418
diff --git a/quiche/quic/core/crypto/quic_crypto_client_config.cc b/quiche/quic/core/crypto/quic_crypto_client_config.cc index c9137de..3458c69 100644 --- a/quiche/quic/core/crypto/quic_crypto_client_config.cc +++ b/quiche/quic/core/crypto/quic_crypto_client_config.cc
@@ -62,7 +62,7 @@ QuicCryptoClientConfig::QuicCryptoClientConfig( std::unique_ptr<ProofVerifier> proof_verifier, - std::unique_ptr<SessionCache> session_cache) + std::shared_ptr<SessionCache> session_cache) : proof_verifier_(std::move(proof_verifier)), session_cache_(std::move(session_cache)), ssl_ctx_(TlsClientConnection::CreateSslCtx( @@ -775,6 +775,11 @@ return session_cache_.get(); } +void QuicCryptoClientConfig::set_session_cache( + std::shared_ptr<SessionCache> session_cache) { + session_cache_ = std::move(session_cache); +} + ClientProofSource* QuicCryptoClientConfig::proof_source() const { return proof_source_.get(); }
diff --git a/quiche/quic/core/crypto/quic_crypto_client_config.h b/quiche/quic/core/crypto/quic_crypto_client_config.h index 693d0d4..02c3643 100644 --- a/quiche/quic/core/crypto/quic_crypto_client_config.h +++ b/quiche/quic/core/crypto/quic_crypto_client_config.h
@@ -239,7 +239,7 @@ explicit QuicCryptoClientConfig( std::unique_ptr<ProofVerifier> proof_verifier); QuicCryptoClientConfig(std::unique_ptr<ProofVerifier> proof_verifier, - std::unique_ptr<SessionCache> session_cache); + std::shared_ptr<SessionCache> session_cache); QuicCryptoClientConfig(const QuicCryptoClientConfig&) = delete; QuicCryptoClientConfig& operator=(const QuicCryptoClientConfig&) = delete; ~QuicCryptoClientConfig(); @@ -337,6 +337,7 @@ ProofVerifier* proof_verifier() const; SessionCache* session_cache() const; + void set_session_cache(std::shared_ptr<SessionCache> session_cache); ClientProofSource* proof_source() const; void set_proof_source(std::unique_ptr<ClientProofSource> proof_source); SSL_CTX* ssl_ctx() const; @@ -402,8 +403,6 @@ bool pad_full_hello() const { return pad_full_hello_; } void set_pad_full_hello(bool new_value) { pad_full_hello_ = new_value; } - SessionCache* mutable_session_cache() { return session_cache_.get(); } - private: // Sets the members to reasonable, default values. void SetDefaults(); @@ -440,7 +439,7 @@ std::vector<std::string> canonical_suffixes_; std::unique_ptr<ProofVerifier> proof_verifier_; - std::unique_ptr<SessionCache> session_cache_; + std::shared_ptr<SessionCache> session_cache_; std::unique_ptr<ClientProofSource> proof_source_; bssl::UniquePtr<SSL_CTX> ssl_ctx_;
diff --git a/quiche/quic/core/http/end_to_end_test.cc b/quiche/quic/core/http/end_to_end_test.cc index f9a89d7..f8028ea 100644 --- a/quiche/quic/core/http/end_to_end_test.cc +++ b/quiche/quic/core/http/end_to_end_test.cc
@@ -1874,8 +1874,8 @@ client_->Disconnect(); - QuicClientSessionCache* session_cache = static_cast<QuicClientSessionCache*>( - client_crypto_config->mutable_session_cache()); + QuicClientSessionCache* session_cache = + static_cast<QuicClientSessionCache*>(client_crypto_config->session_cache()); ASSERT_TRUE( !QuicClientSessionCachePeer::GetToken(session_cache, server_id).empty());