Remove one layer of abstraction in QuicCryptoServerStream classes

The former QuicCryptoServerStream::HandshakerDelegate interface matches the
interface of QuicCryptoServerStreamBase. Classes that formerly implemented
the HandshakerDelegate now directly implement QuicCryptoServerStreamBase
and the QuicCryptoServerStream class is removed.

Prior to this change, QuicCryptoServerStream extends QuicCryptoServerStreamBase,
but the whole implementation of QuicCryptoServerStream is to call the
corresponding methods on its HandshakerInterface. The only implementation of
QuicCryptoServerStream::HandshakerInterface is QuicCryptoServerHandshaker. That
class now directly implements QuicCryptoServerStreamBase and bypasses
QuicCryptoServerStream. A similar setup exists with GfeQuicCryptoServerStream
extending QuicCryptoServerStream, but delegating its entire implementation to
GfeQuicCryptoServerHandshaker. Now GfeQuicCryptoServerStream is removed, and
GfeQuicCryptoServerHandshaker implements GfeCryptoServerStream (which used to
be implemented by GfeQuicCryptoServerStream).

The only place (excluding test code) where a GfeQuicCryptoServerStream is
created is in CreateGfeCryptoServerStream, which now creates a
GfeQuicCryptoServerHandshaker directly. Likewise, the only place a
QuicCryptoServerStream is created (apart from the GfeQuicCryptoServerStream
subclass, which is taken care of by the above, and excluding test code) is in
CreateCryptoServerStream, which now creates a QuicCryptoServerHandshaker
instead of a QuicCryptoServerStream.

gfe-relnote: rename classes and remove dead code. no behavior change, not flag protected
PiperOrigin-RevId: 296542342
Change-Id: I516035e2f574554dd5a32ba3ac413c2d16d46c8d
diff --git a/quic/core/http/quic_server_session_base_test.cc b/quic/core/http/quic_server_session_base_test.cc
index 3e9437f..b4072c5 100644
--- a/quic/core/http/quic_server_session_base_test.cc
+++ b/quic/core/http/quic_server_session_base_test.cc
@@ -13,6 +13,7 @@
 #include "net/third_party/quiche/src/quic/core/crypto/quic_random.h"
 #include "net/third_party/quiche/src/quic/core/proto/cached_network_parameters_proto.h"
 #include "net/third_party/quiche/src/quic/core/quic_connection.h"
+#include "net/third_party/quiche/src/quic/core/quic_crypto_server_handshaker.h"
 #include "net/third_party/quiche/src/quic/core/quic_crypto_server_stream.h"
 #include "net/third_party/quiche/src/quic/core/quic_utils.h"
 #include "net/third_party/quiche/src/quic/core/tls_server_handshaker.h"
@@ -456,21 +457,22 @@
                   "ShouldCreateIncomingStream called when disconnected");
 }
 
