Support building QUIC with GCE target constraint.

Most of this works by making GCE builds use the cross-platform polyfills we already use for platforms like Android.

This amends the *_BUG macros, and includes the SimpleEpollServer from
third_party/epoll_server instead of the internal one. Many other changes
are required to bring the portable google3 tests and flags up to
compilation.

Protected by gfe changes are build-only compatibility declarations.

PiperOrigin-RevId: 366069092
Change-Id: Ia5cf90f9f37e592536a1be830679a0cae9ae2eb7
diff --git a/common/platform/api/quiche_bug_tracker.h b/common/platform/api/quiche_bug_tracker.h
new file mode 100644
index 0000000..0e8e456
--- /dev/null
+++ b/common/platform/api/quiche_bug_tracker.h
@@ -0,0 +1,15 @@
+// Copyright (c) 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef QUICHE_COMMON_PLATFORM_API_QUICHE_BUG_TRACKER_H_
+#define QUICHE_COMMON_PLATFORM_API_QUICHE_BUG_TRACKER_H_
+
+#include "net/quiche/common/platform/impl/quiche_bug_tracker_impl.h"
+
+#define QUICHE_BUG QUICHE_BUG_IMPL
+#define QUICHE_BUG_IF QUICHE_BUG_IF_IMPL
+#define QUICHE_PEER_BUG QUICHE_PEER_BUG_IMPL
+#define QUICHE_PEER_BUG_IF QUICHE_PEER_BUG_IF_IMPL
+
+#endif  // QUICHE_COMMON_PLATFORM_API_QUICHE_BUG_TRACKER_H_
diff --git a/common/platform/api/quiche_logging.h b/common/platform/api/quiche_logging.h
index e3278eb..940d492 100644
--- a/common/platform/api/quiche_logging.h
+++ b/common/platform/api/quiche_logging.h
@@ -40,6 +40,7 @@
 #define QUICHE_LOG_ERROR_IS_ON() QUICHE_LOG_ERROR_IS_ON_IMPL()
 
 #define QUICHE_CHECK(condition) QUICHE_CHECK_IMPL(condition)
+#define QUICHE_CHECK_OK(condition) QUICHE_CHECK_OK_IMPL(condition)
 #define QUICHE_CHECK_EQ(val1, val2) QUICHE_CHECK_EQ_IMPL(val1, val2)
 #define QUICHE_CHECK_NE(val1, val2) QUICHE_CHECK_NE_IMPL(val1, val2)
 #define QUICHE_CHECK_LE(val1, val2) QUICHE_CHECK_LE_IMPL(val1, val2)
diff --git a/epoll_server/simple_epoll_server.h b/epoll_server/simple_epoll_server.h
index d2d3683..85b3a08 100644
--- a/epoll_server/simple_epoll_server.h
+++ b/epoll_server/simple_epoll_server.h
@@ -487,6 +487,7 @@
   // Summary:
   // Returns true when the SimpleEpollServer() is being destroyed.
   bool in_shutdown() const { return in_shutdown_; }
+  bool ShutdownCalled() const { return in_shutdown(); }
 
   // Compatibility stub.
   void Shutdown() {}
