gfe-relnote: In QuicPacketReader, use QuicClock::Now() instead of kernel provided systime for receive time. Protected by --gfe2_reloadable_flag_quic_use_quic_time_for_received_timestamp2.

PiperOrigin-RevId: 294963753
Change-Id: I1c06d6ea959570540543803e810479340b6d2af6
diff --git a/quic/core/quic_packet_reader.cc b/quic/core/quic_packet_reader.cc
index 95cc4e4..eed0bbd 100644
--- a/quic/core/quic_packet_reader.cc
+++ b/quic/core/quic_packet_reader.cc
@@ -99,6 +99,15 @@
         /*packet_buffer_length=*/sizeof(read_buffers_[i].packet_buffer));
   }
   QuicWallTime wallnow = clock.WallNow();
+  const bool use_quic_time =
+      GetQuicReloadableFlag(quic_use_quic_time_for_received_timestamp2);
+  QuicTime now = QuicTime::Zero();
+  if (use_quic_time) {
+    QUIC_RELOADABLE_FLAG_COUNT(quic_use_quic_time_for_received_timestamp2);
+    // Use clock.Now() as the packet receipt time, the time between packet
+    // arriving at the host and now is considered part of the network delay.
+    now = clock.Now();
+  }
   size_t packets_read = socket_api_.ReadMultiplePackets(
       fd,
       BitMask64(QuicUdpPacketInfoBit::DROPPED_PACKETS,
@@ -160,8 +169,9 @@
 
     QuicReceivedPacket packet(
         result.packet_buffer.buffer, result.packet_buffer.buffer_len,
-        clock.ConvertWallTimeToQuicTime(walltimestamp), /*owns_buffer=*/false,
-        ttl, has_ttl, headers, headers_length, /*owns_header_buffer=*/false);
+        use_quic_time ? now : clock.ConvertWallTimeToQuicTime(walltimestamp),
+        /*owns_buffer=*/false, ttl, has_ttl, headers, headers_length,
+        /*owns_header_buffer=*/false);
 
     QuicSocketAddress self_address(self_ip, port);
     processor->ProcessPacket(self_address, peer_address, packet);