QuartcFactory cleanup part 1: delete the QuartcFactory object.

QuartcFactory is really just a wrapper for a QuicConnectionHelperInterface and a
function to create a QuartcClientSession.  There's no need for the object.
Instead, CreateQuartcClientSession is now a free function.

gfe-relnote: n/a (Quartc only)
PiperOrigin-RevId: 239778175
Change-Id: I2f7481563f994fb8b364985222c91cbad923af89
diff --git a/quic/quartc/quartc_endpoint.cc b/quic/quartc/quartc_endpoint.cc
index 2882705..459ceba 100644
--- a/quic/quartc/quartc_endpoint.cc
+++ b/quic/quartc/quartc_endpoint.cc
@@ -42,14 +42,6 @@
   return impl_->CreateAlarm(std::move(delegate), arena);
 }
 
-QuartcFactoryConfig CreateFactoryConfig(QuicAlarmFactory* alarm_factory,
-                                        const QuicClock* clock) {
-  QuartcFactoryConfig config;
-  config.alarm_factory = alarm_factory;
-  config.clock = clock;
-  return config;
-}
-
 }  // namespace
 
 QuartcClientEndpoint::QuartcClientEndpoint(
@@ -68,8 +60,7 @@
                                              AllSupportedVersions())),
       create_session_alarm_(QuicWrapUnique(
           alarm_factory_->CreateAlarm(new CreateSessionDelegate(this)))),
-      factory_(QuicMakeUnique<QuartcFactory>(
-          CreateFactoryConfig(alarm_factory, clock))),
+      connection_helper_(QuicMakeUnique<QuartcConnectionHelper>(clock)),
       config_(config) {}
 
 void QuartcClientEndpoint::Connect(QuartcPacketTransport* packet_transport) {
@@ -78,9 +69,10 @@
 }
 
 void QuartcClientEndpoint::OnCreateSessionAlarm() {
-  session_ = factory_->CreateQuartcClientSession(
-      config_, version_manager_->GetSupportedVersions(),
-      serialized_server_config_, packet_transport_);
+  session_ = CreateQuartcClientSession(
+      config_, clock_, alarm_factory_, connection_helper_.get(),
+      version_manager_->GetSupportedVersions(), serialized_server_config_,
+      packet_transport_);
   delegate_->OnSessionCreated(session_.get());
 }
 
diff --git a/quic/quartc/quartc_endpoint.h b/quic/quartc/quartc_endpoint.h
index c78641f..97f3060 100644
--- a/quic/quartc/quartc_endpoint.h
+++ b/quic/quartc/quartc_endpoint.h
@@ -108,11 +108,8 @@
   // calls the delegate.
   std::unique_ptr<QuicAlarm> create_session_alarm_;
 
-  // QuartcFactory used by this endpoint to create sessions.  This is an
-  // implementation detail of the QuartcEndpoint, and will eventually be
-  // replaced by a dispatcher (for servers) or version-negotiation agent (for
-  // clients).
-  std::unique_ptr<QuartcFactory> factory_;
+  // Helper used by QuicConnection.
+  std::unique_ptr<QuicConnectionHelperInterface> connection_helper_;
 
   // Config to be used for new sessions.
   QuartcSessionConfig config_;
diff --git a/quic/quartc/quartc_factory.cc b/quic/quartc/quartc_factory.cc
index 8efa544..51066f4 100644
--- a/quic/quartc/quartc_factory.cc
+++ b/quic/quartc/quartc_factory.cc
@@ -16,16 +16,11 @@
 
 namespace quic {
 
-QuartcFactory::QuartcFactory(const QuartcFactoryConfig& factory_config)
-    : alarm_factory_(factory_config.alarm_factory),
-      clock_(factory_config.clock),
-      connection_helper_(QuicMakeUnique<QuartcConnectionHelper>(clock_)),
-      compressed_certs_cache_(QuicMakeUnique<QuicCompressedCertsCache>(
-          QuicCompressedCertsCache::kQuicCompressedCertsCacheSize)),
-      stream_helper_(QuicMakeUnique<QuartcCryptoServerStreamHelper>()) {}
-
-std::unique_ptr<QuartcSession> QuartcFactory::CreateQuartcClientSession(
+std::unique_ptr<QuartcSession> CreateQuartcClientSession(
     const QuartcSessionConfig& quartc_session_config,
+    const QuicClock* clock,
+    QuicAlarmFactory* alarm_factory,
+    QuicConnectionHelperInterface* connection_helper,
     const ParsedQuicVersionVector& supported_versions,
     QuicStringPiece server_crypto_config,
     QuartcPacketTransport* packet_transport) {
@@ -38,11 +33,18 @@
   // While the QuicConfig is not directly used by the connection, creating it
   // also sets flag values which must be set before creating the connection.
   QuicConfig quic_config = CreateQuicConfig(quartc_session_config);
+
+  // |dummy_id| and |dummy_address| are used because Quartc network layer will
+  // not use these two.
+  QuicConnectionId dummy_id = QuicUtils::CreateZeroConnectionId(
+      supported_versions[0].transport_version);
+  QuicSocketAddress dummy_address(QuicIpAddress::Any4(), /*port=*/0);
   std::unique_ptr<QuicConnection> quic_connection = CreateQuicConnection(
-      Perspective::IS_CLIENT, supported_versions, writer.get());
+      dummy_id, dummy_address, connection_helper, alarm_factory, writer.get(),
+      Perspective::IS_CLIENT, supported_versions);
 
   return QuicMakeUnique<QuartcClientSession>(
-      std::move(quic_connection), quic_config, supported_versions, clock_,
+      std::move(quic_connection), quic_config, supported_versions, clock,
       std::move(writer),
       CreateCryptoClientConfig(quartc_session_config.pre_shared_key),
       server_crypto_config);
@@ -191,20 +193,6 @@
   return quic_config;
 }
 
-std::unique_ptr<QuicConnection> QuartcFactory::CreateQuicConnection(
-    Perspective perspective,
-    const ParsedQuicVersionVector& supported_versions,
-    QuartcPacketWriter* packet_writer) {
-  // |dummy_id| and |dummy_address| are used because Quartc network layer will
-  // not use these two.
-  QuicConnectionId dummy_id = QuicUtils::CreateZeroConnectionId(
-      supported_versions[0].transport_version);
-  QuicSocketAddress dummy_address(QuicIpAddress::Any4(), /*port=*/0);
-  return quic::CreateQuicConnection(
-      dummy_id, dummy_address, connection_helper_.get(), alarm_factory_,
-      packet_writer, perspective, supported_versions);
-}
-
 std::unique_ptr<QuicConnection> CreateQuicConnection(
     QuicConnectionId connection_id,
     const QuicSocketAddress& peer_address,
@@ -246,9 +234,4 @@
   return quic_connection;
 }
 
-std::unique_ptr<QuartcFactory> CreateQuartcFactory(
-    const QuartcFactoryConfig& factory_config) {
-  return std::unique_ptr<QuartcFactory>(new QuartcFactory(factory_config));
-}
-
 }  // namespace quic