diff --git a/http2/decoder/payload_decoders/payload_decoder_base_test_util.h b/http2/decoder/payload_decoders/payload_decoder_base_test_util.h
index 464b0cb..feea5e5 100644
--- a/http2/decoder/payload_decoders/payload_decoder_base_test_util.h
+++ b/http2/decoder/payload_decoders/payload_decoder_base_test_util.h
@@ -385,7 +385,7 @@
     auto& listener = listener_;
     Validator validator =
         [header, expected_missing_length, &listener](
-            const DecodeBuffer& input,
+            const DecodeBuffer&,
             DecodeStatus status) -> ::testing::AssertionResult {
       VERIFY_EQ(DecodeStatus::kDecodeError, status);
       VERIFY_FALSE(listener.IsInProgress());
diff --git a/http2/hpack/decoder/hpack_decoder_state_test.cc b/http2/hpack/decoder/hpack_decoder_state_test.cc
index 43332b1..698c655 100644
--- a/http2/hpack/decoder/hpack_decoder_state_test.cc
+++ b/http2/hpack/decoder/hpack_decoder_state_test.cc
@@ -35,10 +35,12 @@
 
 class MockHpackDecoderListener : public HpackDecoderListener {
  public:
-  MOCK_METHOD0(OnHeaderListStart, void());
-  MOCK_METHOD2(OnHeader,
-               void(const std::string& name, const std::string& value));
-  MOCK_METHOD0(OnHeaderListEnd, void());
+  MOCK_METHOD(void, OnHeaderListStart, (), (override));
+  MOCK_METHOD(void,
+              OnHeader,
+              (const std::string& name, const std::string& value),
+              (override));
+  MOCK_METHOD(void, OnHeaderListEnd, (), (override));
   MOCK_METHOD(void,
               OnHeaderErrorDetected,
               (absl::string_view error_message),
diff --git a/http2/hpack/decoder/hpack_decoder_test.cc b/http2/hpack/decoder/hpack_decoder_test.cc
index 355940d..ce44ccb 100644
--- a/http2/hpack/decoder/hpack_decoder_test.cc
+++ b/http2/hpack/decoder/hpack_decoder_test.cc
@@ -62,10 +62,12 @@
 // and with VerifyDynamicTableContents.
 class MockHpackDecoderListener : public HpackDecoderListener {
  public:
-  MOCK_METHOD0(OnHeaderListStart, void());
-  MOCK_METHOD2(OnHeader,
-               void(const std::string& name, const std::string& value));
-  MOCK_METHOD0(OnHeaderListEnd, void());
+  MOCK_METHOD(void, OnHeaderListStart, (), (override));
+  MOCK_METHOD(void,
+              OnHeader,
+              (const std::string& name, const std::string& value),
+              (override));
+  MOCK_METHOD(void, OnHeaderListEnd, (), (override));
   MOCK_METHOD(void,
               OnHeaderErrorDetected,
               (absl::string_view error_message),
diff --git a/http2/platform/api/http2_bug_tracker.h b/http2/platform/api/http2_bug_tracker.h
index 53d8688..6f2fe51 100644
--- a/http2/platform/api/http2_bug_tracker.h
+++ b/http2/platform/api/http2_bug_tracker.h
@@ -5,10 +5,15 @@
 #ifndef QUICHE_HTTP2_PLATFORM_API_HTTP2_BUG_TRACKER_H_
 #define QUICHE_HTTP2_PLATFORM_API_HTTP2_BUG_TRACKER_H_
 
-#include "net/http2/platform/impl/http2_bug_tracker_impl.h"
+#include "common/platform/api/quiche_bug_tracker.h"
 
-#define HTTP2_BUG HTTP2_BUG_IMPL
-#define HTTP2_BUG_IF HTTP2_BUG_IF_IMPL
+#define HTTP2_BUG QUICHE_BUG
+#define HTTP2_BUG_IF QUICHE_BUG_IF
+
+// V2 macros are the same as all the HTTP2_BUG flavor above, but they take a
+// bug_id parameter.
+#define HTTP2_BUG_V2 QUICHE_BUG
+#define HTTP2_BUG_IF_V2 QUICHE_BUG_IF
 
 #define FLAGS_http2_always_log_bugs_for_tests \
   FLAGS_http2_always_log_bugs_for_tests_IMPL
diff --git a/quic/core/crypto/transport_parameters_test.cc b/quic/core/crypto/transport_parameters_test.cc
index 3d23ae6..81707c5 100644
--- a/quic/core/crypto/transport_parameters_test.cc
+++ b/quic/core/crypto/transport_parameters_test.cc
@@ -448,7 +448,7 @@
   orig_params.max_udp_payload_size.set_value(kMaxPacketSizeForTest);
 
   std::vector<uint8_t> out;
-  bool ok;
+  bool ok = true;
   EXPECT_QUIC_BUG(
       ok = SerializeTransportParameters(version_, orig_params, &out),
       "Not serializing invalid transport parameters: Client cannot send "
diff --git a/quic/core/http/end_to_end_test.cc b/quic/core/http/end_to_end_test.cc
index 6138269..3ac82a4 100644
--- a/quic/core/http/end_to_end_test.cc
+++ b/quic/core/http/end_to_end_test.cc
@@ -4512,7 +4512,7 @@
 
   if (version_.UsesTls()) {
     // TODO(b/154162689) add PSK support to QUIC+TLS.
-    bool ok;
+    bool ok = true;
     EXPECT_QUIC_BUG(ok = Initialize(),
                     "QUIC client pre-shared keys not yet supported with TLS");
     EXPECT_FALSE(ok);
@@ -4535,7 +4535,7 @@
 
   if (version_.UsesTls()) {
     // TODO(b/154162689) add PSK support to QUIC+TLS.
-    bool ok;
+    bool ok = true;
     EXPECT_QUIC_BUG(ok = Initialize(),
                     "QUIC client pre-shared keys not yet supported with TLS");
     EXPECT_FALSE(ok);
@@ -4562,7 +4562,7 @@
 
   if (version_.UsesTls()) {
     // TODO(b/154162689) add PSK support to QUIC+TLS.
-    bool ok;
+    bool ok = true;
     EXPECT_QUIC_BUG(ok = Initialize(),
                     "QUIC server pre-shared keys not yet supported with TLS");
     EXPECT_FALSE(ok);
@@ -4583,7 +4583,7 @@
 
   if (version_.UsesTls()) {
     // TODO(b/154162689) add PSK support to QUIC+TLS.
-    bool ok;
+    bool ok = true;
     EXPECT_QUIC_BUG(ok = Initialize(),
                     "QUIC client pre-shared keys not yet supported with TLS");
     EXPECT_FALSE(ok);
diff --git a/quic/core/quic_udp_socket_test.cc b/quic/core/quic_udp_socket_test.cc
deleted file mode 100644
index 400c38e..0000000
--- a/quic/core/quic_udp_socket_test.cc
+++ /dev/null
@@ -1,439 +0,0 @@
-// Copyright 2019 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "quic/core/quic_udp_socket.h"
-#include <sys/socket.h>
-
-#ifdef __APPLE__
-#include <TargetConditionals.h>
-#endif
-
-#include "quic/core/quic_constants.h"
-#include "quic/platform/api/quic_test.h"
-
-namespace quic {
-namespace test {
-namespace {
-// Used by ReadMultiplePackets tests.
-struct ReadBuffers {
-  char control_buffer[512];
-  char packet_buffer[1536];
-};
-
-// Allows IPv6-specific testing.
-struct TestParameters {
-  // If true, the test will only use IPv6.  If false, IPv4 will be used if
-  // possible, with IPv6 used as a fallback.
-  bool force_ipv6;
-  // The value of ipv6_only to be used in QuicUdpSocketApi::Create calls.
-  bool ipv6_only;
-};
-}  // namespace
-
-class QuicUdpSocketTest : public QuicTestWithParam<TestParameters> {
- protected:
-  void SetUp() override {
-    const TestParameters& parameters = GetParam();
-    if (!parameters.force_ipv6) {
-      // Try creating AF_INET socket, if it fails because of unsupported address
-      // family then tests are being run under IPv6-only environment, initialize
-      // address family to use for running the test under as AF_INET6 otherwise
-      // initialize it as AF_INET.
-      address_family_ = AF_INET;
-      fd_client_ =
-          api_.Create(address_family_,
-                      /*receive_buffer_size =*/kDefaultSocketReceiveBuffer,
-                      /*send_buffer_size =*/kDefaultSocketReceiveBuffer,
-                      /*ipv6_only =*/parameters.ipv6_only);
-    }
-    if (fd_client_ == kQuicInvalidSocketFd) {
-      // Either AF_INET is unsupported, or force_ipv6 is true.
-      address_family_ = AF_INET6;
-      fd_client_ =
-          api_.Create(address_family_,
-                      /*receive_buffer_size =*/kDefaultSocketReceiveBuffer,
-                      /*send_buffer_size =*/kDefaultSocketReceiveBuffer,
-                      /*ipv6_only =*/parameters.ipv6_only);
-    }
-    ASSERT_NE(fd_client_, kQuicInvalidSocketFd);
-
-    fd_server_ =
-        api_.Create(address_family_,
-                    /*receive_buffer_size =*/kDefaultSocketReceiveBuffer,
-                    /*send_buffer_size =*/kDefaultSocketReceiveBuffer,
-                    /*ipv6_only =*/parameters.ipv6_only);
-    ASSERT_NE(fd_server_, kQuicInvalidSocketFd);
-
-    ASSERT_TRUE(
-        api_.Bind(fd_server_, QuicSocketAddress(Loopback(), /*port=*/0)));
-
-    ASSERT_EQ(0, server_address_.FromSocket(fd_server_));
-
-    QUIC_LOG(INFO) << "Testing under IP"
-                   << std::string((address_family_ == AF_INET) ? "v4" : "v6");
-  }
-
-  ~QuicUdpSocketTest() {
-    api_.Destroy(fd_client_);
-    api_.Destroy(fd_server_);
-  }
-
-  QuicIpAddress Loopback() const {
-    return (address_family_ == AF_INET) ? QuicIpAddress::Loopback4()
-                                        : QuicIpAddress::Loopback6();
-  }
-
-  // Client sends the first |packet_size| bytes in |client_packet_buffer_| to
-  // server.
-  WriteResult SendPacketFromClient(size_t packet_size) {
-    EXPECT_LE(packet_size, sizeof(client_packet_buffer_));
-    QuicUdpPacketInfo packet_info;
-    packet_info.SetPeerAddress(server_address_);
-    return api_.WritePacket(fd_client_, client_packet_buffer_, packet_size,
-                            packet_info);
-  }
-
-  WriteResult SendPacketFromClientWithTtl(size_t packet_size, int ttl) {
-    EXPECT_LE(packet_size, sizeof(client_packet_buffer_));
-    QuicUdpPacketInfo packet_info;
-    packet_info.SetPeerAddress(server_address_);
-    packet_info.SetTtl(ttl);
-    return api_.WritePacket(fd_client_, client_packet_buffer_, packet_size,
-                            packet_info);
-  }
-
-  // Server waits for an incoming packet and reads it into
-  // |server_packet_buffer_|.
-  QuicUdpSocketApi::ReadPacketResult ReadPacketFromServer(
-      BitMask64 packet_info_interested) {
-    EXPECT_TRUE(
-        api_.WaitUntilReadable(fd_server_, QuicTime::Delta::FromSeconds(5)));
-    memset(server_packet_buffer_, 0, sizeof(server_packet_buffer_));
-    QuicUdpSocketApi::ReadPacketResult result;
-    result.packet_buffer = {server_packet_buffer_,
-                            sizeof(server_packet_buffer_)};
-    result.control_buffer = {server_control_buffer_,
-                             sizeof(server_control_buffer_)};
-    api_.ReadPacket(fd_server_, packet_info_interested, &result);
-    return result;
-  }
-
-  int ComparePacketBuffers(size_t packet_size) {
-    return memcmp(client_packet_buffer_, server_packet_buffer_, packet_size);
-  }
-
-  bool VerifyBufferIsFilledWith(const char* buffer,
-                                size_t buffer_length,
-                                char c) {
-    for (size_t i = 0; i < buffer_length; ++i) {
-      if (buffer[i] != c) {
-        return false;
-      }
-    }
-    return true;
-  }
-
-  QuicUdpSocketApi api_;
-  QuicUdpSocketFd fd_client_ = kQuicInvalidSocketFd;
-  QuicUdpSocketFd fd_server_ = kQuicInvalidSocketFd;
-  QuicSocketAddress server_address_;
-  int address_family_;
-  char client_packet_buffer_[kEthernetMTU] = {0};
-  char server_packet_buffer_[kDefaultMaxPacketSize] = {0};
-  char server_control_buffer_[512] = {0};
-};
-
-INSTANTIATE_TEST_SUITE_P(
-    PlatformIndependent,
-    QuicUdpSocketTest,
-    testing::Values(TestParameters{/*force_ipv6 =*/false, /*ipv6_only =*/false},
-                    TestParameters{/*force_ipv6 =*/false, /*ipv6_only =*/true},
-                    TestParameters{/*force_ipv6 =*/true, /*ipv6_only =*/true}));
-
-#ifndef TARGET_OS_IPHONE
-// IPv6 on iOS is known to fail without ipv6_only, so should not be tested.
-INSTANTIATE_TEST_SUITE_P(NonIos,
-                         QuicUdpSocketTest,
-                         testing::Values(TestParameters{/*force_ipv6 =*/true,
-                                                        /*ipv6_only =*/false}));
-#endif
-
-TEST_P(QuicUdpSocketTest, ReadPacketResultReset) {
-  QuicUdpSocketApi::ReadPacketResult result;
-  result.packet_info.SetDroppedPackets(100);
-  result.packet_buffer.buffer_len = 100;
-  result.ok = true;
-
-  result.Reset(/*packet_buffer_length=*/200);
-
-  EXPECT_FALSE(result.ok);
-  EXPECT_FALSE(
-      result.packet_info.HasValue(QuicUdpPacketInfoBit::DROPPED_PACKETS));
-  EXPECT_EQ(200u, result.packet_buffer.buffer_len);
-}
-
-TEST_P(QuicUdpSocketTest, ReadPacketOnly) {
-  const size_t kPacketSize = 512;
-  memset(client_packet_buffer_, '-', kPacketSize);
-  ASSERT_EQ(WriteResult(WRITE_STATUS_OK, kPacketSize),
-            SendPacketFromClient(kPacketSize));
-
-  QuicUdpSocketApi::ReadPacketResult read_result =
-      ReadPacketFromServer(/*packet_info_interested=*/BitMask64());
-  ASSERT_TRUE(read_result.ok);
-  ASSERT_EQ(kPacketSize, read_result.packet_buffer.buffer_len);
-  ASSERT_EQ(0, ComparePacketBuffers(kPacketSize));
-}
-
-TEST_P(QuicUdpSocketTest, ReadTruncated) {
-  const size_t kPacketSize = kDefaultMaxPacketSize + 1;
-  memset(client_packet_buffer_, '*', kPacketSize);
-  ASSERT_EQ(WriteResult(WRITE_STATUS_OK, kPacketSize),
-            SendPacketFromClient(kPacketSize));
-
-  QuicUdpSocketApi::ReadPacketResult read_result =
-      ReadPacketFromServer(/*packet_info_interested=*/BitMask64());
-  ASSERT_FALSE(read_result.ok);
-}
-
-TEST_P(QuicUdpSocketTest, ReadDroppedPackets) {
-  const size_t kPacketSize = kDefaultMaxPacketSize;
-  memset(client_packet_buffer_, '-', kPacketSize);
-  ASSERT_EQ(WriteResult(WRITE_STATUS_OK, kPacketSize),
-            SendPacketFromClient(kPacketSize));
-  ASSERT_EQ(WriteResult(WRITE_STATUS_OK, kPacketSize),
-            SendPacketFromClient(kPacketSize));
-
-  // Read the first packet without enabling DROPPED_PACKETS.
-  QuicUdpSocketApi::ReadPacketResult read_result =
-      ReadPacketFromServer(BitMask64(QuicUdpPacketInfoBit::DROPPED_PACKETS));
-  ASSERT_TRUE(read_result.ok);
-  ASSERT_EQ(kPacketSize, read_result.packet_buffer.buffer_len);
-  ASSERT_EQ(0, ComparePacketBuffers(kPacketSize));
-  ASSERT_FALSE(
-      read_result.packet_info.HasValue(QuicUdpPacketInfoBit::DROPPED_PACKETS));
-
-  // Enable DROPPED_PACKETS and read the second packet.
-  if (!api_.EnableDroppedPacketCount(fd_server_)) {
-    QUIC_LOG(INFO) << "DROPPED_PACKETS is not supported";
-    return;
-  }
-  read_result =
-      ReadPacketFromServer(BitMask64(QuicUdpPacketInfoBit::DROPPED_PACKETS));
-  ASSERT_TRUE(read_result.ok);
-  ASSERT_EQ(kPacketSize, read_result.packet_buffer.buffer_len);
-  ASSERT_EQ(0, ComparePacketBuffers(kPacketSize));
-  if (read_result.packet_info.HasValue(QuicUdpPacketInfoBit::DROPPED_PACKETS)) {
-    EXPECT_EQ(0u, read_result.packet_info.dropped_packets());
-  }
-}
-
-TEST_P(QuicUdpSocketTest, ReadSelfIp) {
-  const QuicUdpPacketInfoBit self_ip_bit =
-      (address_family_ == AF_INET) ? QuicUdpPacketInfoBit::V4_SELF_IP
-                                   : QuicUdpPacketInfoBit::V6_SELF_IP;
-
-  const size_t kPacketSize = 512;
-  memset(client_packet_buffer_, '&', kPacketSize);
-  ASSERT_EQ(WriteResult(WRITE_STATUS_OK, kPacketSize),
-            SendPacketFromClient(kPacketSize));
-
-  QuicUdpSocketApi::ReadPacketResult read_result =
-      ReadPacketFromServer(BitMask64(self_ip_bit));
-  ASSERT_TRUE(read_result.ok);
-  ASSERT_EQ(kPacketSize, read_result.packet_buffer.buffer_len);
-  ASSERT_EQ(0, ComparePacketBuffers(kPacketSize));
-  ASSERT_TRUE(read_result.packet_info.HasValue(self_ip_bit));
-  EXPECT_EQ(Loopback(), (address_family_ == AF_INET)
-                            ? read_result.packet_info.self_v4_ip()
-                            : read_result.packet_info.self_v6_ip());
-}
-
-TEST_P(QuicUdpSocketTest, ReadReceiveTimestamp) {
-  const size_t kPacketSize = kDefaultMaxPacketSize;
-  memset(client_packet_buffer_, '-', kPacketSize);
-  ASSERT_EQ(WriteResult(WRITE_STATUS_OK, kPacketSize),
-            SendPacketFromClient(kPacketSize));
-  ASSERT_EQ(WriteResult(WRITE_STATUS_OK, kPacketSize),
-            SendPacketFromClient(kPacketSize));
-
-  // Read the first packet without enabling RECV_TIMESTAMP.
-  QuicUdpSocketApi::ReadPacketResult read_result =
-      ReadPacketFromServer(BitMask64(QuicUdpPacketInfoBit::RECV_TIMESTAMP));
-  ASSERT_TRUE(read_result.ok);
-  ASSERT_EQ(kPacketSize, read_result.packet_buffer.buffer_len);
-  ASSERT_EQ(0, ComparePacketBuffers(kPacketSize));
-  ASSERT_FALSE(
-      read_result.packet_info.HasValue(QuicUdpPacketInfoBit::RECV_TIMESTAMP));
-
-  // Enable RECV_TIMESTAMP and read the second packet.
-  if (!api_.EnableReceiveTimestamp(fd_server_)) {
-    QUIC_LOG(INFO) << "RECV_TIMESTAMP is not supported";
-    return;
-  }
-  read_result =
-      ReadPacketFromServer(BitMask64(QuicUdpPacketInfoBit::RECV_TIMESTAMP));
-  ASSERT_TRUE(read_result.ok);
-  ASSERT_EQ(kPacketSize, read_result.packet_buffer.buffer_len);
-  ASSERT_EQ(0, ComparePacketBuffers(kPacketSize));
-  ASSERT_TRUE(
-      read_result.packet_info.HasValue(QuicUdpPacketInfoBit::RECV_TIMESTAMP));
-  QuicWallTime recv_timestamp = read_result.packet_info.receive_timestamp();
-  // 1577836800 is the unix seconds for 2020-01-01
-  EXPECT_TRUE(
-      QuicWallTime::FromUNIXSeconds(1577836800).IsBefore(recv_timestamp));
-}
-
-TEST_P(QuicUdpSocketTest, Ttl) {
-  const size_t kPacketSize = 512;
-  memset(client_packet_buffer_, '$', kPacketSize);
-  ASSERT_EQ(WriteResult(WRITE_STATUS_OK, kPacketSize),
-            SendPacketFromClientWithTtl(kPacketSize, 13));
-  ASSERT_EQ(WriteResult(WRITE_STATUS_OK, kPacketSize),
-            SendPacketFromClientWithTtl(kPacketSize, 13));
-
-  // Read the first packet without enabling ttl reporting.
-  QuicUdpSocketApi::ReadPacketResult read_result =
-      ReadPacketFromServer(BitMask64(QuicUdpPacketInfoBit::TTL));
-  ASSERT_TRUE(read_result.ok);
-  ASSERT_EQ(kPacketSize, read_result.packet_buffer.buffer_len);
-  ASSERT_EQ(0, ComparePacketBuffers(kPacketSize));
-  ASSERT_FALSE(read_result.packet_info.HasValue(QuicUdpPacketInfoBit::TTL));
-
-  // Enable ttl reporting and read the second packet.
-  if (!((address_family_ == AF_INET)
-            ? api_.EnableReceiveTtlForV4(fd_server_)
-            : api_.EnableReceiveTtlForV6(fd_server_))) {
-    QUIC_LOG(INFO) << "TTL is not supported for address family "
-                   << address_family_;
-    return;
-  }
-
-  read_result = ReadPacketFromServer(BitMask64(QuicUdpPacketInfoBit::TTL));
-  ASSERT_TRUE(read_result.ok);
-  ASSERT_EQ(kPacketSize, read_result.packet_buffer.buffer_len);
-  ASSERT_EQ(0, ComparePacketBuffers(kPacketSize));
-  ASSERT_TRUE(read_result.packet_info.HasValue(QuicUdpPacketInfoBit::TTL));
-  EXPECT_EQ(13, read_result.packet_info.ttl());
-}
-
-TEST_P(QuicUdpSocketTest, ReadMultiplePackets) {
-  const QuicUdpPacketInfoBit self_ip_bit =
-      (address_family_ == AF_INET) ? QuicUdpPacketInfoBit::V4_SELF_IP
-                                   : QuicUdpPacketInfoBit::V6_SELF_IP;
-  const size_t kPacketSize = kDefaultMaxPacketSize;
-  const size_t kNumPackets = 90;
-  for (size_t i = 0; i < kNumPackets; ++i) {
-    memset(client_packet_buffer_, ' ' + i, kPacketSize);
-    ASSERT_EQ(WriteResult(WRITE_STATUS_OK, kPacketSize),
-              SendPacketFromClient(kPacketSize));
-  }
-
-  const size_t kNumPacketsPerRead = 16;
-  size_t total_packets_read = 0;
-  while (total_packets_read < kNumPackets) {
-    std::unique_ptr<ReadBuffers[]> read_buffers =
-        std::make_unique<ReadBuffers[]>(kNumPacketsPerRead);
-    QuicUdpSocketApi::ReadPacketResults results(kNumPacketsPerRead);
-    for (size_t i = 0; i < kNumPacketsPerRead; ++i) {
-      results[i].packet_buffer.buffer = read_buffers[i].packet_buffer;
-      results[i].packet_buffer.buffer_len =
-          sizeof(read_buffers[i].packet_buffer);
-
-      results[i].control_buffer.buffer = read_buffers[i].control_buffer;
-      results[i].control_buffer.buffer_len =
-          sizeof(read_buffers[i].control_buffer);
-    }
-    size_t packets_read =
-        api_.ReadMultiplePackets(fd_server_, BitMask64(self_ip_bit), &results);
-    if (packets_read == 0) {
-      ASSERT_TRUE(
-          api_.WaitUntilReadable(fd_server_, QuicTime::Delta::FromSeconds(5)));
-      packets_read = api_.ReadMultiplePackets(fd_server_,
-                                              BitMask64(self_ip_bit), &results);
-      ASSERT_GT(packets_read, 0u);
-    }
-
-    for (size_t i = 0; i < packets_read; ++i) {
-      const auto& result = results[i];
-      ASSERT_TRUE(result.ok);
-      ASSERT_EQ(kPacketSize, result.packet_buffer.buffer_len);
-      ASSERT_TRUE(VerifyBufferIsFilledWith(result.packet_buffer.buffer,
-                                           result.packet_buffer.buffer_len,
-                                           ' ' + total_packets_read));
-      ASSERT_TRUE(result.packet_info.HasValue(self_ip_bit));
-      EXPECT_EQ(Loopback(), (address_family_ == AF_INET)
-                                ? result.packet_info.self_v4_ip()
-                                : result.packet_info.self_v6_ip());
-      total_packets_read++;
-    }
-  }
-}
-
-TEST_P(QuicUdpSocketTest, ReadMultiplePacketsSomeTruncated) {
-  const QuicUdpPacketInfoBit self_ip_bit =
-      (address_family_ == AF_INET) ? QuicUdpPacketInfoBit::V4_SELF_IP
-                                   : QuicUdpPacketInfoBit::V6_SELF_IP;
-  const size_t kPacketSize = kDefaultMaxPacketSize;
-  const size_t kNumPackets = 90;
-  for (size_t i = 0; i < kNumPackets; ++i) {
-    memset(client_packet_buffer_, ' ' + i, kPacketSize);
-    ASSERT_EQ(WriteResult(WRITE_STATUS_OK, kPacketSize),
-              SendPacketFromClient(kPacketSize));
-  }
-
-  const size_t kNumPacketsPerRead = 16;
-  size_t total_packets_read = 0;  // Including truncated packets.
-  while (total_packets_read < kNumPackets) {
-    std::unique_ptr<ReadBuffers[]> read_buffers =
-        std::make_unique<ReadBuffers[]>(kNumPacketsPerRead);
-    QuicUdpSocketApi::ReadPacketResults results(kNumPacketsPerRead);
-    // Use small packet buffer for all even-numbered packets and expect them to
-    // be truncated.
-    auto is_truncated = [total_packets_read](size_t i) {
-      return ((total_packets_read + i) % 2) == 1;
-    };
-
-    for (size_t i = 0; i < kNumPacketsPerRead; ++i) {
-      results[i].packet_buffer.buffer = read_buffers[i].packet_buffer;
-      results[i].packet_buffer.buffer_len =
-          is_truncated(i) ? kPacketSize - 1
-                          : sizeof(read_buffers[i].packet_buffer);
-
-      results[i].control_buffer.buffer = read_buffers[i].control_buffer;
-      results[i].control_buffer.buffer_len =
-          sizeof(read_buffers[i].control_buffer);
-    }
-    size_t packets_read =
-        api_.ReadMultiplePackets(fd_server_, BitMask64(self_ip_bit), &results);
-    if (packets_read == 0) {
-      ASSERT_TRUE(
-          api_.WaitUntilReadable(fd_server_, QuicTime::Delta::FromSeconds(5)));
-      packets_read = api_.ReadMultiplePackets(fd_server_,
-                                              BitMask64(self_ip_bit), &results);
-      ASSERT_GT(packets_read, 0u);
-    }
-
-    for (size_t i = 0; i < packets_read; ++i) {
-      const auto& result = results[i];
-      if (is_truncated(i)) {
-        ASSERT_FALSE(result.ok);
-      } else {
-        ASSERT_TRUE(result.ok);
-        ASSERT_EQ(kPacketSize, result.packet_buffer.buffer_len);
-        ASSERT_TRUE(VerifyBufferIsFilledWith(result.packet_buffer.buffer,
-                                             result.packet_buffer.buffer_len,
-                                             ' ' + total_packets_read));
-        ASSERT_TRUE(result.packet_info.HasValue(self_ip_bit));
-        EXPECT_EQ(Loopback(), (address_family_ == AF_INET)
-                                  ? result.packet_info.self_v4_ip()
-                                  : result.packet_info.self_v6_ip());
-      }
-      total_packets_read++;
-    }
-  }
-}
-
-}  // namespace test
-}  // namespace quic
diff --git a/quic/platform/api/quic_bug_tracker.h b/quic/platform/api/quic_bug_tracker.h
index 23bcb7b..cffa6e5 100644
--- a/quic/platform/api/quic_bug_tracker.h
+++ b/quic/platform/api/quic_bug_tracker.h
@@ -5,11 +5,11 @@
 #ifndef QUICHE_QUIC_PLATFORM_API_QUIC_BUG_TRACKER_H_
 #define QUICHE_QUIC_PLATFORM_API_QUIC_BUG_TRACKER_H_
 
-#include "net/quic/platform/impl/quic_bug_tracker_impl.h"
+#include "common/platform/api/quiche_bug_tracker.h"
 
-#define QUIC_BUG QUIC_BUG_IMPL
-#define QUIC_BUG_IF QUIC_BUG_IF_IMPL
-#define QUIC_PEER_BUG QUIC_PEER_BUG_IMPL
-#define QUIC_PEER_BUG_IF QUIC_PEER_BUG_IF_IMPL
+#define QUIC_BUG QUICHE_BUG
+#define QUIC_BUG_IF QUICHE_BUG_IF
+#define QUIC_PEER_BUG QUICHE_PEER_BUG
+#define QUIC_PEER_BUG_IF QUICHE_PEER_BUG_IF
 
 #endif  // QUICHE_QUIC_PLATFORM_API_QUIC_BUG_TRACKER_H_
diff --git a/quic/qbone/qbone_client.cc b/quic/qbone/qbone_client.cc
index 464c053..d0daf95 100644
--- a/quic/qbone/qbone_client.cc
+++ b/quic/qbone/qbone_client.cc
@@ -11,6 +11,7 @@
 #include "quic/core/quic_epoll_connection_helper.h"
 #include "quic/platform/api/quic_epoll.h"
 #include "quic/platform/api/quic_exported_stats.h"
+#include "quic/platform/api/quic_testvalue.h"
 #include "quic/qbone/qbone_stream.h"
 
 namespace quic {
@@ -20,7 +21,7 @@
     QboneClient* client) {
   std::unique_ptr<QuicClientBase::NetworkHelper> helper =
       std::make_unique<QuicClientEpollNetworkHelper>(epoll_server, client);
-  testing::testvalue::Adjust("QboneClient/network_helper", &helper);
+  quic::AdjustTestValue("QboneClient/network_helper", &helper);
   return helper;
 }
 }  // namespace
diff --git a/quic/qbone/qbone_session_base.cc b/quic/qbone/qbone_session_base.cc
index 0badb91..e984196 100644
--- a/quic/qbone/qbone_session_base.cc
+++ b/quic/qbone/qbone_session_base.cc
@@ -15,10 +15,11 @@
 #include "quic/core/quic_types.h"
 #include "quic/platform/api/quic_exported_stats.h"
 #include "quic/platform/api/quic_logging.h"
+#include "quic/platform/api/quic_testvalue.h"
 #include "quic/qbone/platform/icmp_packet.h"
 #include "quic/qbone/qbone_constants.h"
 
-ABSL_FLAG(
+DEFINE_QUIC_COMMAND_LINE_FLAG(
     bool,
     qbone_close_ephemeral_frames,
     true,
@@ -212,7 +213,7 @@
 
 void QboneSessionBase::set_writer(QbonePacketWriter* writer) {
   writer_ = writer;
-  testing::testvalue::Adjust("quic_QbonePacketWriter", &writer_);
+  quic::AdjustTestValue("quic_QbonePacketWriter", &writer_);
 }
 
 }  // namespace quic
diff --git a/quic/qbone/qbone_stream.cc b/quic/qbone/qbone_stream.cc
index 43aab4d..5aac3e7 100644
--- a/quic/qbone/qbone_stream.cc
+++ b/quic/qbone/qbone_stream.cc
@@ -11,7 +11,10 @@
 #include "quic/qbone/qbone_constants.h"
 #include "quic/qbone/qbone_session_base.h"
 
-ABSL_FLAG(int, qbone_stream_ttl_secs, 3, "The QBONE Stream TTL in seconds.");
+DEFINE_QUIC_COMMAND_LINE_FLAG(int,
+                              qbone_stream_ttl_secs,
+                              3,
+                              "The QBONE Stream TTL in seconds.");
 
 namespace quic {
 
diff --git a/spdy/core/spdy_framer.cc b/spdy/core/spdy_framer.cc
index 19e53b6..bc7cd17 100644
--- a/spdy/core/spdy_framer.cc
+++ b/spdy/core/spdy_framer.cc
@@ -407,7 +407,6 @@
   return *(frame_ir_.get());
 }
 
-// TODO(yasong): remove all the static_casts.
 std::unique_ptr<SpdyFrameSequence> SpdyFramer::CreateIterator(
     SpdyFramer* framer,
     std::unique_ptr<const SpdyFrameIR> frame_ir) {
@@ -419,8 +418,8 @@
     }
     case SpdyFrameType::PUSH_PROMISE: {
       return std::make_unique<SpdyPushPromiseFrameIterator>(
-          framer, absl::WrapUnique(
-                      static_cast<const SpdyPushPromiseIR*>(frame_ir.release())));
+          framer, absl::WrapUnique(static_cast<const SpdyPushPromiseIR*>(
+                      frame_ir.release())));
     }
     case SpdyFrameType::DATA: {
       SPDY_DVLOG(1) << "Serialize a stream end DATA frame for VTL";