Convert unnamed enums in third_party/quic to `constexpr` variables.

Modern C++ style prefers `constexpr` variables over unnamed enums
for defining compile-time constants. go/totw/140 This change replaces instances
of unnamed enums defining constants across QUIC
libraries with their `constexpr` equivalents.

Unnamed enums that were defined within classes were replaced with
`static constexpr` variables, those outside classes were replaced with
`inline constexpr` variables.

PiperOrigin-RevId: 927430549
diff --git a/quiche/quic/core/crypto/aead_base_encrypter.h b/quiche/quic/core/crypto/aead_base_encrypter.h
index ab1f5db..7580b4d 100644
--- a/quiche/quic/core/crypto/aead_base_encrypter.h
+++ b/quiche/quic/core/crypto/aead_base_encrypter.h
@@ -48,8 +48,8 @@
   // Make these constants available to the subclasses so that the subclasses
   // can assert at compile time their key_size_ and nonce_size_ do not
   // exceed the maximum.
-  static const size_t kMaxKeySize = 32;
-  enum : size_t { kMaxNonceSize = 12 };
+  static constexpr size_t kMaxKeySize = 32;
+  static constexpr size_t kMaxNonceSize = 12;
 
  private:
   const EVP_AEAD* const aead_alg_;
diff --git a/quiche/quic/core/crypto/aes_128_gcm_encrypter.h b/quiche/quic/core/crypto/aes_128_gcm_encrypter.h
index d36e0ea..6de1e81 100644
--- a/quiche/quic/core/crypto/aes_128_gcm_encrypter.h
+++ b/quiche/quic/core/crypto/aes_128_gcm_encrypter.h
@@ -17,9 +17,7 @@
 // that is XOR'd with the packet number to compute the nonce.
 class QUICHE_EXPORT Aes128GcmEncrypter : public AesBaseEncrypter {
  public:
-  enum {
-    kAuthTagSize = 16,
-  };
+  static constexpr size_t kAuthTagSize = 16;
 
   Aes128GcmEncrypter();
   Aes128GcmEncrypter(const Aes128GcmEncrypter&) = delete;
diff --git a/quiche/quic/core/crypto/aes_256_gcm_encrypter.h b/quiche/quic/core/crypto/aes_256_gcm_encrypter.h
index 0718077..e9bf3b9 100644
--- a/quiche/quic/core/crypto/aes_256_gcm_encrypter.h
+++ b/quiche/quic/core/crypto/aes_256_gcm_encrypter.h
@@ -17,9 +17,7 @@
 // that is XOR'd with the packet number to compute the nonce.
 class QUICHE_EXPORT Aes256GcmEncrypter : public AesBaseEncrypter {
  public:
-  enum {
-    kAuthTagSize = 16,
-  };
+  static constexpr size_t kAuthTagSize = 16;
 
   Aes256GcmEncrypter();
   Aes256GcmEncrypter(const Aes256GcmEncrypter&) = delete;
diff --git a/quiche/quic/core/crypto/p256_key_exchange.h b/quiche/quic/core/crypto/p256_key_exchange.h
index 2a3b80c..621630e 100644
--- a/quiche/quic/core/crypto/p256_key_exchange.h
+++ b/quiche/quic/core/crypto/p256_key_exchange.h
@@ -40,16 +40,14 @@
   QuicTag type() const override { return kP256; }
 
  private:
-  enum {
-    // A P-256 field element consists of 32 bytes.
-    kP256FieldBytes = 32,
-    // A P-256 point in uncompressed form consists of 0x04 (to denote
-    // that the point is uncompressed) followed by two, 32-byte field
-    // elements.
-    kUncompressedP256PointBytes = 1 + 2 * kP256FieldBytes,
-    // The first byte in an uncompressed P-256 point.
-    kUncompressedECPointForm = 0x04,
-  };
+  // A P-256 field element consists of 32 bytes.
+  static constexpr size_t kP256FieldBytes = 32;
+  // A P-256 point in uncompressed form consists of 0x04 (to denote
+  // that the point is uncompressed) followed by two, 32-byte field
+  // elements.
+  static constexpr size_t kUncompressedP256PointBytes = 1 + 2 * kP256FieldBytes;
+  // The first byte in an uncompressed P-256 point.
+  static constexpr size_t kUncompressedECPointForm = 0x04;
 
   // P256KeyExchange wraps |private_key|, and expects |public_key| consists of
   // |kUncompressedP256PointBytes| bytes.
diff --git a/quiche/quic/core/http/http_constants.h b/quiche/quic/core/http/http_constants.h
index 210fb4d..11e53be 100644
--- a/quiche/quic/core/http/http_constants.h
+++ b/quiche/quic/core/http/http_constants.h
@@ -15,19 +15,17 @@
 namespace quic {
 
 // Unidirectional stream types.
-enum : uint64_t {
-  // https://quicwg.org/base-drafts/draft-ietf-quic-http.html#unidirectional-streams
-  kControlStream = 0x00,
-  kServerPushStream = 0x01,
-  // https://quicwg.org/base-drafts/draft-ietf-quic-qpack.html#enc-dec-stream-def
-  kQpackEncoderStream = 0x02,
-  kQpackDecoderStream = 0x03,
-  // https://ietf-wg-webtrans.github.io/draft-ietf-webtrans-http3/draft-ietf-webtrans-http3.html#name-unidirectional-streams
-  kWebTransportUnidirectionalStream = 0x54,
-};
+// https://quicwg.org/base-drafts/draft-ietf-quic-http.html#unidirectional-streams
+inline constexpr uint64_t kControlStream = 0x00;
+inline constexpr uint64_t kServerPushStream = 0x01;
+// https://quicwg.org/base-drafts/draft-ietf-quic-qpack.html#enc-dec-stream-def
+inline constexpr uint64_t kQpackEncoderStream = 0x02;
+inline constexpr uint64_t kQpackDecoderStream = 0x03;
+// https://ietf-wg-webtrans.github.io/draft-ietf-webtrans-http3/draft-ietf-webtrans-http3.html#name-unidirectional-streams
+inline constexpr uint64_t kWebTransportUnidirectionalStream = 0x54;
 
 // This includes control stream, QPACK encoder stream, and QPACK decoder stream.
-enum : QuicStreamCount { kHttp3StaticUnidirectionalStreamCount = 3 };
+inline constexpr QuicStreamCount kHttp3StaticUnidirectionalStreamCount = 3;
 
 // HTTP/3 and QPACK settings identifiers.
 // https://quicwg.org/base-drafts/draft-ietf-quic-http.html#settings-parameters
@@ -56,19 +54,17 @@
 
 // Default maximum dynamic table capacity, communicated via
 // SETTINGS_QPACK_MAX_TABLE_CAPACITY.
-enum : QuicByteCount {
-  kDefaultQpackMaxDynamicTableCapacity = 64 * 1024  // 64 KB
-};
+inline constexpr QuicByteCount kDefaultQpackMaxDynamicTableCapacity =
+    64 * 1024;  // 64 KB
 
 // Default limit on the size of uncompressed headers,
 // communicated via SETTINGS_MAX_HEADER_LIST_SIZE.
-enum : QuicByteCount {
-  kDefaultMaxUncompressedHeaderSize = 16 * 1024  // 16 KB
-};
+inline constexpr QuicByteCount kDefaultMaxUncompressedHeaderSize =
+    16 * 1024;  // 16 KB
 
 // Default limit on number of blocked streams, communicated via
 // SETTINGS_QPACK_BLOCKED_STREAMS.
-enum : uint64_t { kDefaultMaximumBlockedStreams = 100 };
+inline constexpr uint64_t kDefaultMaximumBlockedStreams = 100;
 
 ABSL_CONST_INIT QUICHE_EXPORT extern const absl::string_view
     kUserAgentHeaderName;
diff --git a/quiche/quic/core/quic_types.h b/quiche/quic/core/quic_types.h
index 6b19dc0..7f5c2ef 100644
--- a/quiche/quic/core/quic_types.h
+++ b/quiche/quic/core/quic_types.h
@@ -50,7 +50,7 @@
 using DiversificationNonce = std::array<char, 32>;
 using PacketTimeVector = std::vector<std::pair<QuicPacketNumber, QuicTime>>;
 
-enum : size_t { kStatelessResetTokenLength = 16 };
+inline constexpr size_t kStatelessResetTokenLength = 16;
 using StatelessResetToken = std::array<char, kStatelessResetTokenLength>;
 
 // WebTransport session IDs are stream IDs.
@@ -60,7 +60,7 @@
 // WebTransport session error codes are 32-bit.
 using WebTransportSessionError = ::webtransport::SessionErrorCode;
 
-enum : size_t { kQuicPathFrameBufferSize = 8 };
+inline constexpr size_t kQuicPathFrameBufferSize = 8;
 using QuicPathFrameBuffer = std::array<uint8_t, kQuicPathFrameBufferSize>;
 
 // The connection id sequence number specifies the order that connection
diff --git a/quiche/quic/masque/masque_utils.h b/quiche/quic/masque/masque_utils.h
index 7b40490..db1524d 100644
--- a/quiche/quic/masque/masque_utils.h
+++ b/quiche/quic/masque/masque_utils.h
@@ -21,11 +21,9 @@
 // List of QUIC versions that support MASQUE. Currently restricted to IETF QUIC.
 QUIC_NO_EXPORT ParsedQuicVersionVector MasqueSupportedVersions();
 
-enum : QuicByteCount {
-  kMasqueIpPacketBufferSize = 1501,
-  // Enough for a VLAN tag, but not Stacked VLANs.
-  kMasqueEthernetFrameBufferSize = 1523,
-};
+inline constexpr QuicByteCount kMasqueIpPacketBufferSize = 1501;
+// Enough for a VLAN tag, but not Stacked VLANs.
+inline constexpr QuicByteCount kMasqueEthernetFrameBufferSize = 1523;
 
 // Mode that MASQUE is operating in.
 enum class MasqueMode : uint8_t {
diff --git a/quiche/quic/qbone/qbone_packet_processor.h b/quiche/quic/qbone/qbone_packet_processor.h
index 9f1030d..8cfc51f 100644
--- a/quiche/quic/qbone/qbone_packet_processor.h
+++ b/quiche/quic/qbone/qbone_packet_processor.h
@@ -20,11 +20,10 @@
 
 namespace quic {
 
-enum : size_t {
-  kIPv6HeaderSize = 40,
-  kICMPv6HeaderSize = sizeof(icmp6_hdr),
-  kTotalICMPv6HeaderSize = kIPv6HeaderSize + kICMPv6HeaderSize,
-};
+inline constexpr size_t kIPv6HeaderSize = 40;
+inline constexpr size_t kICMPv6HeaderSize = sizeof(icmp6_hdr);
+inline constexpr size_t kTotalICMPv6HeaderSize =
+    kIPv6HeaderSize + kICMPv6HeaderSize;
 
 // QBONE packet processor accepts packets destined in either direction
 // (client-to-network or network-to-client).  It inspects them and makes
diff --git a/quiche/quic/test_tools/quic_test_utils.h b/quiche/quic/test_tools/quic_test_utils.h
index 697c1a8..78cfe1f 100644
--- a/quiche/quic/test_tools/quic_test_utils.h
+++ b/quiche/quic/test_tools/quic_test_utils.h
@@ -73,20 +73,18 @@
 // Extracts the connection number passed to TestConnectionId().
 uint64_t TestConnectionIdToUInt64(QuicConnectionId connection_id);
 
-enum : uint16_t { kTestPort = 12345 };
-enum : uint32_t {
-  kMaxDatagramFrameSizeForTest = 1333,
-  kMaxPacketSizeForTest = 9001,
-  kInitialStreamFlowControlWindowForTest = 1024 * 1024,   // 1 MB
-  kInitialSessionFlowControlWindowForTest = 1536 * 1024,  // 1.5 MB
-};
+inline constexpr uint16_t kTestPort = 12345;
+inline constexpr uint32_t kMaxDatagramFrameSizeForTest = 1333;
+inline constexpr uint32_t kMaxPacketSizeForTest = 9001;
+inline constexpr uint32_t kInitialStreamFlowControlWindowForTest =
+    1024 * 1024;  // 1 MB
+inline constexpr uint32_t kInitialSessionFlowControlWindowForTest =
+    1536 * 1024;  // 1.5 MB
 
-enum : uint64_t {
-  kAckDelayExponentForTest = 10,
-  kMaxAckDelayForTest = 51,  // ms
-  kActiveConnectionIdLimitForTest = 52,
-  kMinAckDelayUsForTest = 1000
-};
+inline constexpr uint64_t kAckDelayExponentForTest = 10;
+inline constexpr uint64_t kMaxAckDelayForTest = 51;  // ms
+inline constexpr uint64_t kActiveConnectionIdLimitForTest = 52;
+inline constexpr uint64_t kMinAckDelayUsForTest = 1000;
 
 // Create an arbitrary stateless reset token, same across multiple calls.
 std::vector<uint8_t> CreateStatelessResetTokenForTest();
@@ -1768,9 +1766,7 @@
   }
 
  private:
-  enum {
-    kTagSize = 16,
-  };
+  static constexpr size_t kTagSize = 16;
 
   const uint8_t tag_;
 };
@@ -1831,9 +1827,7 @@
   }
 
  private:
-  enum {
-    kTagSize = 16,
-  };
+  static constexpr size_t kTagSize = 16;
 
   bool CheckTag(absl::string_view ciphertext, uint8_t tag);
 };