gfe-relnote: Let GFE be able to use LIFO write scheduler in QUIC and enable it via a connection option LIFO. Protected by gfe2_reloadable_flag_quic_use_lifo_write_scheduler.

PiperOrigin-RevId: 261741584
Change-Id: I2db660dd8a9e2eb40b70147ea829825a8f45404e
diff --git a/quic/core/crypto/crypto_protocol.h b/quic/core/crypto/crypto_protocol.h
index 0facf00..bbd0b18 100644
--- a/quic/core/crypto/crypto_protocol.h
+++ b/quic/core/crypto/crypto_protocol.h
@@ -201,6 +201,8 @@
 const QuicTag kH2PR = TAG('H', '2', 'P', 'R');  // HTTP2 priorities.
 const QuicTag kFIFO = TAG('F', 'I', 'F', 'O');  // Stream with the smallest ID
                                                 // has the highest priority.
+const QuicTag kLIFO = TAG('L', 'I', 'F', 'O');  // Stream with the largest ID
+                                                // has the highest priority.
 
 // Proof types (i.e. certificate types)
 // NOTE: although it would be silly to do so, specifying both kX509 and kX59R
diff --git a/quic/core/http/end_to_end_test.cc b/quic/core/http/end_to_end_test.cc
index 2e79f78..750f371 100644
--- a/quic/core/http/end_to_end_test.cc
+++ b/quic/core/http/end_to_end_test.cc
@@ -158,7 +158,7 @@
         continue;
       }
       for (const QuicTag priority_tag :
-           {/*no tag*/ static_cast<QuicTag>(0), kH2PR, kFIFO}) {
+           {/*no tag*/ static_cast<QuicTag>(0), kH2PR, kFIFO, kLIFO}) {
         // Add an entry for server and client supporting all versions.
         params.push_back(TestParams(client_versions, all_supported_versions,
                                     client_versions.front(),
diff --git a/quic/core/quic_session.cc b/quic/core/quic_session.cc
index e39fd41..fe65bc3 100644
--- a/quic/core/quic_session.cc
+++ b/quic/core/quic_session.cc
@@ -1014,6 +1014,14 @@
                 connection_->transport_version())) {
           QUIC_RELOADABLE_FLAG_COUNT(quic_enable_fifo_write_scheduler);
         }
+      } else if (GetQuicReloadableFlag(quic_enable_lifo_write_scheduler) &&
+                 ContainsQuicTag(config_.ReceivedConnectionOptions(), kLIFO)) {
+        // Enable LIFO write scheduler.
+        if (write_blocked_streams_.SwitchWriteScheduler(
+                spdy::WriteSchedulerType::LIFO,
+                connection_->transport_version())) {
+          QUIC_RELOADABLE_FLAG_COUNT(quic_enable_lifo_write_scheduler);
+        }
       }
     }
 
diff --git a/quic/core/quic_write_blocked_list.h b/quic/core/quic_write_blocked_list.h
index dd9ddb4..72ebc05 100644
--- a/quic/core/quic_write_blocked_list.h
+++ b/quic/core/quic_write_blocked_list.h
@@ -16,6 +16,7 @@
 #include "net/third_party/quiche/src/quic/platform/api/quic_ptr_util.h"
 #include "net/third_party/quiche/src/spdy/core/fifo_write_scheduler.h"
 #include "net/third_party/quiche/src/spdy/core/http2_priority_write_scheduler.h"
+#include "net/third_party/quiche/src/spdy/core/lifo_write_scheduler.h"
 #include "net/third_party/quiche/src/spdy/core/priority_write_scheduler.h"
 
 namespace quic {
@@ -79,6 +80,10 @@
     QUIC_DVLOG(1) << "Switching to scheduler type: "
                   << spdy::WriteSchedulerTypeToString(type);
     switch (type) {
+      case spdy::WriteSchedulerType::LIFO:
+        priority_write_scheduler_ =
+            QuicMakeUnique<spdy::LifoWriteScheduler<QuicStreamId>>();
+        break;
       case spdy::WriteSchedulerType::SPDY:
         priority_write_scheduler_ =
             QuicMakeUnique<spdy::PriorityWriteScheduler<QuicStreamId>>(
@@ -209,6 +214,8 @@
   bool PrecedenceMatchesSchedulerType(
       const spdy::SpdyStreamPrecedence& precedence) {
     switch (scheduler_type_) {
+      case spdy::WriteSchedulerType::LIFO:
+        break;
       case spdy::WriteSchedulerType::SPDY:
         return precedence.is_spdy3_priority();
       case spdy::WriteSchedulerType::HTTP2: