Put Google QUIC Connection Close code in the extracted code field

When processing Google QUIC Connection Close frames, place a copy
of the close code into the QuicConnectionCloseFrame::extracted_error_code
field. In this way, as we migrate through a hybrid Google/IETF QUIC
implementation, the Google QUIC close code is always available in
this field, regardless of the QUIC type in use.  This does not change
the existing code's placement of the error code in
QuicConnectionCloseFrame::quic_error_code.

gfe-relnote: N/A, part of a revision of the ConnectionCloseFrame in an earlier CL.
PiperOrigin-RevId: 262114442
Change-Id: Iaa472c1e040dd7de4d5b6a3c2484d5aad1408413
diff --git a/quic/core/frames/quic_connection_close_frame.h b/quic/core/frames/quic_connection_close_frame.h
index aba67b9..fd8baf1 100644
--- a/quic/core/frames/quic_connection_close_frame.h
+++ b/quic/core/frames/quic_connection_close_frame.h
@@ -64,9 +64,10 @@
     QuicErrorCode quic_error_code;
   };
 
-  // This error code is extracted from, or added to, the "QuicErrorCode:
-  // QUIC_...(123)" text in the error_details. It provides fine-grained
-  // information as to the source of the error.
+  // For IETF QUIC frames, this is the error code is extracted from, or added
+  // to, the error details text. For received Google QUIC frames, the Google
+  // QUIC error code from the frame's error code field is copied here (as well
+  // as in quic_error_code, above).
   QuicErrorCode extracted_error_code;
 
   // String with additional error details. "QuicErrorCode: 123" will be appended
diff --git a/quic/core/quic_framer.cc b/quic/core/quic_framer.cc
index ea9d9f5..13669d9 100644
--- a/quic/core/quic_framer.cc
+++ b/quic/core/quic_framer.cc
@@ -4032,6 +4032,11 @@
 
   frame->quic_error_code = static_cast<QuicErrorCode>(error_code);
 
+  // For Google QUIC connection closes, copy the Google QUIC error code to
+  // the extracted error code field so that the Google QUIC error code is always
+  // available in extracted_error_code.
+  frame->extracted_error_code = frame->quic_error_code;
+
   QuicStringPiece error_details;
   if (!reader->ReadStringPiece16(&error_details)) {
     set_detailed_error("Unable to read connection close error details.");
diff --git a/quic/core/quic_framer_test.cc b/quic/core/quic_framer_test.cc
index 99864ad..2c04be8 100644
--- a/quic/core/quic_framer_test.cc
+++ b/quic/core/quic_framer_test.cc
@@ -4889,6 +4889,12 @@
               visitor_.connection_close_frame_.transport_close_frame_type);
     EXPECT_EQ(QUIC_IETF_GQUIC_ERROR_MISSING,
               visitor_.connection_close_frame_.extracted_error_code);
+  } else {
+    // For Google QUIC closes, the error code is copied into
+    // extracted_error_code.
+    EXPECT_EQ(0x11u,
+              static_cast<unsigned>(
+                  visitor_.connection_close_frame_.extracted_error_code));
   }
 
   ASSERT_EQ(0u, visitor_.ack_frames_.size());
@@ -5050,8 +5056,7 @@
               visitor_.connection_close_frame_.transport_close_frame_type);
     EXPECT_EQ(17767u, visitor_.connection_close_frame_.extracted_error_code);
   } else {
-    // QUIC_IETF_GQUIC_ERROR_MISSING is 122
-    EXPECT_EQ(122u, visitor_.connection_close_frame_.extracted_error_code);
+    EXPECT_EQ(0x11u, visitor_.connection_close_frame_.extracted_error_code);
   }
 
   ASSERT_EQ(0u, visitor_.ack_frames_.size());