-class MockQuicCryptoServerStream : public QuicCryptoServerStream {
+class MockQuicCryptoServerHandshaker : public QuicCryptoServerHandshaker {
  public:
-  explicit MockQuicCryptoServerStream(
+  explicit MockQuicCryptoServerHandshaker(
       const QuicCryptoServerConfig* crypto_config,
       QuicCompressedCertsCache* compressed_certs_cache,
       QuicServerSessionBase* session,
       QuicCryptoServerStreamBase::Helper* helper)
-      : QuicCryptoServerStream(crypto_config,
-                               compressed_certs_cache,
-                               session,
-                               helper) {}
-  MockQuicCryptoServerStream(const MockQuicCryptoServerStream&) = delete;
-  MockQuicCryptoServerStream& operator=(const MockQuicCryptoServerStream&) =
+      : QuicCryptoServerHandshaker(crypto_config,
+                                   compressed_certs_cache,
+                                   session,
+                                   helper) {}
+  MockQuicCryptoServerHandshaker(const MockQuicCryptoServerHandshaker&) =
       delete;
-  ~MockQuicCryptoServerStream() override {}
+  MockQuicCryptoServerHandshaker& operator=(
+      const MockQuicCryptoServerHandshaker&) = delete;
+  ~MockQuicCryptoServerHandshaker() override {}
 
   MOCK_METHOD1(SendServerConfigUpdate,
                void(const CachedNetworkParameters* cached_network_parameters));
@@ -516,11 +518,11 @@
         /*is_static=*/true);
   }
   QuicServerSessionBasePeer::SetCryptoStream(session_.get(), nullptr);
-  MockQuicCryptoServerStream* quic_crypto_stream = nullptr;
+  MockQuicCryptoServerHandshaker* quic_crypto_stream = nullptr;
   MockTlsServerHandshaker* tls_server_stream = nullptr;
   if (session_->connection()->version().handshake_protocol ==
       PROTOCOL_QUIC_CRYPTO) {
-    quic_crypto_stream = new MockQuicCryptoServerStream(
+    quic_crypto_stream = new MockQuicCryptoServerHandshaker(
         &crypto_config_, &compressed_certs_cache_, session_.get(),
         &stream_helper_);
     QuicServerSessionBasePeer::SetCryptoStream(session_.get(),
@@ -651,8 +653,9 @@
   connection_->AdvanceTime(
       QuicTime::Delta::FromSeconds(kNumSecondsPerHour + 1));
 
-  QuicCryptoServerStream* crypto_stream = static_cast<QuicCryptoServerStream*>(
-      QuicSessionPeer::GetMutableCryptoStream(session_.get()));
+  QuicCryptoServerStreamBase* crypto_stream =
+      static_cast<QuicCryptoServerStreamBase*>(
+          QuicSessionPeer::GetMutableCryptoStream(session_.get()));
 
   // No effect if no CachedNetworkParameters provided.
   EXPECT_CALL(*connection_, ResumeConnectionState(_, _)).Times(0);
diff --git a/quic/core/quic_crypto_server_handshaker.cc b/quic/core/quic_crypto_server_handshaker.cc
index a4994a0..ba25c21 100644
--- a/quic/core/quic_crypto_server_handshaker.cc
+++ b/quic/core/quic_crypto_server_handshaker.cc
@@ -48,12 +48,11 @@
 
 QuicCryptoServerHandshaker::QuicCryptoServerHandshaker(
     const QuicCryptoServerConfig* crypto_config,
-    QuicCryptoServerStream* stream,
     QuicCompressedCertsCache* compressed_certs_cache,
     QuicSession* session,
     QuicCryptoServerStreamBase::Helper* helper)
-    : QuicCryptoHandshaker(stream, session),
-      stream_(stream),
+    : QuicCryptoServerStreamBase(session),
+      QuicCryptoHandshaker(this, session),
       session_(session),
       delegate_(session),
       crypto_config_(crypto_config),
@@ -101,14 +100,14 @@
 
   // Do not process handshake messages after the handshake is confirmed.
   if (one_rtt_keys_available_) {
-    stream_->OnUnrecoverableError(QUIC_CRYPTO_MESSAGE_AFTER_HANDSHAKE_COMPLETE,
-                                  "Unexpected handshake message from client");
+    OnUnrecoverableError(QUIC_CRYPTO_MESSAGE_AFTER_HANDSHAKE_COMPLETE,
+                         "Unexpected handshake message from client");
     return;
   }
 
   if (message.tag() != kCHLO) {
-    stream_->OnUnrecoverableError(QUIC_INVALID_CRYPTO_MESSAGE_TYPE,
-                                  "Handshake packet not CHLO");
+    OnUnrecoverableError(QUIC_INVALID_CRYPTO_MESSAGE_TYPE,
+                         "Handshake packet not CHLO");
     return;
   }
 
@@ -117,9 +116,8 @@
     // Already processing some other handshake message.  The protocol
     // does not allow for clients to send multiple handshake messages
     // before the server has a chance to respond.
-    stream_->OnUnrecoverableError(
-        QUIC_CRYPTO_MESSAGE_WHILE_VALIDATING_CLIENT_HELLO,
-        "Unexpected handshake message while processing CHLO");
+    OnUnrecoverableError(QUIC_CRYPTO_MESSAGE_WHILE_VALIDATING_CLIENT_HELLO,
+                         "Unexpected handshake message while processing CHLO");
     return;
   }
 
@@ -166,7 +164,7 @@
 
   const CryptoHandshakeMessage& message = result.client_hello;
   if (error != QUIC_NO_ERROR) {
-    stream_->OnUnrecoverableError(error, error_details);
+    OnUnrecoverableError(error, error_details);
     return;
   }
 
@@ -186,7 +184,7 @@
   const QuicErrorCode process_error =
       config->ProcessPeerHello(message, CLIENT, &process_error_details);
   if (process_error != QUIC_NO_ERROR) {
-    stream_->OnUnrecoverableError(process_error, process_error_details);
+    OnUnrecoverableError(process_error, process_error_details);
     return;
   }
 
@@ -286,8 +284,8 @@
                 << message.DebugString();
   if (!QuicVersionUsesCryptoFrames(transport_version())) {
     const QuicData& data = message.GetSerialized();
-    stream_->WriteOrBufferData(
-        quiche::QuicheStringPiece(data.data(), data.length()), false, nullptr);
+    WriteOrBufferData(quiche::QuicheStringPiece(data.data(), data.length()),
+                      false, nullptr);
   } else {
     SendHandshakeMessage(message);
   }
@@ -330,6 +328,10 @@
   }
 }
 
+void QuicCryptoServerHandshaker::OnHandshakeDoneReceived() {
+  DCHECK(false);
+}
+
 bool QuicCryptoServerHandshaker::ShouldSendExpectCTHeader() const {
   return signed_config_->proof.send_expect_ct_header;
 }
diff --git a/quic/core/quic_crypto_server_handshaker.h b/quic/core/quic_crypto_server_handshaker.h
index 257ee16..6c4b710 100644
--- a/quic/core/quic_crypto_server_handshaker.h
+++ b/quic/core/quic_crypto_server_handshaker.h
@@ -20,18 +20,11 @@
 class QuicCryptoServerStreamPeer;
 }  // namespace test
 
+// TODO(nharper): Rename this class to QuicCryptoServerStream.
 class QUIC_EXPORT_PRIVATE QuicCryptoServerHandshaker
-    : public QuicCryptoServerStream::HandshakerInterface,
+    : public QuicCryptoServerStreamBase,
       public QuicCryptoHandshaker {
  public:
-  // |crypto_config| must outlive the stream.
-  // |session| must outlive the stream.
-  // |helper| must outlive the stream.
-  QuicCryptoServerHandshaker(const QuicCryptoServerConfig* crypto_config,
-                             QuicCryptoServerStream* stream,
-                             QuicCompressedCertsCache* compressed_certs_cache,
-                             QuicSession* session,
-                             QuicCryptoServerStreamBase::Helper* helper);
   QuicCryptoServerHandshaker(const QuicCryptoServerHandshaker&) = delete;
   QuicCryptoServerHandshaker& operator=(const QuicCryptoServerHandshaker&) =
       delete;
@@ -51,6 +44,8 @@
   void SetPreviousCachedNetworkParams(
       CachedNetworkParameters cached_network_params) override;
   void OnPacketDecrypted(EncryptionLevel level) override;
+  void OnOneRttPacketAcknowledged() override {}
+  void OnHandshakeDoneReceived() override;
   bool ShouldSendExpectCTHeader() const override;
 
   // From QuicCryptoStream
@@ -66,6 +61,20 @@
   void OnHandshakeMessage(const CryptoHandshakeMessage& message) override;
 
  protected:
+  QUIC_EXPORT_PRIVATE friend std::unique_ptr<QuicCryptoServerStreamBase>
+  CreateCryptoServerStream(const QuicCryptoServerConfig* crypto_config,
+                           QuicCompressedCertsCache* compressed_certs_cache,
+                           QuicSession* session,
+                           QuicCryptoServerStreamBase::Helper* helper);
+
+  // |crypto_config| must outlive the stream.
+  // |session| must outlive the stream.
+  // |helper| must outlive the stream.
+  QuicCryptoServerHandshaker(const QuicCryptoServerConfig* crypto_config,
+                             QuicCompressedCertsCache* compressed_certs_cache,
+                             QuicSession* session,
+                             QuicCryptoServerStreamBase::Helper* helper);
+
   virtual void ProcessClientHello(
       QuicReferenceCountedPointer<ValidateClientHelloResultCallback::Result>
           result,
@@ -161,8 +170,6 @@
     return session_->transport_version();
   }
 
-  QuicCryptoServerStream* stream_;
-
   QuicSession* session_;
   HandshakerDelegateInterface* delegate_;
 
diff --git a/quic/core/quic_crypto_server_stream.cc b/quic/core/quic_crypto_server_stream.cc
index dbbb541..a4ee9d1 100644
--- a/quic/core/quic_crypto_server_stream.cc
+++ b/quic/core/quic_crypto_server_stream.cc
@@ -34,8 +34,9 @@
     QuicCryptoServerStreamBase::Helper* 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));
+      return std::unique_ptr<QuicCryptoServerHandshaker>(
+          new QuicCryptoServerHandshaker(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()));
@@ -48,156 +49,4 @@
   return nullptr;
 }
 
-QuicCryptoServerStream::QuicCryptoServerStream(
-    const QuicCryptoServerConfig* crypto_config,
-    QuicCompressedCertsCache* compressed_certs_cache,
-    QuicSession* session,
-    QuicCryptoServerStreamBase::Helper* helper)
-    : QuicCryptoServerStream(crypto_config,
-                             compressed_certs_cache,
-                             session,
-                             helper,
-                             /*handshaker*/ nullptr) {}
-
-QuicCryptoServerStream::QuicCryptoServerStream(
-    const QuicCryptoServerConfig* crypto_config,
-    QuicCompressedCertsCache* compressed_certs_cache,
-    QuicSession* session,
-    QuicCryptoServerStreamBase::Helper* helper,
-    std::unique_ptr<HandshakerInterface> handshaker)
-    : QuicCryptoServerStreamBase(session),
-      handshaker_(std::move(handshaker)),
-      crypto_config_(crypto_config),
-      compressed_certs_cache_(compressed_certs_cache),
-      helper_(helper) {
-  DCHECK_EQ(Perspective::IS_SERVER, session->connection()->perspective());
-  if (!handshaker_) {
-    switch (session->connection()->version().handshake_protocol) {
-      case PROTOCOL_QUIC_CRYPTO:
-        handshaker_ = std::make_unique<QuicCryptoServerHandshaker>(
-            crypto_config_, this, compressed_certs_cache_, session, helper_);
-        break;
-      case PROTOCOL_TLS1_3:
-        QUIC_BUG
-            << "Attempting to create QuicCryptoServerStream for TLS version";
-        break;
-      case PROTOCOL_UNSUPPORTED:
-        QUIC_BUG << "Attempting to create QuicCryptoServerStream for unknown "
-                    "handshake protocol";
-    }
-  }
-}
-
-QuicCryptoServerStream::~QuicCryptoServerStream() {}
-
-void QuicCryptoServerStream::CancelOutstandingCallbacks() {
-  if (handshaker_) {
-    handshaker_->CancelOutstandingCallbacks();
-  }
-}
-
-bool QuicCryptoServerStream::GetBase64SHA256ClientChannelID(
-    std::string* output) const {
-  return handshaker_->GetBase64SHA256ClientChannelID(output);
-}
-
-void QuicCryptoServerStream::SendServerConfigUpdate(
-    const CachedNetworkParameters* cached_network_params) {
-  handshaker_->SendServerConfigUpdate(cached_network_params);
-}
-
-uint8_t QuicCryptoServerStream::NumHandshakeMessages() const {
-  return handshaker_->NumHandshakeMessages();
-}
-
-uint8_t QuicCryptoServerStream::NumHandshakeMessagesWithServerNonces() const {
-  return handshaker_->NumHandshakeMessagesWithServerNonces();
-}
-
-int QuicCryptoServerStream::NumServerConfigUpdateMessagesSent() const {
-  return handshaker_->NumServerConfigUpdateMessagesSent();
-}
-
-const CachedNetworkParameters*
-QuicCryptoServerStream::PreviousCachedNetworkParams() const {
-  return handshaker_->PreviousCachedNetworkParams();
-}
-
-bool QuicCryptoServerStream::ZeroRttAttempted() const {
-  return handshaker_->ZeroRttAttempted();
-}
-
-void QuicCryptoServerStream::SetPreviousCachedNetworkParams(
-    CachedNetworkParameters cached_network_params) {
-  handshaker_->SetPreviousCachedNetworkParams(cached_network_params);
-}
-
-bool QuicCryptoServerStream::ShouldSendExpectCTHeader() const {
-  return handshaker_->ShouldSendExpectCTHeader();
-}
-
-bool QuicCryptoServerStream::encryption_established() const {
-  if (!handshaker_) {
-    return false;
-  }
-  return handshaker_->encryption_established();
-}
-
-bool QuicCryptoServerStream::one_rtt_keys_available() const {
-  if (!handshaker_) {
-    return false;
-  }
-  return handshaker_->one_rtt_keys_available();
-}
-
-const QuicCryptoNegotiatedParameters&
-QuicCryptoServerStream::crypto_negotiated_params() const {
-  return handshaker_->crypto_negotiated_params();
-}
-
-CryptoMessageParser* QuicCryptoServerStream::crypto_message_parser() {
-  return handshaker_->crypto_message_parser();
-}
-
-void QuicCryptoServerStream::OnPacketDecrypted(EncryptionLevel level) {
-  handshaker_->OnPacketDecrypted(level);
-}
-
-void QuicCryptoServerStream::OnHandshakeDoneReceived() {
-  DCHECK(false);
-}
-
-HandshakeState QuicCryptoServerStream::GetHandshakeState() const {
-  return handshaker_->GetHandshakeState();
-}
-
-size_t QuicCryptoServerStream::BufferSizeLimitForLevel(
-    EncryptionLevel level) const {
-  return handshaker_->BufferSizeLimitForLevel(level);
-}
-
-void QuicCryptoServerStream::set_handshaker(
-    std::unique_ptr<QuicCryptoServerStream::HandshakerInterface> handshaker) {
-  CHECK(!handshaker_);
-  handshaker_ = std::move(handshaker);
-}
-
-QuicCryptoServerStream::HandshakerInterface*
-QuicCryptoServerStream::handshaker() const {
-  return handshaker_.get();
-}
-
-const QuicCryptoServerConfig* QuicCryptoServerStream::crypto_config() const {
-  return crypto_config_;
-}
-
-QuicCompressedCertsCache* QuicCryptoServerStream::compressed_certs_cache()
-    const {
-  return compressed_certs_cache_;
-}
-
-QuicCryptoServerStreamBase::Helper* QuicCryptoServerStream::helper() const {
-  return helper_;
-}
-
 }  // namespace quic
