Use QuicVersionUsesCryptoFrames instead of checking against QUIC_VERSION_47

gfe-relnote: refactor QUIC_VERSION_47 checks. No behavior change
PiperOrigin-RevId: 237924704
Change-Id: Iaf70e71f64fbcc51f500e3919c2f026b146d7ab6
diff --git a/quic/core/chlo_extractor.cc b/quic/core/chlo_extractor.cc
index 15a118b..355ecd7 100644
--- a/quic/core/chlo_extractor.cc
+++ b/quic/core/chlo_extractor.cc
@@ -125,7 +125,7 @@
 }
 void ChloFramerVisitor::OnCoalescedPacket(const QuicEncryptedPacket& packet) {}
 bool ChloFramerVisitor::OnStreamFrame(const QuicStreamFrame& frame) {
-  if (framer_->transport_version() >= QUIC_VERSION_47) {
+  if (QuicVersionUsesCryptoFrames(framer_->transport_version())) {
     // CHLO will be sent in CRYPTO frames in v47 and above.
     return false;
   }
@@ -139,7 +139,7 @@
 }
 
 bool ChloFramerVisitor::OnCryptoFrame(const QuicCryptoFrame& frame) {
-  if (framer_->transport_version() < QUIC_VERSION_47) {
+  if (!QuicVersionUsesCryptoFrames(framer_->transport_version())) {
     // CHLO will be in stream frames before v47.
     return false;
   }
diff --git a/quic/core/chlo_extractor_test.cc b/quic/core/chlo_extractor_test.cc
index cb5fd59..57be311 100644
--- a/quic/core/chlo_extractor_test.cc
+++ b/quic/core/chlo_extractor_test.cc
@@ -70,7 +70,8 @@
     }
     QuicFramer framer(SupportedVersions(header_.version), QuicTime::Zero(),
                       Perspective::IS_CLIENT, kQuicDefaultConnectionIdLength);
-    if (version.transport_version < QUIC_VERSION_47 || munge_stream_id) {
+    if (!QuicVersionUsesCryptoFrames(version.transport_version) ||
+        munge_stream_id) {
       QuicStreamId stream_id =
           QuicUtils::GetCryptoStreamId(version.transport_version);
       if (munge_stream_id) {
diff --git a/quic/core/http/end_to_end_test.cc b/quic/core/http/end_to_end_test.cc
index d439e95..61b6834 100644
--- a/quic/core/http/end_to_end_test.cc
+++ b/quic/core/http/end_to_end_test.cc
@@ -148,7 +148,7 @@
   ParsedQuicVersionVector version_buckets[3];
 
   for (const ParsedQuicVersion& version : all_supported_versions) {
-    if (version.transport_version < QUIC_VERSION_47) {
+    if (!QuicVersionUsesCryptoFrames(version.transport_version)) {
       version_buckets[0].push_back(version);
     } else if (version.handshake_protocol == PROTOCOL_QUIC_CRYPTO) {
       version_buckets[1].push_back(version);
@@ -2023,8 +2023,10 @@
       client_->client()->client_session());
   // In v47 and later, the crypto handshake (sent in CRYPTO frames) is not
   // subject to flow control.
-  if (client_->client()->client_session()->connection()->transport_version() <
-      QUIC_VERSION_47) {
+  if (!QuicVersionUsesCryptoFrames(client_->client()
+                                       ->client_session()
+                                       ->connection()
+                                       ->transport_version())) {
     EXPECT_LT(QuicFlowControllerPeer::SendWindowSize(
                   crypto_stream->flow_controller()),
               kStreamIFCW);
diff --git a/quic/core/http/quic_spdy_session_test.cc b/quic/core/http/quic_spdy_session_test.cc
index 1087493..a6dc96b 100644
--- a/quic/core/http/quic_spdy_session_test.cc
+++ b/quic/core/http/quic_spdy_session_test.cc
@@ -1109,7 +1109,7 @@
 
 TEST_P(QuicSpdySessionTestServer,
        HandshakeUnblocksFlowControlBlockedCryptoStream) {
-  if (GetParam().transport_version >= QUIC_VERSION_47) {
+  if (QuicVersionUsesCryptoFrames(GetParam().transport_version)) {
     // QUIC version 47 onwards uses CRYPTO frames for the handshake, so this
     // test doesn't make sense for those versions.
     return;
@@ -1664,13 +1664,13 @@
 
   // Lost data on cryption stream, streams 2 and 4.
   EXPECT_CALL(*stream4, HasPendingRetransmission()).WillOnce(Return(true));
-  if (connection_->transport_version() < QUIC_VERSION_47) {
+  if (!QuicVersionUsesCryptoFrames(connection_->transport_version())) {
     EXPECT_CALL(*crypto_stream, HasPendingRetransmission())
         .WillOnce(Return(true));
   }
   EXPECT_CALL(*stream2, HasPendingRetransmission()).WillOnce(Return(true));
   session_.OnFrameLost(QuicFrame(frame3));
-  if (connection_->transport_version() < QUIC_VERSION_47) {
+  if (!QuicVersionUsesCryptoFrames(connection_->transport_version())) {
     session_.OnFrameLost(QuicFrame(frame1));
   } else {
     QuicCryptoFrame crypto_frame(ENCRYPTION_NONE, 0, 1300);
@@ -1687,7 +1687,7 @@
   // stream go first.
   // Do not check congestion window when crypto stream has lost data.
   EXPECT_CALL(*send_algorithm, CanSend(_)).Times(0);
-  if (connection_->transport_version() < QUIC_VERSION_47) {
+  if (!QuicVersionUsesCryptoFrames(connection_->transport_version())) {
     EXPECT_CALL(*crypto_stream, OnCanWrite());
     EXPECT_CALL(*crypto_stream, HasPendingRetransmission())
         .WillOnce(Return(false));
diff --git a/quic/core/quic_connection_test.cc b/quic/core/quic_connection_test.cc
index f991355..afa9512 100644
--- a/quic/core/quic_connection_test.cc
+++ b/quic/core/quic_connection_test.cc
@@ -645,7 +645,7 @@
   QuicConsumedData SendCryptoStreamData() {
     QuicStreamOffset offset = 0;
     QuicStringPiece data("chlo");
-    if (transport_version() < QUIC_VERSION_47) {
+    if (!QuicVersionUsesCryptoFrames(transport_version())) {
       return SendStreamDataWithString(
           QuicUtils::GetCryptoStreamId(transport_version()), data, offset,
           NO_FIN);
@@ -2676,7 +2676,7 @@
   // Parse the last packet and ensure it's the crypto stream frame.
   EXPECT_EQ(2u, writer_->frame_count());
   ASSERT_EQ(1u, writer_->padding_frames().size());
-  if (connection_.transport_version() < QUIC_VERSION_47) {
+  if (!QuicVersionUsesCryptoFrames(connection_.transport_version())) {
     ASSERT_EQ(1u, writer_->stream_frames().size());
     EXPECT_EQ(QuicUtils::GetCryptoStreamId(connection_.transport_version()),
               writer_->stream_frames()[0]->stream_id);
@@ -5913,7 +5913,7 @@
     EXPECT_EQ(4u, writer_->frame_count());
     EXPECT_FALSE(writer_->stop_waiting_frames().empty());
   }
-  if (connection_.transport_version() < QUIC_VERSION_47) {
+  if (!QuicVersionUsesCryptoFrames(connection_.transport_version())) {
     EXPECT_EQ(1u, writer_->stream_frames().size());
   } else {
     EXPECT_EQ(1u, writer_->crypto_frames().size());
@@ -5946,7 +5946,7 @@
     EXPECT_EQ(4u, writer_->frame_count());
     EXPECT_FALSE(writer_->stop_waiting_frames().empty());
   }
-  if (connection_.transport_version() < QUIC_VERSION_47) {
+  if (!QuicVersionUsesCryptoFrames(connection_.transport_version())) {
     EXPECT_EQ(1u, writer_->stream_frames().size());
   } else {
     EXPECT_EQ(1u, writer_->crypto_frames().size());
diff --git a/quic/core/quic_crypto_server_handshaker.cc b/quic/core/quic_crypto_server_handshaker.cc
index fb24fed..0d16354 100644
--- a/quic/core/quic_crypto_server_handshaker.cc
+++ b/quic/core/quic_crypto_server_handshaker.cc
@@ -310,7 +310,7 @@
 
   QUIC_DVLOG(1) << "Server: Sending server config update: "
                 << message.DebugString();
-  if (transport_version() < QUIC_VERSION_47) {
+  if (!QuicVersionUsesCryptoFrames(transport_version())) {
     const QuicData& data = message.GetSerialized();
     stream_->WriteOrBufferData(QuicStringPiece(data.data(), data.length()),
                                false, nullptr);
diff --git a/quic/core/quic_crypto_stream.cc b/quic/core/quic_crypto_stream.cc
index 6a941e7..c09f08a 100644
--- a/quic/core/quic_crypto_stream.cc
+++ b/quic/core/quic_crypto_stream.cc
@@ -54,14 +54,16 @@
 }
 
 void QuicCryptoStream::OnCryptoFrame(const QuicCryptoFrame& frame) {
-  QUIC_BUG_IF(session()->connection()->transport_version() < QUIC_VERSION_47)
+  QUIC_BUG_IF(!QuicVersionUsesCryptoFrames(
+      session()->connection()->transport_version()))
       << "Versions less than 47 shouldn't receive CRYPTO frames";
   EncryptionLevel level = session()->connection()->last_decrypted_level();
   substreams_[level].sequencer.OnCryptoFrame(frame);
 }
 
 void QuicCryptoStream::OnStreamFrame(const QuicStreamFrame& frame) {
-  if (session()->connection()->transport_version() >= QUIC_VERSION_47) {
+  if (QuicVersionUsesCryptoFrames(
+          session()->connection()->transport_version())) {
     QUIC_PEER_BUG
         << "Crypto data received in stream frame instead of crypto frame";
     CloseConnectionWithDetails(QUIC_INVALID_STREAM_DATA,
@@ -72,7 +74,8 @@
 
 void QuicCryptoStream::OnDataAvailable() {
   EncryptionLevel level = session()->connection()->last_decrypted_level();
-  if (session()->connection()->transport_version() < QUIC_VERSION_47) {
+  if (!QuicVersionUsesCryptoFrames(
+          session()->connection()->transport_version())) {
     // Versions less than 47 only support QUIC crypto, which ignores the
     // EncryptionLevel passed into CryptoMessageParser::ProcessInput (and
     // OnDataAvailableInSequencer).
@@ -120,7 +123,8 @@
 
 void QuicCryptoStream::WriteCryptoData(EncryptionLevel level,
                                        QuicStringPiece data) {
-  if (session()->connection()->transport_version() < QUIC_VERSION_47) {
+  if (!QuicVersionUsesCryptoFrames(
+          session()->connection()->transport_version())) {
     // The QUIC crypto handshake takes care of setting the appropriate
     // encryption level before writing data. Since that is the only handshake
     // supported in versions less than 47, |level| can be ignored here.
@@ -170,7 +174,8 @@
 }
 
 void QuicCryptoStream::NeuterUnencryptedStreamData() {
-  if (session()->connection()->transport_version() < QUIC_VERSION_47) {
+  if (!QuicVersionUsesCryptoFrames(
+          session()->connection()->transport_version())) {
     for (const auto& interval : bytes_consumed_[ENCRYPTION_NONE]) {
       QuicByteCount newly_acked_length = 0;
       send_buffer().OnStreamDataAcked(
@@ -191,7 +196,8 @@
 }
 
 void QuicCryptoStream::OnStreamDataConsumed(size_t bytes_consumed) {
-  if (session()->connection()->transport_version() >= QUIC_VERSION_47) {
+  if (QuicVersionUsesCryptoFrames(
+          session()->connection()->transport_version())) {
     QUIC_BUG << "Stream data consumed when CRYPTO frames should be in use";
   }
   if (bytes_consumed > 0) {
@@ -202,7 +208,8 @@
 }
 
 bool QuicCryptoStream::HasPendingCryptoRetransmission() {
-  if (session()->connection()->transport_version() < QUIC_VERSION_47) {
+  if (!QuicVersionUsesCryptoFrames(
+          session()->connection()->transport_version())) {
     return false;
   }
   for (EncryptionLevel level :
@@ -215,7 +222,8 @@
 }
 
 void QuicCryptoStream::WritePendingCryptoRetransmission() {
-  QUIC_BUG_IF(session()->connection()->transport_version() < QUIC_VERSION_47)
+  QUIC_BUG_IF(!QuicVersionUsesCryptoFrames(
+      session()->connection()->transport_version()))
       << "Versions less than 47 don't write CRYPTO frames";
   EncryptionLevel current_encryption_level =
       session()->connection()->encryption_level();
@@ -323,7 +331,8 @@
 }
 
 uint64_t QuicCryptoStream::crypto_bytes_read() const {
-  if (session()->connection()->transport_version() < QUIC_VERSION_47) {
+  if (!QuicVersionUsesCryptoFrames(
+          session()->connection()->transport_version())) {
     return stream_bytes_read();
   }
   return substreams_[ENCRYPTION_NONE].sequencer.NumBytesConsumed() +
@@ -339,21 +348,24 @@
                                         QuicStreamOffset offset,
                                         QuicByteCount data_length,
                                         QuicDataWriter* writer) {
-  QUIC_BUG_IF(session()->connection()->transport_version() < QUIC_VERSION_47)
+  QUIC_BUG_IF(!QuicVersionUsesCryptoFrames(
+      session()->connection()->transport_version()))
       << "Versions less than 47 don't write CRYPTO frames (2)";
   return substreams_[level].send_buffer.WriteStreamData(offset, data_length,
                                                         writer);
 }
 
 void QuicCryptoStream::OnCryptoFrameLost(QuicCryptoFrame* crypto_frame) {
-  QUIC_BUG_IF(session()->connection()->transport_version() < QUIC_VERSION_47)
+  QUIC_BUG_IF(!QuicVersionUsesCryptoFrames(
+      session()->connection()->transport_version()))
       << "Versions less than 47 don't lose CRYPTO frames";
   substreams_[crypto_frame->level].send_buffer.OnStreamDataLost(
       crypto_frame->offset, crypto_frame->data_length);
 }
 
 void QuicCryptoStream::RetransmitData(QuicCryptoFrame* crypto_frame) {
-  QUIC_BUG_IF(session()->connection()->transport_version() < QUIC_VERSION_47)
+  QUIC_BUG_IF(!QuicVersionUsesCryptoFrames(
+      session()->connection()->transport_version()))
       << "Versions less than 47 don't retransmit CRYPTO frames";
   QuicIntervalSet<QuicStreamOffset> retransmission(
       crypto_frame->offset, crypto_frame->offset + crypto_frame->data_length);
@@ -380,7 +392,8 @@
 bool QuicCryptoStream::IsFrameOutstanding(EncryptionLevel level,
                                           size_t offset,
                                           size_t length) const {
-  if (session()->connection()->transport_version() < QUIC_VERSION_47) {
+  if (!QuicVersionUsesCryptoFrames(
+          session()->connection()->transport_version())) {
     // This only happens if a client was originally configured for a version
     // greater than 45, but received a version negotiation packet and is
     // attempting to retransmit for a version less than 47. Outside of tests,
@@ -393,7 +406,8 @@
 }
 
 bool QuicCryptoStream::IsWaitingForAcks() const {
-  if (session()->connection()->transport_version() < QUIC_VERSION_47) {
+  if (!QuicVersionUsesCryptoFrames(
+          session()->connection()->transport_version())) {
     return QuicStream::IsWaitingForAcks();
   }
   for (EncryptionLevel level :
diff --git a/quic/core/quic_crypto_stream_test.cc b/quic/core/quic_crypto_stream_test.cc
index 263910b..a33b986 100644
--- a/quic/core/quic_crypto_stream_test.cc
+++ b/quic/core/quic_crypto_stream_test.cc
@@ -100,7 +100,7 @@
 }
 
 TEST_F(QuicCryptoStreamTest, ProcessRawData) {
-  if (connection_->transport_version() < QUIC_VERSION_47) {
+  if (!QuicVersionUsesCryptoFrames(connection_->transport_version())) {
     stream_->OnStreamFrame(QuicStreamFrame(
         QuicUtils::GetCryptoStreamId(connection_->transport_version()),
         /*fin=*/false,
@@ -127,7 +127,7 @@
 
   EXPECT_CALL(*connection_, CloseConnection(QUIC_CRYPTO_TAGS_OUT_OF_ORDER,
                                             testing::_, testing::_));
-  if (connection_->transport_version() < QUIC_VERSION_47) {
+  if (!QuicVersionUsesCryptoFrames(connection_->transport_version())) {
     stream_->OnStreamFrame(QuicStreamFrame(
         QuicUtils::GetCryptoStreamId(connection_->transport_version()),
         /*fin=*/false, /*offset=*/0, bad));
@@ -142,7 +142,7 @@
 }
 
 TEST_F(QuicCryptoStreamTest, RetransmitCryptoData) {
-  if (connection_->transport_version() >= QUIC_VERSION_47) {
+  if (QuicVersionUsesCryptoFrames(connection_->transport_version())) {
     return;
   }
   InSequence s;
@@ -201,7 +201,7 @@
 }
 
 TEST_F(QuicCryptoStreamTest, RetransmitCryptoDataInCryptoFrames) {
-  if (connection_->transport_version() < QUIC_VERSION_47) {
+  if (!QuicVersionUsesCryptoFrames(connection_->transport_version())) {
     return;
   }
   EXPECT_CALL(*connection_, SendCryptoData(_, _, _)).Times(0);
@@ -253,7 +253,7 @@
 }
 
 TEST_F(QuicCryptoStreamTest, NeuterUnencryptedStreamData) {
-  if (connection_->transport_version() >= QUIC_VERSION_47) {
+  if (QuicVersionUsesCryptoFrames(connection_->transport_version())) {
     return;
   }
   // Send [0, 1350) in ENCRYPTION_NONE.
@@ -295,7 +295,7 @@
 }
 
 TEST_F(QuicCryptoStreamTest, NeuterUnencryptedCryptoData) {
-  if (connection_->transport_version() < QUIC_VERSION_47) {
+  if (!QuicVersionUsesCryptoFrames(connection_->transport_version())) {
     return;
   }
   // Send [0, 1350) in ENCRYPTION_NONE.
@@ -338,7 +338,7 @@
 }
 
 TEST_F(QuicCryptoStreamTest, RetransmitStreamData) {
-  if (connection_->transport_version() >= QUIC_VERSION_47) {
+  if (QuicVersionUsesCryptoFrames(connection_->transport_version())) {
     return;
   }
   InSequence s;
@@ -411,7 +411,7 @@
 }
 
 TEST_F(QuicCryptoStreamTest, RetransmitStreamDataWithCryptoFrames) {
-  if (connection_->transport_version() < QUIC_VERSION_47) {
+  if (!QuicVersionUsesCryptoFrames(connection_->transport_version())) {
     return;
   }
   InSequence s;
@@ -470,7 +470,7 @@
 
 // Regression test for b/115926584.
 TEST_F(QuicCryptoStreamTest, HasUnackedCryptoData) {
-  if (connection_->transport_version() >= QUIC_VERSION_47) {
+  if (QuicVersionUsesCryptoFrames(connection_->transport_version())) {
     return;
   }
   std::string data(1350, 'a');
@@ -499,7 +499,7 @@
 }
 
 TEST_F(QuicCryptoStreamTest, HasUnackedCryptoDataWithCryptoFrames) {
-  if (connection_->transport_version() < QUIC_VERSION_47) {
+  if (!QuicVersionUsesCryptoFrames(connection_->transport_version())) {
     return;
   }
   // Send [0, 1350) in ENCRYPTION_NONE.
diff --git a/quic/core/quic_dispatcher.cc b/quic/core/quic_dispatcher.cc
index ce95320..c6b1c09 100644
--- a/quic/core/quic_dispatcher.cc
+++ b/quic/core/quic_dispatcher.cc
@@ -161,7 +161,7 @@
     collector_.SaveStatelessRejectFrameData(reject);
     while (offset < reject.length()) {
       QuicFrame frame;
-      if (framer_->transport_version() < QUIC_VERSION_47) {
+      if (!QuicVersionUsesCryptoFrames(framer_->transport_version())) {
         if (!creator_.ConsumeData(
                 QuicUtils::GetCryptoStreamId(framer_->transport_version()),
                 reject.length(), offset, offset,
diff --git a/quic/core/quic_dispatcher_test.cc b/quic/core/quic_dispatcher_test.cc
index c744505..1e7fb51 100644
--- a/quic/core/quic_dispatcher_test.cc
+++ b/quic/core/quic_dispatcher_test.cc
@@ -373,7 +373,8 @@
 };
 
 TEST_F(QuicDispatcherTest, TlsClientHelloCreatesSession) {
-  if (CurrentSupportedVersions().front().transport_version < QUIC_VERSION_47) {
+  if (!QuicVersionUsesCryptoFrames(
+          CurrentSupportedVersions().front().transport_version)) {
     // TLS is only supported in versions 47 and greater.
     return;
   }
diff --git a/quic/core/quic_framer.cc b/quic/core/quic_framer.cc
index 32d50c5..6505cb0 100644
--- a/quic/core/quic_framer.cc
+++ b/quic/core/quic_framer.cc
@@ -1043,7 +1043,7 @@
         }
         break;
       case CRYPTO_FRAME:
-        if (version_.transport_version < QUIC_VERSION_47) {
+        if (!QuicVersionUsesCryptoFrames(version_.transport_version)) {
           set_detailed_error(
               "Attempt to append CRYPTO frame in version prior to 47.");
           return RaiseError(QUIC_INTERNAL_ERROR);
@@ -2804,7 +2804,7 @@
         break;
       }
       case CRYPTO_FRAME: {
-        if (version_.transport_version < QUIC_VERSION_47) {
+        if (!QuicVersionUsesCryptoFrames(version_.transport_version)) {
           set_detailed_error("Illegal frame type.");
           return RaiseError(QUIC_INVALID_FRAME_DATA);
         }
diff --git a/quic/core/quic_framer_test.cc b/quic/core/quic_framer_test.cc
index c848c0a..4d2a179 100644
--- a/quic/core/quic_framer_test.cc
+++ b/quic/core/quic_framer_test.cc
@@ -9640,7 +9640,7 @@
   EXPECT_CALL(visitor, OnDecryptedPacket(_)).Times(1);
   EXPECT_CALL(visitor, OnError(_)).Times(0);
   EXPECT_CALL(visitor, OnStreamFrame(_)).Times(0);
-  if (framer_.version().transport_version < QUIC_VERSION_47) {
+  if (!QuicVersionUsesCryptoFrames(framer_.version().transport_version)) {
     EXPECT_CALL(visitor, OnStreamFrame(Truly(ExpectedStreamFrame))).Times(1);
   } else {
     EXPECT_CALL(visitor, OnCryptoFrame(_)).Times(1);
diff --git a/quic/core/quic_session.cc b/quic/core/quic_session.cc
index 151fa18..98e4f4e 100644
--- a/quic/core/quic_session.cc
+++ b/quic/core/quic_session.cc
@@ -1517,7 +1517,8 @@
   QuicConnection::ScopedPacketFlusher retransmission_flusher(
       connection_, QuicConnection::SEND_ACK_IF_QUEUED);
   // Retransmit crypto data first.
-  bool uses_crypto_frames = connection_->transport_version() >= QUIC_VERSION_47;
+  bool uses_crypto_frames =
+      QuicVersionUsesCryptoFrames(connection_->transport_version());
   QuicCryptoStream* crypto_stream = GetMutableCryptoStream();
   if (uses_crypto_frames && crypto_stream->HasPendingCryptoRetransmission()) {
     SetTransmissionType(HANDSHAKE_RETRANSMISSION);
diff --git a/quic/core/quic_session_test.cc b/quic/core/quic_session_test.cc
index fba914f..6c516c6 100644
--- a/quic/core/quic_session_test.cc
+++ b/quic/core/quic_session_test.cc
@@ -1240,7 +1240,7 @@
 }
 
 TEST_P(QuicSessionTestServer, HandshakeUnblocksFlowControlBlockedCryptoStream) {
-  if (GetParam().transport_version >= QUIC_VERSION_47) {
+  if (QuicVersionUsesCryptoFrames(GetParam().transport_version)) {
     // QUIC version 47 onwards uses CRYPTO frames for the handshake, so this
     // test doesn't make sense for those versions since CRYPTO frames aren't
     // flow controlled.
@@ -1809,13 +1809,13 @@
 
   // Lost data on cryption stream, streams 2 and 4.
   EXPECT_CALL(*stream4, HasPendingRetransmission()).WillOnce(Return(true));
-  if (connection_->transport_version() < QUIC_VERSION_47) {
+  if (!QuicVersionUsesCryptoFrames(connection_->transport_version())) {
     EXPECT_CALL(*crypto_stream, HasPendingRetransmission())
         .WillOnce(Return(true));
   }
   EXPECT_CALL(*stream2, HasPendingRetransmission()).WillOnce(Return(true));
   session_.OnFrameLost(QuicFrame(frame3));
-  if (connection_->transport_version() < QUIC_VERSION_47) {
+  if (!QuicVersionUsesCryptoFrames(connection_->transport_version())) {
     session_.OnFrameLost(QuicFrame(frame1));
   } else {
     QuicCryptoFrame crypto_frame(ENCRYPTION_NONE, 0, 1300);
@@ -1832,7 +1832,7 @@
   // stream go first.
   // Do not check congestion window when crypto stream has lost data.
   EXPECT_CALL(*send_algorithm, CanSend(_)).Times(0);
-  if (connection_->transport_version() < QUIC_VERSION_47) {
+  if (!QuicVersionUsesCryptoFrames(connection_->transport_version())) {
     EXPECT_CALL(*crypto_stream, OnCanWrite());
     EXPECT_CALL(*crypto_stream, HasPendingRetransmission())
         .WillOnce(Return(false));
diff --git a/quic/core/quic_utils.cc b/quic/core/quic_utils.cc
index 10854bf..0ec92ac 100644
--- a/quic/core/quic_utils.cc
+++ b/quic/core/quic_utils.cc
@@ -317,7 +317,7 @@
 // static
 bool QuicUtils::IsHandshakeFrame(const QuicFrame& frame,
                                  QuicTransportVersion transport_version) {
-  if (transport_version < QUIC_VERSION_47) {
+  if (!QuicVersionUsesCryptoFrames(transport_version)) {
     return frame.type == STREAM_FRAME &&
            frame.stream_frame.stream_id == GetCryptoStreamId(transport_version);
   } else {
diff --git a/quic/core/quic_versions.cc b/quic/core/quic_versions.cc
index 7ea441a..df85e16 100644
--- a/quic/core/quic_versions.cc
+++ b/quic/core/quic_versions.cc
@@ -119,7 +119,8 @@
       continue;
     }
     for (QuicTransportVersion version : kSupportedTransportVersions) {
-      if (protocol == PROTOCOL_TLS1_3 && version < QUIC_VERSION_47) {
+      if (protocol == PROTOCOL_TLS1_3 &&
+          !QuicVersionUsesCryptoFrames(version)) {
         // The TLS handshake is only deployable if CRYPTO frames are also used,
         // which are added in v47.
         continue;
diff --git a/quic/core/quic_versions.h b/quic/core/quic_versions.h
index 2825c9f..9682bd1 100644
--- a/quic/core/quic_versions.h
+++ b/quic/core/quic_versions.h
@@ -341,6 +341,13 @@
   return transport_version == QUIC_VERSION_99;
 }
 
+// Returns whether |transport_version| uses CRYPTO frames for the handshake
+// instead of stream 1.
+QUIC_EXPORT_PRIVATE inline bool QuicVersionUsesCryptoFrames(
+    QuicTransportVersion transport_version) {
+  return transport_version >= QUIC_VERSION_47;
+}
+
 }  // namespace quic
 
 #endif  // QUICHE_QUIC_CORE_QUIC_VERSIONS_H_