Change GetServerConfig() to return const ref.
Change QuicTestClient::GetServerConfig() and SimpleQuicClient::GetServerConfig()
to return const ref instead of value in order to eliminate a copy. This is only
used in one test file, where operator[] cannot be used any longer as it is not
constant.
Change QuicTestClient::GetServerConfig() to require that
QuicCryptoClientConfig::server_config_ to be set otherwise it crashes. This is
safe since this method is only called by tests internally, and there are no
callers in Chrome.
Also remove unused QuicCryptoServerConfig::tag_value_map.
PiperOrigin-RevId: 378863306
diff --git a/quic/core/crypto/quic_crypto_server_config.h b/quic/core/crypto/quic_crypto_server_config.h
index 4f3ad08..15ce0f2 100644
--- a/quic/core/crypto/quic_crypto_server_config.h
+++ b/quic/core/crypto/quic_crypto_server_config.h
@@ -507,9 +507,6 @@
// one-to-one, with the tags in |kexs| from the parent class.
std::vector<std::unique_ptr<AsynchronousKeyExchange>> key_exchanges;
- // tag_value_map contains the raw key/value pairs for the config.
- QuicTagValueMap tag_value_map;
-
// channel_id_enabled is true if the config in |serialized| specifies that
// ChannelIDs are supported.
bool channel_id_enabled;
diff --git a/quic/test_tools/quic_test_client.cc b/quic/test_tools/quic_test_client.cc
index bc1142d..598e14c 100644
--- a/quic/test_tools/quic_test_client.cc
+++ b/quic/test_tools/quic_test_client.cc
@@ -618,16 +618,12 @@
->cert_sct();
}
-QuicTagValueMap QuicTestClient::GetServerConfig() const {
+const QuicTagValueMap& QuicTestClient::GetServerConfig() const {
QuicCryptoClientConfig* config = client_->crypto_config();
- QuicCryptoClientConfig::CachedState* state =
+ const QuicCryptoClientConfig::CachedState* state =
config->LookupOrCreate(client_->server_id());
const CryptoHandshakeMessage* handshake_msg = state->GetServerConfig();
- if (handshake_msg != nullptr) {
- return handshake_msg->tag_value_map();
- } else {
- return QuicTagValueMap();
- }
+ return handshake_msg->tag_value_map();
}
bool QuicTestClient::connected() const {
diff --git a/quic/test_tools/quic_test_client.h b/quic/test_tools/quic_test_client.h
index e498e8e..fd42046 100644
--- a/quic/test_tools/quic_test_client.h
+++ b/quic/test_tools/quic_test_client.h
@@ -281,8 +281,8 @@
// or the empty std::string if no signed timestamp was presented.
const std::string& cert_sct() const;
- // Get the server config map.
- QuicTagValueMap GetServerConfig() const;
+ // Get the server config map. Server config must exist.
+ const QuicTagValueMap& GetServerConfig() const;
void set_auto_reconnect(bool reconnect) { auto_reconnect_ = reconnect; }