Log handshake completion time in quic_connection_stats. Logging only.

PiperOrigin-RevId: 327442793
Change-Id: I7fbacca9e8231178e004032b48c3f935e903cc56
diff --git a/quic/core/http/end_to_end_test.cc b/quic/core/http/end_to_end_test.cc
index 4eb856e..cfb7671 100644
--- a/quic/core/http/end_to_end_test.cc
+++ b/quic/core/http/end_to_end_test.cc
@@ -785,6 +785,8 @@
     }
     server_thread_->Resume();
   }
+  QuicConnectionStats client_stats = GetClientConnection()->GetStats();
+  EXPECT_TRUE(client_stats.handshake_completion_time.IsInitialized());
 }
 
 TEST_P(EndToEndTest, HandshakeConfirmed) {
diff --git a/quic/core/quic_connection_stats.h b/quic/core/quic_connection_stats.h
index a751f74..5a568e1 100644
--- a/quic/core/quic_connection_stats.h
+++ b/quic/core/quic_connection_stats.h
@@ -129,6 +129,9 @@
   // Creation time, as reported by the QuicClock.
   QuicTime connection_creation_time = QuicTime::Zero();
 
+  // Handshake completion time.
+  QuicTime handshake_completion_time = QuicTime::Zero();
+
   uint64_t blocked_frames_received = 0;
   uint64_t blocked_frames_sent = 0;
 
diff --git a/quic/core/quic_session.cc b/quic/core/quic_session.cc
index 4098764..0f43d2f 100644
--- a/quic/core/quic_session.cc
+++ b/quic/core/quic_session.cc
@@ -1590,6 +1590,8 @@
     case ENCRYPTION_FORWARD_SECURE:
       QUIC_BUG_IF(!config_.negotiated())
           << ENDPOINT << "Handshake confirmed without parameter negotiation.";
+      connection()->mutable_stats().handshake_completion_time =
+          connection()->clock()->ApproximateNow();
       break;
     default:
       QUIC_BUG << "Unknown encryption level: " << level;
@@ -1602,6 +1604,8 @@
       << ENDPOINT << "Handshake completes without cipher suite negotiation.";
   QUIC_BUG_IF(!config_.negotiated())
       << ENDPOINT << "Handshake completes without parameter negotiation.";
+  connection()->mutable_stats().handshake_completion_time =
+      connection()->clock()->ApproximateNow();
   if ((connection()->version().HasHandshakeDone() ||
        config_.PeerSupportsHandshakeDone()) &&
       perspective_ == Perspective::IS_SERVER) {