diff --git a/quic/quartc/quartc_factory.h b/quic/quartc/quartc_factory.h
index d568f52..df55cd3 100644
--- a/quic/quartc/quartc_factory.h
+++ b/quic/quartc/quartc_factory.h
@@ -13,18 +13,6 @@
 
 namespace quic {
 
-// The configuration for creating a QuartcFactory.
-struct QuartcFactoryConfig {
-  // Factory for |QuicAlarm|s. Implemented by the Quartc user with different
-  // mechanisms. For example in WebRTC, it is implemented with rtc::Thread.
-  // Owned by the user, and needs to stay alive for as long as the QuartcFactory
-  // exists.
-  QuicAlarmFactory* alarm_factory = nullptr;
-  // The clock used by |QuicAlarm|s. Implemented by the Quartc user. Owned by
-  // the user, and needs to stay alive for as long as the QuartcFactory exists.
-  const QuicClock* clock = nullptr;
-};
-
 struct QuartcSessionConfig {
   // If a pre-shared cryptographic key is available for this session, specify it
   // here.  This value will only be used if non-empty.
@@ -48,42 +36,15 @@
   bool enable_tail_loss_probe = true;
 };
 
-// Factory that creates instances of QuartcSession.  Implements the
-// QuicConnectionHelperInterface used by the QuicConnections. Only one
-// QuartcFactory is expected to be created.
-class QuartcFactory {
- public:
-  explicit QuartcFactory(const QuartcFactoryConfig& factory_config);
-
-  // Creates a new QuartcSession using the given configuration.
-  std::unique_ptr<QuartcSession> CreateQuartcClientSession(
-      const QuartcSessionConfig& quartc_session_config,
-      const ParsedQuicVersionVector& supported_versions,
-      QuicStringPiece server_crypto_config,
-      QuartcPacketTransport* packet_transport);
-
- private:
-  std::unique_ptr<QuicConnection> CreateQuicConnection(
-      Perspective perspective,
-      const ParsedQuicVersionVector& supported_versions,
-      QuartcPacketWriter* packet_writer);
-
-  // Used to implement QuicAlarmFactory.  Owned by the user and must outlive
-  // QuartcFactory.
-  QuicAlarmFactory* alarm_factory_;
-  // Used to implement the QuicConnectionHelperInterface.  Owned by the user and
-  // must outlive QuartcFactory.
-  const QuicClock* clock_;
-
-  // Helper used by all QuicConnections.
-  std::unique_ptr<QuicConnectionHelperInterface> connection_helper_;
-
-  // Used by QuicCryptoServerStream to track most recently compressed certs.
-  std::unique_ptr<QuicCompressedCertsCache> compressed_certs_cache_;
-
-  // This helper is needed to create QuicCryptoServerStreams.
-  std::unique_ptr<QuicCryptoServerStream::Helper> stream_helper_;
-};
+// Creates a new QuartcClientSession using the given configuration.
+std::unique_ptr<QuartcSession> CreateQuartcClientSession(
+    const QuartcSessionConfig& quartc_session_config,
+    const QuicClock* clock,
+    QuicAlarmFactory* alarm_factory,
+    QuicConnectionHelperInterface* connection_helper,
+    const ParsedQuicVersionVector& supported_versions,
+    QuicStringPiece server_crypto_config,
+    QuartcPacketTransport* packet_transport);
 
 // Configures global settings, such as supported quic versions.
 // Must execute on QUIC thread.
@@ -101,10 +62,6 @@
     Perspective perspective,
     ParsedQuicVersionVector supported_versions);
 
-// Creates a new instance of QuartcFactory.
-std::unique_ptr<QuartcFactory> CreateQuartcFactory(
-    const QuartcFactoryConfig& factory_config);
-
 }  // namespace quic
 
 #endif  // QUICHE_QUIC_QUARTC_QUARTC_FACTORY_H_