Rename QUIC connection ID to server connection ID, part 2

This is part of a larger body of work required to enable client connection IDs.

gfe-relnote: n/a, code-rename-only change
PiperOrigin-RevId: 250386523
Change-Id: I20d5a688e040791eefda378f5246adfa770cef61
diff --git a/quic/core/http/end_to_end_test.cc b/quic/core/http/end_to_end_test.cc
index c751cf8..faee164 100644
--- a/quic/core/http/end_to_end_test.cc
+++ b/quic/core/http/end_to_end_test.cc
@@ -211,8 +211,8 @@
         chlo_multiplier_(0),
         stream_factory_(nullptr),
         support_server_push_(false),
-        override_connection_id_(nullptr),
-        expected_connection_id_length_(kQuicDefaultConnectionIdLength) {
+        override_server_connection_id_(nullptr),
+        expected_server_connection_id_length_(kQuicDefaultConnectionIdLength) {
     SetQuicFlag(FLAGS_quic_supports_tls_handshake, true);
     SetQuicRestartFlag(quic_no_server_conn_ver_negotiation2, true);
     SetQuicReloadableFlag(quic_no_client_conn_ver_negotiation, true);
@@ -259,8 +259,8 @@
     if (!pre_shared_key_client_.empty()) {
       client->client()->SetPreSharedKey(pre_shared_key_client_);
     }
-    if (override_connection_id_ != nullptr) {
-      client->UseConnectionId(*override_connection_id_);
+    if (override_server_connection_id_ != nullptr) {
+      client->UseConnectionId(*override_server_connection_id_);
     }
     client->Connect();
     return client;
@@ -375,7 +375,7 @@
     auto* test_server = new QuicTestServer(
         crypto_test_utils::ProofSourceForTesting(), server_config_,
         server_supported_versions_, &memory_cache_backend_,
-        expected_connection_id_length_);
+        expected_server_connection_id_length_);
     server_thread_ = QuicMakeUnique<ServerThread>(test_server, server_address_);
     if (chlo_multiplier_ != 0) {
       server_thread_->server()->SetChloMultiplier(chlo_multiplier_);
@@ -538,8 +538,8 @@
   bool support_server_push_;
   std::string pre_shared_key_client_;
   std::string pre_shared_key_server_;
-  QuicConnectionId* override_connection_id_;
-  uint8_t expected_connection_id_length_;
+  QuicConnectionId* override_server_connection_id_;
+  uint8_t expected_server_connection_id_length_;
 };
 
 // Run all end to end tests with all supported versions.
@@ -603,8 +603,8 @@
 TEST_P(EndToEndTest, SimpleRequestResponseZeroConnectionID) {
   QuicConnectionId connection_id = QuicUtils::CreateZeroConnectionId(
       GetParam().negotiated_version.transport_version);
-  override_connection_id_ = &connection_id;
-  expected_connection_id_length_ = connection_id.length();
+  override_server_connection_id_ = &connection_id;
+  expected_server_connection_id_length_ = connection_id.length();
   ASSERT_TRUE(Initialize());
 
   EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo"));
@@ -628,7 +628,7 @@
   }
   QuicConnectionId connection_id =
       TestConnectionIdNineBytesLong(UINT64_C(0xBADbadBADbad));
-  override_connection_id_ = &connection_id;
+  override_server_connection_id_ = &connection_id;
   ASSERT_TRUE(Initialize());
   EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo"));
   EXPECT_EQ("200", client_->response_headers()->find(":status")->second);
@@ -654,7 +654,7 @@
                                     QuicVersionReservedForNegotiation());
   QuicConnectionId connection_id =
       TestConnectionIdNineBytesLong(UINT64_C(0xBADbadBADbad));
-  override_connection_id_ = &connection_id;
+  override_server_connection_id_ = &connection_id;
   ASSERT_TRUE(Initialize());
   ASSERT_TRUE(ServerSendsVersionNegotiation());
   EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo"));
@@ -676,9 +676,9 @@
   // Start client_ which will use a bad connection ID length.
   QuicConnectionId connection_id =
       TestConnectionIdNineBytesLong(UINT64_C(0xBADbadBADbad));
-  override_connection_id_ = &connection_id;
+  override_server_connection_id_ = &connection_id;
   ASSERT_TRUE(Initialize());
-  override_connection_id_ = nullptr;
+  override_server_connection_id_ = nullptr;
 
   // Start client2 which will use a good connection ID length.
   std::unique_ptr<QuicTestClient> client2(CreateQuicClient(nullptr));
@@ -783,8 +783,8 @@
 TEST_P(EndToEndTest, MultipleRequestResponseZeroConnectionID) {
   QuicConnectionId connection_id = QuicUtils::CreateZeroConnectionId(
       GetParam().negotiated_version.transport_version);
-  override_connection_id_ = &connection_id;
-  expected_connection_id_length_ = connection_id.length();
+  override_server_connection_id_ = &connection_id;
+  expected_server_connection_id_length_ = connection_id.length();
   ASSERT_TRUE(Initialize());
 
   EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo"));
diff --git a/quic/core/quic_connection.cc b/quic/core/quic_connection.cc
index 6afc62d..226a4cc 100644
--- a/quic/core/quic_connection.cc
+++ b/quic/core/quic_connection.cc
@@ -376,8 +376,7 @@
   if (use_uber_received_packet_manager_) {
     QUIC_RELOADABLE_FLAG_COUNT(quic_use_uber_received_packet_manager);
   }
-  QUIC_DLOG(INFO) << ENDPOINT
-                  << "Created connection with server connection_id: "
+  QUIC_DLOG(INFO) << ENDPOINT << "Created connection with server connection ID "
                   << server_connection_id
                   << " and version: " << ParsedQuicVersionToString(version());
 
diff --git a/quic/core/quic_dispatcher.cc b/quic/core/quic_dispatcher.cc
index 796b2dc..63a64c9 100644
--- a/quic/core/quic_dispatcher.cc
+++ b/quic/core/quic_dispatcher.cc
@@ -237,7 +237,7 @@
     std::unique_ptr<QuicConnectionHelperInterface> helper,
     std::unique_ptr<QuicCryptoServerStream::Helper> session_helper,
     std::unique_ptr<QuicAlarmFactory> alarm_factory,
-    uint8_t expected_connection_id_length)
+    uint8_t expected_server_connection_id_length)
     : config_(config),
       crypto_config_(crypto_config),
       compressed_certs_cache_(
@@ -253,14 +253,15 @@
       framer_(GetSupportedVersions(),
               /*unused*/ QuicTime::Zero(),
               Perspective::IS_SERVER,
-              expected_connection_id_length),
+              expected_server_connection_id_length),
       last_error_(QUIC_NO_ERROR),
       new_sessions_allowed_per_event_loop_(0u),
       accept_new_connections_(true),
       allow_short_initial_server_connection_ids_(false),
       last_version_label_(0),
