Replace long connection IDs in GfeQuicDispatcher

Google's QUIC implementation only uses 8-byte connection IDs. However, other implementations can use longer connection IDs at the start of the connection - we then replace them with 8-byte ones. This replacement is performed by QuicDispatcher. However, GfeQuicDispatcher keeps its own connection ID map, and we therefore need to also replace connection IDs before inserting into that map.

Replace connection ids, protected by gfe2_restart_flag_quic_replace_gfe_connection_ids

PiperOrigin-RevId: 311152585
Change-Id: I1e7c53c9a93427cc9c043ca5d277e4f0d0d4507d
diff --git a/quic/core/quic_dispatcher.cc b/quic/core/quic_dispatcher.cc
index a73a10d..ffea9ff 100644
--- a/quic/core/quic_dispatcher.cc
+++ b/quic/core/quic_dispatcher.cc
@@ -311,7 +311,7 @@
 
 QuicConnectionId QuicDispatcher::MaybeReplaceServerConnectionId(
     QuicConnectionId server_connection_id,
-    ParsedQuicVersion version) {
+    ParsedQuicVersion version) const {
   if (server_connection_id.length() == expected_server_connection_id_length_) {
     return server_connection_id;
   }
diff --git a/quic/core/quic_dispatcher.h b/quic/core/quic_dispatcher.h
index cd58130..73ab3ec 100644
--- a/quic/core/quic_dispatcher.h
+++ b/quic/core/quic_dispatcher.h
@@ -307,6 +307,13 @@
   // element of the vector is returned.
   std::string SelectAlpn(const std::vector<std::string>& alpns);
 
+  // If the connection ID length is different from what the dispatcher expects,
+  // replace the connection ID with a random one of the right length,
+  // and save it to make sure the mapping is persistent.
+  QuicConnectionId MaybeReplaceServerConnectionId(
+      QuicConnectionId server_connection_id,
+      ParsedQuicVersion version) const;
+
  private:
   friend class test::QuicDispatcherPeer;
 
@@ -319,13 +326,6 @@
       const std::list<QuicBufferedPacketStore::BufferedPacket>& packets,
       QuicSession* session);
 
-  // If the connection ID length is different from what the dispatcher expects,
-  // replace the connection ID with a random one of the right length,
-  // and save it to make sure the mapping is persistent.
-  QuicConnectionId MaybeReplaceServerConnectionId(
-      QuicConnectionId server_connection_id,
-      ParsedQuicVersion version);
-
   // Returns true if |version| is a supported protocol version.
   bool IsSupportedVersion(const ParsedQuicVersion version);