Track GOAWAY in MasqueConnectionPool responses

PiperOrigin-RevId: 934418444
diff --git a/quiche/quic/masque/masque_connection_pool.cc b/quiche/quic/masque/masque_connection_pool.cc
index 4818af8..666e95f 100644
--- a/quiche/quic/masque/masque_connection_pool.cc
+++ b/quiche/quic/masque/masque_connection_pool.cc
@@ -295,6 +295,7 @@
       Message response;
       response.headers = headers.Clone();
       response.body = body;
+      response.draining = connection->draining();
       if (end_stream) {
         pending_request.response_done = true;
       }
diff --git a/quiche/quic/masque/masque_connection_pool.h b/quiche/quic/masque/masque_connection_pool.h
index 24faf65..a169890 100644
--- a/quiche/quic/masque/masque_connection_pool.h
+++ b/quiche/quic/masque/masque_connection_pool.h
@@ -32,6 +32,7 @@
   struct Message {
     quiche::HttpHeaderBlock headers;
     std::string body;
+    bool draining = false;  // Sent on responses received after low GOAWAY.
   };
 
   // Returns the HTTP status code from the message, or 0 if not available.
diff --git a/quiche/quic/masque/masque_h2_connection.cc b/quiche/quic/masque/masque_h2_connection.cc
index 8413215..e0cdb39 100644
--- a/quiche/quic/masque/masque_h2_connection.cc
+++ b/quiche/quic/masque/masque_h2_connection.cc
@@ -384,6 +384,9 @@
                      body.size(), ", headers: ", headers.DebugString())));
     return -1;
   }
+  if (stream_id > highest_stream_id_) {
+    highest_stream_id_ = stream_id;
+  }
   QUICHE_LOG(INFO) << ENDPOINT << "Sending request on stream ID " << stream_id
                    << " with body of length " << body.size()
                    << ", headers: " << headers.DebugString();
@@ -556,6 +559,9 @@
                    << last_accepted_stream_id
                    << " error_code: " << Http2ErrorCodeToString(error_code)
                    << " opaque_data length: " << opaque_data.size();
+  if (last_accepted_stream_id <= highest_stream_id_) {
+    draining_ = true;
+  }
   for (auto it = h2_streams_.begin(); it != h2_streams_.end();) {
     if (it->first > last_accepted_stream_id) {
       if (!it->second->callback_fired) {
diff --git a/quiche/quic/masque/masque_h2_connection.h b/quiche/quic/masque/masque_h2_connection.h
index 1a93e0b..8d01bec 100644
--- a/quiche/quic/masque/masque_h2_connection.h
+++ b/quiche/quic/masque/masque_h2_connection.h
@@ -66,6 +66,7 @@
   ~MasqueH2Connection();
 
   bool aborted() const { return !error_.ok() || has_closed_gracefully_; }
+  bool draining() const { return draining_; }
   // Call when there is more data to be read from SSL.
   void OnTransportReadable();
   // Call when there is more data to be written to SSL.
@@ -163,6 +164,8 @@
       h2_streams_;
   Visitor* visitor_;
   std::string tls_write_buffer_;
+  Http2StreamId highest_stream_id_ = 0;
+  bool draining_ = false;
 };
 
 // Formats an SSL error that was provided by BoringSSL.