-      expected_connection_id_length_(expected_connection_id_length),
-      should_update_expected_connection_id_length_(false),
+      expected_server_connection_id_length_(
+          expected_server_connection_id_length),
+      should_update_expected_server_connection_id_length_(false),
       no_framer_(GetQuicRestartFlag(quic_no_framer_object_in_dispatcher)) {
   if (!no_framer_) {
     framer_.set_visitor(this);
@@ -304,7 +305,7 @@
   uint8_t destination_connection_id_length;
   std::string detailed_error;
   const QuicErrorCode error = QuicFramer::ProcessPacketDispatcher(
-      packet, expected_connection_id_length_, &header.form,
+      packet, expected_server_connection_id_length_, &header.form,
       &header.version_flag, &last_version_label_,
       &destination_connection_id_length, &header.destination_connection_id,
       &detailed_error);
@@ -315,16 +316,17 @@
     return;
   }
   header.version = ParseQuicVersionLabel(last_version_label_);
-  if (destination_connection_id_length != expected_connection_id_length_ &&
-      !should_update_expected_connection_id_length_ &&
+  if (destination_connection_id_length !=
+          expected_server_connection_id_length_ &&
+      !should_update_expected_server_connection_id_length_ &&
       !QuicUtils::VariableLengthConnectionIdAllowedForVersion(
           header.version.transport_version)) {
     SetLastError(QUIC_INVALID_PACKET_HEADER);
     QUIC_DLOG(ERROR) << "Invalid Connection Id Length";
     return;
   }
-  if (should_update_expected_connection_id_length_) {
-    expected_connection_id_length_ = destination_connection_id_length;
+  if (should_update_expected_server_connection_id_length_) {
+    expected_server_connection_id_length_ = destination_connection_id_length;
   }
   // TODO(fayang): Instead of passing in QuicPacketHeader, pass format,
   // version_flag, version and destination_connection_id. Combine
@@ -341,10 +343,10 @@
 QuicConnectionId QuicDispatcher::MaybeReplaceServerConnectionId(
     QuicConnectionId server_connection_id,
     ParsedQuicVersion version) {
-  const uint8_t expected_connection_id_length =
-      no_framer_ ? expected_connection_id_length_
-                 : framer_.GetExpectedConnectionIdLength();
-  if (server_connection_id.length() == expected_connection_id_length) {
+  const uint8_t expected_server_connection_id_length =
+      no_framer_ ? expected_server_connection_id_length_
+                 : framer_.GetExpectedServerConnectionIdLength();
+  if (server_connection_id.length() == expected_server_connection_id_length) {
     return server_connection_id;
   }
   DCHECK(QuicUtils::VariableLengthConnectionIdAllowedForVersion(
@@ -356,7 +358,7 @@
   QuicConnectionId new_connection_id =
       session_helper_->GenerateConnectionIdForReject(version.transport_version,
                                                      server_connection_id);
-  DCHECK_EQ(expected_connection_id_length, new_connection_id.length());
+  DCHECK_EQ(expected_server_connection_id_length, new_connection_id.length());
   connection_id_map_.insert(
       std::make_pair(server_connection_id, new_connection_id));
   QUIC_DLOG(INFO) << "Replacing incoming connection ID " << server_connection_id
@@ -387,18 +389,18 @@
   // connection ID, the dispatcher picks a new one of its expected length.
   // Therefore we should never receive a connection ID that is smaller
   // than 64 bits and smaller than what we expect.
-  const uint8_t expected_connection_id_length =
-      no_framer_ ? expected_connection_id_length_
-                 : framer_.GetExpectedConnectionIdLength();
+  const uint8_t expected_server_connection_id_length =
+      no_framer_ ? expected_server_connection_id_length_
+                 : framer_.GetExpectedServerConnectionIdLength();
   if (server_connection_id.length() < kQuicMinimumInitialConnectionIdLength &&
-      server_connection_id.length() < expected_connection_id_length &&
+      server_connection_id.length() < expected_server_connection_id_length &&
       !allow_short_initial_server_connection_ids_) {
     DCHECK(header.version_flag);
     DCHECK(QuicUtils::VariableLengthConnectionIdAllowedForVersion(
         header.version.transport_version));
     QUIC_DLOG(INFO) << "Packet with short destination connection ID "
                     << server_connection_id << " expected "
-                    << static_cast<int>(expected_connection_id_length);
+                    << static_cast<int>(expected_server_connection_id_length);
     ProcessUnauthenticatedHeaderFate(kFateTimeWait, server_connection_id,
                                      header.form, header.version_flag,
                                      header.version);
diff --git a/quic/core/quic_dispatcher.h b/quic/core/quic_dispatcher.h
index f22505a..790d4d2 100644
--- a/quic/core/quic_dispatcher.h
+++ b/quic/core/quic_dispatcher.h
@@ -48,7 +48,7 @@
                  std::unique_ptr<QuicConnectionHelperInterface> helper,
                  std::unique_ptr<QuicCryptoServerStream::Helper> session_helper,
                  std::unique_ptr<QuicAlarmFactory> alarm_factory,
-                 uint8_t expected_connection_id_length);
+                 uint8_t expected_server_connection_id_length);
   QuicDispatcher(const QuicDispatcher&) = delete;
   QuicDispatcher& operator=(const QuicDispatcher&) = delete;
 
@@ -356,15 +356,15 @@
 
   // If true, our framer will change its expected connection ID length
   // to the received destination connection ID length of all IETF long headers.
-  void SetShouldUpdateExpectedConnectionIdLength(
-      bool should_update_expected_connection_id_length) {
+  void SetShouldUpdateExpectedServerConnectionIdLength(
+      bool should_update_expected_server_connection_id_length) {
     if (!no_framer_) {
-      framer_.SetShouldUpdateExpectedConnectionIdLength(
-          should_update_expected_connection_id_length);
+      framer_.SetShouldUpdateExpectedServerConnectionIdLength(
+          should_update_expected_server_connection_id_length);
       return;
     }
-    should_update_expected_connection_id_length_ =
-        should_update_expected_connection_id_length;
+    should_update_expected_server_connection_id_length_ =
+        should_update_expected_server_connection_id_length;
   }
 
   // If true, the dispatcher will allow incoming initial packets that have
@@ -508,14 +508,15 @@
   // encode its length. This variable contains the length we expect to read.
   // This is also used to signal an error when a long header packet with
   // different destination connection ID length is received when
-  // should_update_expected_connection_id_length_ is false and packet's version
-  // does not allow variable length connection ID. Used when no_framer_ is true.
-  uint8_t expected_connection_id_length_;
+  // should_update_expected_server_connection_id_length_ is false and packet's
+  // version does not allow variable length connection ID. Used when no_framer_
+  // is true.
+  uint8_t expected_server_connection_id_length_;
 
-  // If true, change expected_connection_id_length_ to be the received
+  // If true, change expected_server_connection_id_length_ to be the received
   // destination connection ID length of all IETF long headers. Used when
   // no_framer_ is true.
-  bool should_update_expected_connection_id_length_;
+  bool should_update_expected_server_connection_id_length_;
 
   // Latched value of quic_no_framer_object_in_dispatcher.
   const bool no_framer_;
diff --git a/quic/core/quic_framer.cc b/quic/core/quic_framer.cc
index 6ebdc78..b66b98d 100644
--- a/quic/core/quic_framer.cc
+++ b/quic/core/quic_framer.cc
@@ -459,7 +459,7 @@
 QuicFramer::QuicFramer(const ParsedQuicVersionVector& supported_versions,
                        QuicTime creation_time,
                        Perspective perspective,
-                       uint8_t expected_connection_id_length)
+                       uint8_t expected_server_connection_id_length)
     : visitor_(nullptr),
       error_(QUIC_NO_ERROR),
       last_serialized_server_connection_id_(EmptyQuicConnectionId()),
@@ -478,8 +478,9 @@
       data_producer_(nullptr),
       infer_packet_header_type_from_version_(perspective ==
                                              Perspective::IS_CLIENT),
-      expected_connection_id_length_(expected_connection_id_length),
-      should_update_expected_connection_id_length_(false),
+      expected_server_connection_id_length_(
+          expected_server_connection_id_length),
+      should_update_expected_server_connection_id_length_(false),
       supports_multiple_packet_number_spaces_(false),
       last_written_packet_number_length_(0) {
   DCHECK(!supported_versions.empty());
@@ -1387,14 +1388,14 @@
 
 // static
 std::unique_ptr<QuicEncryptedPacket> QuicFramer::BuildVersionNegotiationPacket(
-    QuicConnectionId connection_id,
+    QuicConnectionId server_connection_id,
     bool ietf_quic,
     const ParsedQuicVersionVector& versions) {
   if (ietf_quic) {
-    return BuildIetfVersionNegotiationPacket(connection_id, versions);
+    return BuildIetfVersionNegotiationPacket(server_connection_id, versions);
   }
   DCHECK(!versions.empty());
-  size_t len = kPublicFlagsSize + connection_id.length() +
+  size_t len = kPublicFlagsSize + server_connection_id.length() +
                versions.size() * kQuicVersionSize;
   std::unique_ptr<char[]> buffer(new char[len]);
   // Endianness is not a concern here, version negotiation packet does not have
@@ -1409,7 +1410,7 @@
     return nullptr;
   }
 
-  if (!writer.WriteConnectionId(connection_id)) {
+  if (!writer.WriteConnectionId(server_connection_id)) {
     return nullptr;
   }
 
@@ -2614,8 +2615,8 @@
 bool QuicFramer::ProcessAndValidateIetfConnectionIdLength(
     QuicDataReader* reader,
     ParsedQuicVersion version,
-    bool should_update_expected_connection_id_length,
-    uint8_t* expected_connection_id_length,
+    bool should_update_expected_server_connection_id_length,
+    uint8_t* expected_server_connection_id_length,
     uint8_t* destination_connection_id_length,
     uint8_t* source_connection_id_length,
     std::string* detailed_error) {
@@ -2629,18 +2630,18 @@
   if (dcil != 0) {
     dcil += kConnectionIdLengthAdjustment;
   }
-  if (should_update_expected_connection_id_length &&
-      *expected_connection_id_length != dcil) {
-    QUIC_DVLOG(1) << "Updating expected_connection_id_length: "
-                  << static_cast<int>(*expected_connection_id_length) << " -> "
-                  << static_cast<int>(dcil);
-    *expected_connection_id_length = dcil;
+  if (should_update_expected_server_connection_id_length &&
+      *expected_server_connection_id_length != dcil) {
+    QUIC_DVLOG(1) << "Updating expected_server_connection_id_length: "
+                  << static_cast<int>(*expected_server_connection_id_length)
+                  << " -> " << static_cast<int>(dcil);
+    *expected_server_connection_id_length = dcil;
   }
   uint8_t scil = connection_id_lengths_byte & kSourceConnectionIdLengthMask;
   if (scil != 0) {
     scil += kConnectionIdLengthAdjustment;
   }
-  if (!should_update_expected_connection_id_length &&
+  if (!should_update_expected_server_connection_id_length &&
       (dcil != *destination_connection_id_length ||
        scil != *source_connection_id_length) &&
       !QuicUtils::VariableLengthConnectionIdAllowedForVersion(
@@ -2665,18 +2666,19 @@
 
   uint8_t destination_connection_id_length =
       header->destination_connection_id_included == CONNECTION_ID_PRESENT
-          ? expected_connection_id_length_
+          ? expected_server_connection_id_length_
           : 0;
   uint8_t source_connection_id_length =
       header->source_connection_id_included == CONNECTION_ID_PRESENT
-          ? expected_connection_id_length_
+          ? expected_server_connection_id_length_
           : 0;
   if (header->form == IETF_QUIC_LONG_HEADER_PACKET) {
     if (!ProcessAndValidateIetfConnectionIdLength(
             reader, header->version,
-            should_update_expected_connection_id_length_,
-            &expected_connection_id_length_, &destination_connection_id_length,
-            &source_connection_id_length, &detailed_error_)) {
+            should_update_expected_server_connection_id_length_,
+            &expected_server_connection_id_length_,
+            &destination_connection_id_length, &source_connection_id_length,
+            &detailed_error_)) {
       return false;
     }
   }
@@ -6082,14 +6084,14 @@
       *detailed_error = "Unable to read protocol version.";
       return QUIC_INVALID_PACKET_HEADER;
     }
-    // Set should_update_expected_connection_id_length to true to bypass
+    // Set should_update_expected_server_connection_id_length to true to bypass
     // connection ID lengths validation.
     uint8_t unused_source_connection_id_length = 0;
-    uint8_t unused_expected_connection_id_length = 0;
+    uint8_t unused_expected_server_connection_id_length = 0;
     if (!ProcessAndValidateIetfConnectionIdLength(
             &reader, ParseQuicVersionLabel(*version_label),
-            /*should_update_expected_connection_id_length=*/true,
-            &unused_expected_connection_id_length,
+            /*should_update_expected_server_connection_id_length=*/true,
+            &unused_expected_server_connection_id_length,
             destination_connection_id_length,
             &unused_source_connection_id_length, detailed_error)) {
       return QUIC_INVALID_PACKET_HEADER;
@@ -6233,13 +6235,14 @@
     *detailed_error = "Packet is not a version negotiation packet";
     return false;
   }
-  uint8_t expected_connection_id_length = 0,
+  uint8_t expected_server_connection_id_length = 0,
           destination_connection_id_length = 0, source_connection_id_length = 0;
   if (!ProcessAndValidateIetfConnectionIdLength(
           &reader, UnsupportedQuicVersion(),
-          /*should_update_expected_connection_id_length=*/true,
-          &expected_connection_id_length, &destination_connection_id_length,
-          &source_connection_id_length, detailed_error)) {
+          /*should_update_expected_server_connection_id_length=*/true,
+          &expected_server_connection_id_length,
+          &destination_connection_id_length, &source_connection_id_length,
+          detailed_error)) {
     return false;
   }
   if (destination_connection_id_length != 0) {
diff --git a/quic/core/quic_framer.h b/quic/core/quic_framer.h
index e56aba2..d939175 100644
--- a/quic/core/quic_framer.h
+++ b/quic/core/quic_framer.h
@@ -226,7 +226,7 @@
   QuicFramer(const ParsedQuicVersionVector& supported_versions,
              QuicTime creation_time,
              Perspective perspective,
-             uint8_t expected_connection_id_length);
+             uint8_t expected_server_connection_id_length);
   QuicFramer(const QuicFramer&) = delete;
   QuicFramer& operator=(const QuicFramer&) = delete;
 
@@ -575,15 +575,16 @@
 
   // If true, QuicFramer will change its expected connection ID length
   // to the received destination connection ID length of all IETF long headers.
-  void SetShouldUpdateExpectedConnectionIdLength(
-      bool should_update_expected_connection_id_length) {
-    should_update_expected_connection_id_length_ =
-        should_update_expected_connection_id_length;
+  void SetShouldUpdateExpectedServerConnectionIdLength(
+      bool should_update_expected_server_connection_id_length) {
+    should_update_expected_server_connection_id_length_ =
+        should_update_expected_server_connection_id_length;
   }
 
-  // The connection ID length the framer expects on incoming IETF short headers.
-  uint8_t GetExpectedConnectionIdLength() {
-    return expected_connection_id_length_;
+  // The connection ID length the framer expects on incoming IETF short headers
+  // on the server.
+  uint8_t GetExpectedServerConnectionIdLength() {
+    return expected_server_connection_id_length_;
   }
 
   void EnableMultiplePacketNumberSpacesSupport();
@@ -715,8 +716,8 @@
   static bool ProcessAndValidateIetfConnectionIdLength(
       QuicDataReader* reader,
       ParsedQuicVersion version,
-      bool should_update_expected_connection_id_length,
-      uint8_t* expected_connection_id_length,
+      bool should_update_expected_server_connection_id_length,
+      uint8_t* expected_server_connection_id_length,
       uint8_t* destination_connection_id_length,
       uint8_t* source_connection_id_length,
       std::string* detailed_error);
@@ -1017,15 +1018,14 @@
   // encode its length. This variable contains the length we expect to read.
   // This is also used to validate the long header connection ID lengths in
   // older versions of QUIC.
-  // TODO(fayang): Remove this when deprecating
-  // quic_no_framer_object_in_dispatcher.
-  uint8_t expected_connection_id_length_;
+  uint8_t expected_server_connection_id_length_;
 
-  // When this is true, QuicFramer will change expected_connection_id_length_
-  // to the received destination connection ID length of all IETF long headers.
+  // When this is true, QuicFramer will change
+  // expected_server_connection_id_length_ to the received destination
+  // connection ID length of all IETF long headers.
   // TODO(fayang): Remove this when deprecating
   // quic_no_framer_object_in_dispatcher.
-  bool should_update_expected_connection_id_length_;
+  bool should_update_expected_server_connection_id_length_;
 
   // Indicates whether this framer supports multiple packet number spaces.
   bool supports_multiple_packet_number_spaces_;
diff --git a/quic/core/quic_framer_test.cc b/quic/core/quic_framer_test.cc
index 65022e2..0201c8e 100644
--- a/quic/core/quic_framer_test.cc
+++ b/quic/core/quic_framer_test.cc
@@ -13236,8 +13236,8 @@
   QuicConnectionId connection_id(connection_id_bytes,
                                  sizeof(connection_id_bytes));
   QuicFramerPeer::SetLargestPacketNumber(&framer_, kPacketNumber - 2);
-  QuicFramerPeer::SetExpectedConnectionIDLength(&framer_,
-                                                connection_id.length());
+  QuicFramerPeer::SetExpectedServerConnectionIDLength(&framer_,
+                                                      connection_id.length());
 
   // clang-format off
   PacketFragments packet = {
@@ -13293,7 +13293,7 @@
     return;
   }
   SetDecrypterLevel(ENCRYPTION_ZERO_RTT);
-  framer_.SetShouldUpdateExpectedConnectionIdLength(true);
+  framer_.SetShouldUpdateExpectedServerConnectionIdLength(true);
 
   // clang-format off
   unsigned char long_header_packet[] = {
@@ -13405,7 +13405,7 @@
   if (framer_.transport_version() < QUIC_VERSION_46) {
     return;
   }
-  framer_.SetShouldUpdateExpectedConnectionIdLength(true);
+  framer_.SetShouldUpdateExpectedServerConnectionIdLength(true);
   framer_.EnableMultiplePacketNumberSpacesSupport();
 
   // clang-format off
diff --git a/quic/core/quic_packet_creator.h b/quic/core/quic_packet_creator.h
index c9e31ac..a7b1d5c 100644
--- a/quic/core/quic_packet_creator.h
+++ b/quic/core/quic_packet_creator.h
@@ -225,7 +225,7 @@
   void SetServerConnectionIdIncluded(
       QuicConnectionIdIncluded server_connection_id_included);
 
-  // Update the connection ID used in outgoing packets.
+  // Update the server connection ID used in outgoing packets.
   void SetServerConnectionId(QuicConnectionId server_connection_id);
 
   // Sets the encryption level that will be applied to new packets.
diff --git a/quic/quartc/quartc_dispatcher.cc b/quic/quartc/quartc_dispatcher.cc
index 091d56b..e6e9c2b 100644
--- a/quic/quartc/quartc_dispatcher.cc
+++ b/quic/quartc/quartc_dispatcher.cc
@@ -37,7 +37,7 @@
       delegate_(delegate),
       packet_writer_(packet_writer.get()) {
   // Allow incoming packets to set our expected connection ID length.
-  SetShouldUpdateExpectedConnectionIdLength(true);
+  SetShouldUpdateExpectedServerConnectionIdLength(true);
   // Allow incoming packets with connection ID lengths shorter than allowed.
   SetAllowShortInitialServerConnectionIds(true);
   // QuicDispatcher takes ownership of the writer.
@@ -58,7 +58,7 @@
     QuicStringPiece alpn,
     const ParsedQuicVersion& version) {
   // Make our expected connection ID non-mutable since we have a connection.
-  SetShouldUpdateExpectedConnectionIdLength(false);
+  SetShouldUpdateExpectedServerConnectionIdLength(false);
   std::unique_ptr<QuicConnection> connection = CreateQuicConnection(
       connection_id, client_address, helper(), alarm_factory(), writer(),
       Perspective::IS_SERVER, ParsedQuicVersionVector{version});
diff --git a/quic/test_tools/quic_framer_peer.cc b/quic/test_tools/quic_framer_peer.cc
index dcb0e94..6eedd60 100644
--- a/quic/test_tools/quic_framer_peer.cc
+++ b/quic/test_tools/quic_framer_peer.cc
@@ -337,11 +337,11 @@
 }
 
 // static
-void QuicFramerPeer::SetExpectedConnectionIDLength(
+void QuicFramerPeer::SetExpectedServerConnectionIDLength(
     QuicFramer* framer,
-    uint8_t expected_connection_id_length) {
-  *const_cast<uint8_t*>(&framer->expected_connection_id_length_) =
-      expected_connection_id_length;
+    uint8_t expected_server_connection_id_length) {
+  *const_cast<uint8_t*>(&framer->expected_server_connection_id_length_) =
+      expected_server_connection_id_length;
 }
 
 // static
diff --git a/quic/test_tools/quic_framer_peer.h b/quic/test_tools/quic_framer_peer.h
index e363105..0b17c19 100644
--- a/quic/test_tools/quic_framer_peer.h
+++ b/quic/test_tools/quic_framer_peer.h
@@ -160,9 +160,9 @@
                                    QuicPacketNumberLength packet_number_length);
   static void SetFirstSendingPacketNumber(QuicFramer* framer,
                                           uint64_t packet_number);
-  static void SetExpectedConnectionIDLength(
+  static void SetExpectedServerConnectionIDLength(
       QuicFramer* framer,
-      uint8_t expected_connection_id_length);
+      uint8_t expected_server_connection_id_length);
   static QuicPacketNumber GetLargestDecryptedPacketNumber(
       QuicFramer* framer,
       PacketNumberSpace packet_number_space);
diff --git a/quic/test_tools/quic_test_client.cc b/quic/test_tools/quic_test_client.cc
index 9866a68..d4608ed 100644
--- a/quic/test_tools/quic_test_client.cc
+++ b/quic/test_tools/quic_test_client.cc
@@ -209,8 +209,8 @@
                                                                this),
           QuicWrapUnique(
               new RecordingProofVerifier(std::move(proof_verifier)))),
-      override_connection_id_(EmptyQuicConnectionId()),
-      connection_id_overridden_(false) {}
+      override_server_connection_id_(EmptyQuicConnectionId()),
+      server_connection_id_overridden_(false) {}
 
 MockableQuicClient::~MockableQuicClient() {
   if (connected()) {
@@ -231,13 +231,15 @@
 }
 
 QuicConnectionId MockableQuicClient::GenerateNewConnectionId() {
-  return connection_id_overridden_ ? override_connection_id_
-                                   : QuicClient::GenerateNewConnectionId();
+  return server_connection_id_overridden_
+             ? override_server_connection_id_
+             : QuicClient::GenerateNewConnectionId();
 }
 
-void MockableQuicClient::UseConnectionId(QuicConnectionId connection_id) {
-  connection_id_overridden_ = true;
-  override_connection_id_ = connection_id;
+void MockableQuicClient::UseConnectionId(
+    QuicConnectionId server_connection_id) {
+  server_connection_id_overridden_ = true;
+  override_server_connection_id_ = server_connection_id;
 }
 
 void MockableQuicClient::UseWriter(QuicPacketWriterWrapper* writer) {
@@ -749,9 +751,9 @@
   client_->UseWriter(writer);
 }
 
-void QuicTestClient::UseConnectionId(QuicConnectionId connection_id) {
+void QuicTestClient::UseConnectionId(QuicConnectionId server_connection_id) {
   DCHECK(!connected());
-  client_->UseConnectionId(connection_id);
+  client_->UseConnectionId(server_connection_id);
 }
 
 bool QuicTestClient::MigrateSocket(const QuicIpAddress& new_host) {
diff --git a/quic/test_tools/quic_test_client.h b/quic/test_tools/quic_test_client.h
index 353c29e..a4ee0d5 100644
--- a/quic/test_tools/quic_test_client.h
+++ b/quic/test_tools/quic_test_client.h
@@ -55,7 +55,7 @@
   ~MockableQuicClient() override;
 
   QuicConnectionId GenerateNewConnectionId() override;
-  void UseConnectionId(QuicConnectionId connection_id);
+  void UseConnectionId(QuicConnectionId server_connection_id);
 
   void UseWriter(QuicPacketWriterWrapper* writer);
   void set_peer_address(const QuicSocketAddress& address);
@@ -69,9 +69,9 @@
   const MockableQuicClientEpollNetworkHelper* mockable_network_helper() const;
 
  private:
-  // ConnectionId to use, if connection_id_overridden_
-  QuicConnectionId override_connection_id_;
-  bool connection_id_overridden_;
+  // Server connection ID to use, if server_connection_id_overridden_
+  QuicConnectionId override_server_connection_id_;
+  bool server_connection_id_overridden_;
   CachedNetworkParameters cached_network_paramaters_;
 };
 
@@ -219,9 +219,9 @@
   // Configures client_ to take ownership of and use the writer.
   // Must be called before initial connect.
   void UseWriter(QuicPacketWriterWrapper* writer);
-  // If the given ConnectionId is nonzero, configures client_ to use a specific
-  // ConnectionId instead of a random one.
-  void UseConnectionId(QuicConnectionId connection_id);
+  // Configures client_ to use a specific server connection ID instead of a
+  // random one.
+  void UseConnectionId(QuicConnectionId server_connection_id);
 
   // Returns nullptr if the maximum number of streams have already been created.
   QuicSpdyClientStream* GetOrCreateStream();
diff --git a/quic/test_tools/quic_test_server.cc b/quic/test_tools/quic_test_server.cc
index bda2148..68c500e 100644
--- a/quic/test_tools/quic_test_server.cc
+++ b/quic/test_tools/quic_test_server.cc
@@ -77,7 +77,7 @@
       std::unique_ptr<QuicCryptoServerStream::Helper> session_helper,
       std::unique_ptr<QuicAlarmFactory> alarm_factory,
       QuicSimpleServerBackend* quic_simple_server_backend,
-      uint8_t expected_connection_id_length)
+      uint8_t expected_server_connection_id_length)
       : QuicSimpleDispatcher(config,
                              crypto_config,
                              version_manager,
@@ -85,7 +85,7 @@
                              std::move(session_helper),
                              std::move(alarm_factory),
                              quic_simple_server_backend,
-                             expected_connection_id_length),
+                             expected_server_connection_id_length),
         session_factory_(nullptr),
         stream_factory_(nullptr),
         crypto_stream_factory_(nullptr) {}
@@ -170,13 +170,13 @@
     const QuicConfig& config,
     const ParsedQuicVersionVector& supported_versions,
     QuicSimpleServerBackend* quic_simple_server_backend,
-    uint8_t expected_connection_id_length)
+    uint8_t expected_server_connection_id_length)
     : QuicServer(std::move(proof_source),
                  config,
                  QuicCryptoServerConfig::ConfigOptions(),
                  supported_versions,
                  quic_simple_server_backend,
-                 expected_connection_id_length) {}
+                 expected_server_connection_id_length) {}
 
 QuicDispatcher* QuicTestServer::CreateQuicDispatcher() {
   return new QuicTestDispatcher(
@@ -186,7 +186,7 @@
       std::unique_ptr<QuicCryptoServerStream::Helper>(
           new QuicSimpleCryptoServerStreamHelper(QuicRandom::GetInstance())),
       QuicMakeUnique<QuicEpollAlarmFactory>(epoll_server()), server_backend(),
-      expected_connection_id_length());
+      expected_server_connection_id_length());
 }
 
 void QuicTestServer::SetSessionFactory(SessionFactory* factory) {
diff --git a/quic/test_tools/quic_test_server.h b/quic/test_tools/quic_test_server.h
index 52fb7c5..3661b7a 100644
--- a/quic/test_tools/quic_test_server.h
+++ b/quic/test_tools/quic_test_server.h
@@ -69,7 +69,7 @@
                  const QuicConfig& config,
                  const ParsedQuicVersionVector& supported_versions,
                  QuicSimpleServerBackend* quic_simple_server_backend,
-                 uint8_t expected_connection_id_length);
+                 uint8_t expected_server_connection_id_length);
 
   // Create a custom dispatcher which creates custom sessions.
   QuicDispatcher* CreateQuicDispatcher() override;
diff --git a/quic/tools/quic_server.cc b/quic/tools/quic_server.cc
index 4ac1dac..3696b7c 100644
--- a/quic/tools/quic_server.cc
+++ b/quic/tools/quic_server.cc
@@ -64,7 +64,7 @@
     const QuicCryptoServerConfig::ConfigOptions& crypto_config_options,
     const ParsedQuicVersionVector& supported_versions,
     QuicSimpleServerBackend* quic_simple_server_backend,
-    uint8_t expected_connection_id_length)
+    uint8_t expected_server_connection_id_length)
     : port_(0),
       fd_(-1),
       packets_dropped_(0),
@@ -80,7 +80,8 @@
       version_manager_(supported_versions),
       packet_reader_(new QuicPacketReader()),
       quic_simple_server_backend_(quic_simple_server_backend),
-      expected_connection_id_length_(expected_connection_id_length) {
+      expected_server_connection_id_length_(
+          expected_server_connection_id_length) {
   DCHECK(quic_simple_server_backend_);
   Initialize();
 }
@@ -159,7 +160,7 @@
           new QuicSimpleCryptoServerStreamHelper(QuicRandom::GetInstance())),
       std::unique_ptr<QuicEpollAlarmFactory>(
           new QuicEpollAlarmFactory(&epoll_server_)),
-      quic_simple_server_backend_, expected_connection_id_length_);
+      quic_simple_server_backend_, expected_server_connection_id_length_);
 }
 
 void QuicServer::HandleEventsForever() {
diff --git a/quic/tools/quic_server.h b/quic/tools/quic_server.h
index 6fb1646..1f9c225 100644
--- a/quic/tools/quic_server.h
+++ b/quic/tools/quic_server.h
@@ -43,7 +43,7 @@
              const QuicCryptoServerConfig::ConfigOptions& server_config_options,
              const ParsedQuicVersionVector& supported_versions,
              QuicSimpleServerBackend* quic_simple_server_backend,
-             uint8_t expected_connection_id_length);
+             uint8_t expected_server_connection_id_length);
   QuicServer(const QuicServer&) = delete;
   QuicServer& operator=(const QuicServer&) = delete;
 
@@ -103,8 +103,8 @@
 
   void set_silent_close(bool value) { silent_close_ = value; }
 
-  uint8_t expected_connection_id_length() {
-    return expected_connection_id_length_;
+  uint8_t expected_server_connection_id_length() {
+    return expected_server_connection_id_length_;
   }
 
  private:
@@ -155,7 +155,7 @@
   QuicSimpleServerBackend* quic_simple_server_backend_;  // unowned.
 
   // Connection ID length expected to be read on incoming IETF short headers.
-  uint8_t expected_connection_id_length_;
+  uint8_t expected_server_connection_id_length_;
 };
 
 }  // namespace quic
diff --git a/quic/tools/quic_simple_dispatcher.cc b/quic/tools/quic_simple_dispatcher.cc
index 4706b60..0f4d447 100644
--- a/quic/tools/quic_simple_dispatcher.cc
+++ b/quic/tools/quic_simple_dispatcher.cc
@@ -16,14 +16,14 @@
     std::unique_ptr<QuicCryptoServerStream::Helper> session_helper,
     std::unique_ptr<QuicAlarmFactory> alarm_factory,
     QuicSimpleServerBackend* quic_simple_server_backend,
-    uint8_t expected_connection_id_length)
+    uint8_t expected_server_connection_id_length)
     : QuicDispatcher(config,
                      crypto_config,
                      version_manager,
                      std::move(helper),
                      std::move(session_helper),
                      std::move(alarm_factory),
-                     expected_connection_id_length),
+                     expected_server_connection_id_length),
       quic_simple_server_backend_(quic_simple_server_backend) {}
 
 QuicSimpleDispatcher::~QuicSimpleDispatcher() = default;
diff --git a/quic/tools/quic_simple_dispatcher.h b/quic/tools/quic_simple_dispatcher.h
index 46d976c..8a6cf85 100644
--- a/quic/tools/quic_simple_dispatcher.h
+++ b/quic/tools/quic_simple_dispatcher.h
@@ -21,7 +21,7 @@
       std::unique_ptr<QuicCryptoServerStream::Helper> session_helper,
       std::unique_ptr<QuicAlarmFactory> alarm_factory,
       QuicSimpleServerBackend* quic_simple_server_backend,
-      uint8_t expected_connection_id_length);
+      uint8_t expected_server_connection_id_length);
 
   ~QuicSimpleDispatcher() override;