diff --git a/quic/core/quic_crypto_server_stream.h b/quic/core/quic_crypto_server_stream.h
index f96c45a..ad2689e 100644
--- a/quic/core/quic_crypto_server_stream.h
+++ b/quic/core/quic_crypto_server_stream.h
@@ -79,145 +79,6 @@
   virtual bool ShouldSendExpectCTHeader() const = 0;
 };
 
-class QUIC_EXPORT_PRIVATE QuicCryptoServerStream
-    : public QuicCryptoServerStreamBase {
- public:
-  // QuicCryptoServerStream creates a HandshakerInterface at construction time
-  // based on the QuicTransportVersion of the connection. Different
-  // HandshakerInterfaces provide implementations of different crypto handshake
-  // protocols. Currently QUIC crypto is the only protocol implemented; a future
-  // HandshakerInterface will use TLS as the handshake protocol.
-  // QuicCryptoServerStream delegates all of its public methods to its
-  // HandshakerInterface.
-  //
-  // This setup of the crypto stream delegating its implementation to the
-  // handshaker results in the handshaker reading and writing bytes on the
-  // crypto stream, instead of the handshake rpassing the stream bytes to send.
-  class QUIC_EXPORT_PRIVATE HandshakerInterface {
-   public:
-    virtual ~HandshakerInterface() {}
-
-    // Cancel any outstanding callbacks, such as asynchronous validation of
-    // client hello.
-    virtual void CancelOutstandingCallbacks() = 0;
-
-    // GetBase64SHA256ClientChannelID sets |*output| to the base64 encoded,
-    // SHA-256 hash of the client's ChannelID key and returns true, if the
-    // client presented a ChannelID. Otherwise it returns false.
-    virtual bool GetBase64SHA256ClientChannelID(std::string* output) const = 0;
-
-    // Sends the latest server config and source-address token to the client.
-    virtual void SendServerConfigUpdate(
-        const CachedNetworkParameters* cached_network_params) = 0;
-
-    // These are all accessors and setters to their respective counters.
-    virtual uint8_t NumHandshakeMessages() const = 0;
-    virtual uint8_t NumHandshakeMessagesWithServerNonces() const = 0;
-    virtual int NumServerConfigUpdateMessagesSent() const = 0;
-    virtual const CachedNetworkParameters* PreviousCachedNetworkParams()
-        const = 0;
-    virtual bool ZeroRttAttempted() const = 0;
-    virtual void SetPreviousCachedNetworkParams(
-        CachedNetworkParameters cached_network_params) = 0;
-    virtual void OnPacketDecrypted(EncryptionLevel level) = 0;
-
-    // NOTE: Indicating that the Expect-CT header should be sent here presents a
-    // layering violation to some extent. The Expect-CT header only applies to
-    // HTTP connections, while this class can be used for non-HTTP applications.
-    // However, it is exposed here because that is the only place where the
-    // configuration for the certificate used in the connection is accessible.
-    virtual bool ShouldSendExpectCTHeader() const = 0;
-
-    // Returns true once any encrypter (initial/0RTT or final/1RTT) has been set
-    // for the connection.
-    virtual bool encryption_established() const = 0;
-
-    // Returns true once 1RTT keys are available.
-    virtual bool one_rtt_keys_available() const = 0;
-
-    // Returns the parameters negotiated in the crypto handshake.
-    virtual const QuicCryptoNegotiatedParameters& crypto_negotiated_params()
-        const = 0;
-
-    // Used by QuicCryptoStream to parse data received on this stream.
-    virtual CryptoMessageParser* crypto_message_parser() = 0;
-
-    // Get current handshake state.
-    virtual HandshakeState GetHandshakeState() const = 0;
-
-    // Used by QuicCryptoStream to know how much unprocessed data can be
-    // buffered at each encryption level.
-    virtual size_t BufferSizeLimitForLevel(EncryptionLevel level) const = 0;
-  };
-
-  QuicCryptoServerStream(const QuicCryptoServerStream&) = delete;
-  QuicCryptoServerStream& operator=(const QuicCryptoServerStream&) = delete;
-
-  ~QuicCryptoServerStream() override;
-
-  // From QuicCryptoServerStreamBase
-  void CancelOutstandingCallbacks() override;
-  bool GetBase64SHA256ClientChannelID(std::string* output) const override;
-  void SendServerConfigUpdate(
-      const CachedNetworkParameters* cached_network_params) override;
-  uint8_t NumHandshakeMessages() const override;
-  uint8_t NumHandshakeMessagesWithServerNonces() const override;
-  int NumServerConfigUpdateMessagesSent() const override;
-  const CachedNetworkParameters* PreviousCachedNetworkParams() const override;
-  bool ZeroRttAttempted() const override;
-  void SetPreviousCachedNetworkParams(
-      CachedNetworkParameters cached_network_params) override;
-  bool ShouldSendExpectCTHeader() const override;
-
-  bool encryption_established() const override;
-  bool one_rtt_keys_available() const override;
-  const QuicCryptoNegotiatedParameters& crypto_negotiated_params()
-      const override;
-  CryptoMessageParser* crypto_message_parser() override;
-  void OnPacketDecrypted(EncryptionLevel level) override;
-  void OnOneRttPacketAcknowledged() override {}
-  void OnHandshakeDoneReceived() override;
-  HandshakeState GetHandshakeState() const override;
-  size_t BufferSizeLimitForLevel(EncryptionLevel level) const override;
-
- protected:
-  QUIC_EXPORT_PRIVATE friend std::unique_ptr<QuicCryptoServerStreamBase>
-  CreateCryptoServerStream(const QuicCryptoServerConfig* crypto_config,
-                           QuicCompressedCertsCache* compressed_certs_cache,
-                           QuicSession* session,
-                           QuicCryptoServerStreamBase::Helper* helper);
-
-  QuicCryptoServerStream(const QuicCryptoServerConfig* crypto_config,
-                         QuicCompressedCertsCache* compressed_certs_cache,
-                         QuicSession* session,
-                         QuicCryptoServerStreamBase::Helper* helper);
-  // Provided so that subclasses can provide their own handshaker.
-  // set_handshaker can only be called if this QuicCryptoServerStream's
-  // handshaker hasn't been set yet. If set_handshaker is called outside of
-  // OnSuccessfulVersionNegotiation, then that method must be overridden to not
-  // set a handshaker.
-  QuicCryptoServerStream(const QuicCryptoServerConfig* crypto_config,
-                         QuicCompressedCertsCache* compressed_certs_cache,
-                         QuicSession* session,
-                         QuicCryptoServerStreamBase::Helper* helper,
-                         std::unique_ptr<HandshakerInterface> handshaker);
-  void set_handshaker(std::unique_ptr<HandshakerInterface> handshaker);
-  HandshakerInterface* handshaker() const;
-
-  const QuicCryptoServerConfig* crypto_config() const;
-  QuicCompressedCertsCache* compressed_certs_cache() const;
-  QuicCryptoServerStreamBase::Helper* helper() const;
-
- private:
-  std::unique_ptr<HandshakerInterface> handshaker_;
-
-  // Arguments from QuicCryptoServerStream constructor that might need to be
-  // passed to the HandshakerInterface constructor in its late construction.
-  const QuicCryptoServerConfig* crypto_config_;
-  QuicCompressedCertsCache* compressed_certs_cache_;
-  QuicCryptoServerStreamBase::Helper* helper_;
-};
-
 // Creates an appropriate QuicCryptoServerStream for the provided parameters,
 // including the version used by |session|. |crypto_config|, |session|, and
 // |helper| must all outlive the stream. The caller takes ownership of the
diff --git a/quic/tools/quic_simple_server_session_test.cc b/quic/tools/quic_simple_server_session_test.cc
index 8265dde..0315c86 100644
--- a/quic/tools/quic_simple_server_session_test.cc
+++ b/quic/tools/quic_simple_server_session_test.cc
@@ -13,7 +13,7 @@
 #include "net/third_party/quiche/src/quic/core/http/http_encoder.h"
 #include "net/third_party/quiche/src/quic/core/proto/cached_network_parameters_proto.h"
 #include "net/third_party/quiche/src/quic/core/quic_connection.h"
-#include "net/third_party/quiche/src/quic/core/quic_crypto_server_stream.h"
+#include "net/third_party/quiche/src/quic/core/quic_crypto_server_handshaker.h"
 #include "net/third_party/quiche/src/quic/core/quic_utils.h"
 #include "net/third_party/quiche/src/quic/core/quic_versions.h"
 #include "net/third_party/quiche/src/quic/core/tls_server_handshaker.h"
@@ -79,21 +79,22 @@
 
 const size_t kMaxStreamsForTest = 10;
 
-class MockQuicCryptoServerStream : public QuicCryptoServerStream {
+class MockQuicCryptoServerHandshaker : public QuicCryptoServerHandshaker {
  public:
-  explicit MockQuicCryptoServerStream(
+  explicit MockQuicCryptoServerHandshaker(
       const QuicCryptoServerConfig* crypto_config,
       QuicCompressedCertsCache* compressed_certs_cache,
       QuicSession* session,
       QuicCryptoServerStreamBase::Helper* helper)
-      : QuicCryptoServerStream(crypto_config,
-                               compressed_certs_cache,
-                               session,
-                               helper) {}
-  MockQuicCryptoServerStream(const MockQuicCryptoServerStream&) = delete;
-  MockQuicCryptoServerStream& operator=(const MockQuicCryptoServerStream&) =
+      : QuicCryptoServerHandshaker(crypto_config,
+                                   compressed_certs_cache,
+                                   session,
+                                   helper) {}
+  MockQuicCryptoServerHandshaker(const MockQuicCryptoServerHandshaker&) =
       delete;
-  ~MockQuicCryptoServerStream() override {}
+  MockQuicCryptoServerHandshaker& operator=(
+      const MockQuicCryptoServerHandshaker&) = delete;
+  ~MockQuicCryptoServerHandshaker() override {}
 
   MOCK_METHOD1(SendServerConfigUpdate,
                void(const CachedNetworkParameters* cached_network_parameters));
@@ -124,7 +125,7 @@
     QuicCryptoServerStreamBase::Helper* helper) {
   switch (session->connection()->version().handshake_protocol) {
     case PROTOCOL_QUIC_CRYPTO:
-      return new MockQuicCryptoServerStream(
+      return new MockQuicCryptoServerHandshaker(
           crypto_config, compressed_certs_cache, session, helper);
     case PROTOCOL_TLS1_3:
       return new MockTlsServerHandshaker(session, crypto_config->ssl_ctx(),