Refactor TlsServerHandshaker to implement QuicCryptoServerStreamBase directly
Between QuicCryptoServerStreamBase, QuicCryptoServerStream, and
QuicCryptoServerStream::HandshakerInterface, there is one too many layers
of abstraction. Currently QuicCryptoServerStream basically only acts as an
intermediary between QuicCryptoServerStreamBase and the implementation of
its HandshakerInterface. Instead, its HandshakerInterfaces could implement
QuicCryptoServerStreamBase directly. This makes that change for the TLS
side. A future CL will collapse QuicCryptoServerStream and
QuicCryptoServerHandshaker into the same class.
gfe-relnote: refactor of TLS QUIC code, protected by multiple QUIC version flags
PiperOrigin-RevId: 290819354
Change-Id: Ia48d001bf0d1a7fb43863d22137ad0d0b897ad7b
diff --git a/quic/core/quic_crypto_server_stream.cc b/quic/core/quic_crypto_server_stream.cc
index abc681f..f4a514d 100644
--- a/quic/core/quic_crypto_server_stream.cc
+++ b/quic/core/quic_crypto_server_stream.cc
@@ -32,8 +32,20 @@
QuicCompressedCertsCache* compressed_certs_cache,
QuicSession* session,
QuicCryptoServerStream::Helper* helper) {
- return std::unique_ptr<QuicCryptoServerStream>(new QuicCryptoServerStream(
- crypto_config, compressed_certs_cache, session, helper));
+ switch (session->connection()->version().handshake_protocol) {
+ case PROTOCOL_QUIC_CRYPTO:
+ return std::unique_ptr<QuicCryptoServerStream>(new QuicCryptoServerStream(
+ crypto_config, compressed_certs_cache, session, helper));
+ case PROTOCOL_TLS1_3:
+ return std::unique_ptr<TlsServerHandshaker>(new TlsServerHandshaker(
+ session, crypto_config->ssl_ctx(), crypto_config->proof_source()));
+ case PROTOCOL_UNSUPPORTED:
+ break;
+ }
+ QUIC_BUG << "Unknown handshake protocol: "
+ << static_cast<int>(
+ session->connection()->version().handshake_protocol);
+ return nullptr;
}
QuicCryptoServerStream::QuicCryptoServerStream(
@@ -68,9 +80,8 @@
crypto_config_, this, compressed_certs_cache_, session, helper_);
break;
case PROTOCOL_TLS1_3:
- handshaker_ = std::make_unique<TlsServerHandshaker>(
- this, session, crypto_config_->ssl_ctx(),
- crypto_config_->proof_source());
+ QUIC_BUG
+ << "Attempting to create QuicCryptoServerStream for TLS version";
break;
case PROTOCOL_UNSUPPORTED:
QUIC_BUG << "Attempting to create QuicCryptoServerStream for unknown "
@@ -176,9 +187,7 @@
crypto_config_, this, compressed_certs_cache_, session(), helper_);
break;
case PROTOCOL_TLS1_3:
- handshaker_ = std::make_unique<TlsServerHandshaker>(
- this, session(), crypto_config_->ssl_ctx(),
- crypto_config_->proof_source());
+ QUIC_BUG << "Attempting to use QuicCryptoServerStream with TLS";
break;
case PROTOCOL_UNSUPPORTED:
QUIC_BUG << "Attempting to create QuicCryptoServerStream for unknown "