Move quic::QuicEndian to quiche::QuicheEndian

This change will enable us to reuse the endian library in new third_party repos without introducing a dependency on //third_party/quic.

gfe-relnote: Refactor of QUIC Endian library
PiperOrigin-RevId: 281406510
Change-Id: If1b72425a799bad7469281f32a12d6630fe787c4
diff --git a/common/platform/api/quiche_endian.h b/common/platform/api/quiche_endian.h
new file mode 100644
index 0000000..f8a9ee6
--- /dev/null
+++ b/common/platform/api/quiche_endian.h
@@ -0,0 +1,55 @@
+// 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.
+
+#ifndef QUICHE_COMMON_PLATFORM_API_QUICHE_ENDIAN_H_
+#define QUICHE_COMMON_PLATFORM_API_QUICHE_ENDIAN_H_
+
+#include "net/third_party/quiche/src/common/platform/api/quiche_export.h"
+#include "net/quiche/common/platform/impl/quiche_endian_impl.h"
+
+namespace quiche {
+
+enum Endianness {
+  NETWORK_BYTE_ORDER,  // big endian
+  HOST_BYTE_ORDER      // little endian
+};
+
+// Provide utility functions that convert from/to network order (big endian)
+// to/from host order (can be either little or big endian depending on the
+// platform).
+class QUICHE_EXPORT_PRIVATE QuicheEndian {
+ public:
+  // Convert |x| from host order (can be either little or big endian depending
+  // on the platform) to network order (big endian).
+  static uint16_t HostToNet16(uint16_t x) {
+    return QuicheEndianImpl::HostToNet16(x);
+  }
+  static uint32_t HostToNet32(uint32_t x) {
+    return QuicheEndianImpl::HostToNet32(x);
+  }
+  static uint64_t HostToNet64(uint64_t x) {
+    return QuicheEndianImpl::HostToNet64(x);
+  }
+
+  // Convert |x| from network order (big endian) to host order (can be either
+  // little or big endian depending on the platform).
+  static uint16_t NetToHost16(uint16_t x) {
+    return QuicheEndianImpl::NetToHost16(x);
+  }
+  static uint32_t NetToHost32(uint32_t x) {
+    return QuicheEndianImpl::NetToHost32(x);
+  }
+  static uint64_t NetToHost64(uint64_t x) {
+    return QuicheEndianImpl::NetToHost64(x);
+  }
+
+  // Returns true if current host order is little endian.
+  static bool HostIsLittleEndian() {
+    return QuicheEndianImpl::HostIsLittleEndian();
+  }
+};
+
+}  // namespace quiche
+
+#endif  // QUICHE_COMMON_PLATFORM_API_QUICHE_ENDIAN_H_
diff --git a/common/platform/api/quiche_endian_test.cc b/common/platform/api/quiche_endian_test.cc
new file mode 100644
index 0000000..98e16fe
--- /dev/null
+++ b/common/platform/api/quiche_endian_test.cc
@@ -0,0 +1,59 @@
+// Copyright 2017 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 "net/third_party/quiche/src/common/platform/api/quiche_endian.h"
+#include "net/third_party/quiche/src/common/platform/api/quiche_test.h"
+
+namespace quiche {
+namespace test {
+namespace {
+
+const uint16_t k16BitTestData = 0xaabb;
+const uint16_t k16BitSwappedTestData = 0xbbaa;
+const uint32_t k32BitTestData = 0xaabbccdd;
+const uint32_t k32BitSwappedTestData = 0xddccbbaa;
+const uint64_t k64BitTestData = 0xaabbccdd44332211;
+const uint64_t k64BitSwappedTestData = 0x11223344ddccbbaa;
+
+class QuicheEndianTest : public QuicheTest {};
+
+TEST_F(QuicheEndianTest, HostToNet) {
+  if (quiche::QuicheEndian::HostIsLittleEndian()) {
+    EXPECT_EQ(k16BitSwappedTestData,
+              quiche::QuicheEndian::HostToNet16(k16BitTestData));
+    EXPECT_EQ(k32BitSwappedTestData,
+              quiche::QuicheEndian::HostToNet32(k32BitTestData));
+    EXPECT_EQ(k64BitSwappedTestData,
+              quiche::QuicheEndian::HostToNet64(k64BitTestData));
+  } else {
+    EXPECT_EQ(k16BitTestData,
+              quiche::QuicheEndian::HostToNet16(k16BitTestData));
+    EXPECT_EQ(k32BitTestData,
+              quiche::QuicheEndian::HostToNet32(k32BitTestData));
+    EXPECT_EQ(k64BitTestData,
+              quiche::QuicheEndian::HostToNet64(k64BitTestData));
+  }
+}
+
+TEST_F(QuicheEndianTest, NetToHost) {
+  if (quiche::QuicheEndian::HostIsLittleEndian()) {
+    EXPECT_EQ(k16BitTestData,
+              quiche::QuicheEndian::NetToHost16(k16BitSwappedTestData));
+    EXPECT_EQ(k32BitTestData,
+              quiche::QuicheEndian::NetToHost32(k32BitSwappedTestData));
+    EXPECT_EQ(k64BitTestData,
+              quiche::QuicheEndian::NetToHost64(k64BitSwappedTestData));
+  } else {
+    EXPECT_EQ(k16BitSwappedTestData,
+              quiche::QuicheEndian::NetToHost16(k16BitSwappedTestData));
+    EXPECT_EQ(k32BitSwappedTestData,
+              quiche::QuicheEndian::NetToHost32(k32BitSwappedTestData));
+    EXPECT_EQ(k64BitSwappedTestData,
+              quiche::QuicheEndian::NetToHost64(k64BitSwappedTestData));
+  }
+}
+
+}  // namespace
+}  // namespace test
+}  // namespace quiche
diff --git a/common/platform/api/quiche_export.h b/common/platform/api/quiche_export.h
new file mode 100644
index 0000000..22cc1f9
--- /dev/null
+++ b/common/platform/api/quiche_export.h
@@ -0,0 +1,17 @@
+// 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.
+
+#ifndef THIRD_PARTY_QUICHE_PLATFORM_API_QUICHE_EXPORT_H_
+#define THIRD_PARTY_QUICHE_PLATFORM_API_QUICHE_EXPORT_H_
+
+#include "net/quiche/common/platform/impl/quiche_export_impl.h"
+
+// quiche_export_impl.h defines the following macros:
+// - QUICHE_EXPORT is not meant to be used.
+// - QUICHE_EXPORT_PRIVATE is meant for QUICHE functionality that is built in
+//   Chromium as part of //net, and not fully contained in headers.
+// - QUICHE_NO_EXPORT is meant for QUICHE functionality that is either fully
+//   defined in a header, or is built in Chromium as part of tests or tools.
+
+#endif  // THIRD_PARTY_QUICHE_PLATFORM_API_QUICHE_EXPORT_H_
diff --git a/quic/core/crypto/chacha_base_decrypter.cc b/quic/core/crypto/chacha_base_decrypter.cc
index eb1e95f..c67fd89 100644
--- a/quic/core/crypto/chacha_base_decrypter.cc
+++ b/quic/core/crypto/chacha_base_decrypter.cc
@@ -10,6 +10,7 @@
 #include "net/third_party/quiche/src/quic/core/quic_data_reader.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_arraysize.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h"
+#include "net/third_party/quiche/src/common/platform/api/quiche_endian.h"
 
 namespace quic {
 
@@ -30,7 +31,7 @@
   }
   const uint8_t* nonce = reinterpret_cast<const uint8_t*>(sample.data()) + 4;
   uint32_t counter;
-  QuicDataReader(sample.data(), 4, Endianness::HOST_BYTE_ORDER)
+  QuicDataReader(sample.data(), 4, quiche::HOST_BYTE_ORDER)
       .ReadUInt32(&counter);
   const uint8_t zeroes[] = {0, 0, 0, 0, 0};
   std::string out(QUIC_ARRAYSIZE(zeroes), 0);
diff --git a/quic/core/crypto/chacha_base_encrypter.cc b/quic/core/crypto/chacha_base_encrypter.cc
index 04d902f..9c465a9 100644
--- a/quic/core/crypto/chacha_base_encrypter.cc
+++ b/quic/core/crypto/chacha_base_encrypter.cc
@@ -8,6 +8,7 @@
 #include "net/third_party/quiche/src/quic/core/quic_data_reader.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_arraysize.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h"
+#include "net/third_party/quiche/src/common/platform/api/quiche_endian.h"
 
 namespace quic {
 
@@ -27,7 +28,7 @@
   }
   const uint8_t* nonce = reinterpret_cast<const uint8_t*>(sample.data()) + 4;
   uint32_t counter;
-  QuicDataReader(sample.data(), 4, Endianness::HOST_BYTE_ORDER)
+  QuicDataReader(sample.data(), 4, quiche::HOST_BYTE_ORDER)
       .ReadUInt32(&counter);
   const uint8_t zeroes[] = {0, 0, 0, 0, 0};
   std::string out(QUIC_ARRAYSIZE(zeroes), 0);
diff --git a/quic/core/crypto/crypto_framer.cc b/quic/core/crypto/crypto_framer.cc
index 6feaa8a..c3dd2aa 100644
--- a/quic/core/crypto/crypto_framer.cc
+++ b/quic/core/crypto/crypto_framer.cc
@@ -15,6 +15,7 @@
 #include "net/third_party/quiche/src/quic/platform/api/quic_logging.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_str_cat.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_string_piece.h"
+#include "net/third_party/quiche/src/common/platform/api/quiche_endian.h"
 
 namespace quic {
 
@@ -117,7 +118,8 @@
 }
 
 void CryptoFramer::ForceHandshake() {
-  QuicDataReader reader(buffer_.data(), buffer_.length(), HOST_BYTE_ORDER);
+  QuicDataReader reader(buffer_.data(), buffer_.length(),
+                        quiche::HOST_BYTE_ORDER);
   for (const std::pair<QuicTag, size_t>& item : tags_and_lengths_) {
     QuicStringPiece value;
     if (reader.BytesRemaining() < item.second) {
@@ -156,7 +158,7 @@
   }
 
   std::unique_ptr<char[]> buffer(new char[len]);
-  QuicDataWriter writer(len, buffer.get(), HOST_BYTE_ORDER);
+  QuicDataWriter writer(len, buffer.get(), quiche::HOST_BYTE_ORDER);
   if (!writer.WriteTag(message.tag())) {
     DCHECK(false) << "Failed to write message tag.";
     return nullptr;
@@ -244,7 +246,8 @@
 QuicErrorCode CryptoFramer::Process(QuicStringPiece input) {
   // Add this data to the buffer.
   buffer_.append(input.data(), input.length());
-  QuicDataReader reader(buffer_.data(), buffer_.length(), HOST_BYTE_ORDER);
+  QuicDataReader reader(buffer_.data(), buffer_.length(),
+                        quiche::HOST_BYTE_ORDER);
 
   switch (state_) {
     case STATE_READING_TAG:
diff --git a/quic/core/crypto/crypto_handshake_message.cc b/quic/core/crypto/crypto_handshake_message.cc
index 762a279..56f0bd6 100644
--- a/quic/core/crypto/crypto_handshake_message.cc
+++ b/quic/core/crypto/crypto_handshake_message.cc
@@ -12,10 +12,10 @@
 #include "net/third_party/quiche/src/quic/core/crypto/crypto_utils.h"
 #include "net/third_party/quiche/src/quic/core/quic_socket_address_coder.h"
 #include "net/third_party/quiche/src/quic/core/quic_utils.h"
-#include "net/third_party/quiche/src/quic/platform/api/quic_endian.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_map_util.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_str_cat.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_text_utils.h"
+#include "net/third_party/quiche/src/common/platform/api/quiche_endian.h"
 
 namespace quic {
 
@@ -73,14 +73,15 @@
   QuicVersionLabelVector version_labels;
   for (ParsedQuicVersion version : versions) {
     version_labels.push_back(
-        QuicEndian::HostToNet32(CreateQuicVersionLabel(version)));
+        quiche::QuicheEndian::HostToNet32(CreateQuicVersionLabel(version)));
   }
   SetVector(tag, version_labels);
 }
 
 void CryptoHandshakeMessage::SetVersion(QuicTag tag,
                                         ParsedQuicVersion version) {
-  SetValue(tag, QuicEndian::HostToNet32(CreateQuicVersionLabel(version)));
+  SetValue(tag,
+           quiche::QuicheEndian::HostToNet32(CreateQuicVersionLabel(version)));
 }
 
 void CryptoHandshakeMessage::SetStringPiece(QuicTag tag,
@@ -128,7 +129,7 @@
   }
 
   for (size_t i = 0; i < out->size(); ++i) {
-    (*out)[i] = QuicEndian::HostToNet32((*out)[i]);
+    (*out)[i] = quiche::QuicheEndian::HostToNet32((*out)[i]);
   }
 
   return QUIC_NO_ERROR;
@@ -142,7 +143,7 @@
     return error;
   }
 
-  *out = QuicEndian::HostToNet32(*out);
+  *out = quiche::QuicheEndian::HostToNet32(*out);
   return QUIC_NO_ERROR;
 }
 
diff --git a/quic/core/crypto/crypto_handshake_message_test.cc b/quic/core/crypto/crypto_handshake_message_test.cc
index f595581..b6dfdd4 100644
--- a/quic/core/crypto/crypto_handshake_message_test.cc
+++ b/quic/core/crypto/crypto_handshake_message_test.cc
@@ -6,8 +6,8 @@
 
 #include "net/third_party/quiche/src/quic/core/crypto/crypto_handshake.h"
 #include "net/third_party/quiche/src/quic/core/crypto/crypto_protocol.h"
-#include "net/third_party/quiche/src/quic/platform/api/quic_endian.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_test.h"
+#include "net/third_party/quiche/src/common/platform/api/quiche_endian.h"
 
 namespace quic {
 namespace test {
diff --git a/quic/core/crypto/crypto_server_test.cc b/quic/core/crypto/crypto_server_test.cc
index 902d41e..2db49d2 100644
--- a/quic/core/crypto/crypto_server_test.cc
+++ b/quic/core/crypto/crypto_server_test.cc
@@ -22,7 +22,6 @@
 #include "net/third_party/quiche/src/quic/core/quic_socket_address_coder.h"
 #include "net/third_party/quiche/src/quic/core/quic_utils.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_arraysize.h"
-#include "net/third_party/quiche/src/quic/platform/api/quic_endian.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_flags.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_string_piece.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_test.h"
@@ -33,6 +32,7 @@
 #include "net/third_party/quiche/src/quic/test_tools/mock_random.h"
 #include "net/third_party/quiche/src/quic/test_tools/quic_crypto_server_config_peer.h"
 #include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h"
+#include "net/third_party/quiche/src/common/platform/api/quiche_endian.h"
 
 namespace quic {
 namespace test {
diff --git a/quic/core/crypto/crypto_utils.cc b/quic/core/crypto/crypto_utils.cc
index 1c249b9..037990a 100644
--- a/quic/core/crypto/crypto_utils.cc
+++ b/quic/core/crypto/crypto_utils.cc
@@ -30,6 +30,7 @@
 #include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_logging.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_str_cat.h"
+#include "net/third_party/quiche/src/common/platform/api/quiche_endian.h"
 
 namespace quic {
 
@@ -299,7 +300,7 @@
 
     psk_premaster_secret = std::make_unique<char[]>(psk_premaster_secret_size);
     QuicDataWriter writer(psk_premaster_secret_size, psk_premaster_secret.get(),
-                          HOST_BYTE_ORDER);
+                          quiche::HOST_BYTE_ORDER);
 
     if (!writer.WriteStringPiece(label) || !writer.WriteUInt8(0) ||
         !writer.WriteStringPiece(pre_shared_key) ||
diff --git a/quic/core/crypto/null_decrypter.cc b/quic/core/crypto/null_decrypter.cc
index af0a886..51d8b11 100644
--- a/quic/core/crypto/null_decrypter.cc
+++ b/quic/core/crypto/null_decrypter.cc
@@ -10,6 +10,7 @@
 #include "net/third_party/quiche/src/quic/core/quic_utils.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_uint128.h"
+#include "net/third_party/quiche/src/common/platform/api/quiche_endian.h"
 
 namespace quic {
 
@@ -50,7 +51,7 @@
                                   size_t* output_length,
                                   size_t max_output_length) {
   QuicDataReader reader(ciphertext.data(), ciphertext.length(),
-                        HOST_BYTE_ORDER);
+                        quiche::HOST_BYTE_ORDER);
   QuicUint128 hash;
 
   if (!ReadHash(&reader, &hash)) {
diff --git a/quic/core/crypto/quic_crypto_client_config.cc b/quic/core/crypto/quic_crypto_client_config.cc
index 6b00c4c..d674126 100644
--- a/quic/core/crypto/quic_crypto_client_config.cc
+++ b/quic/core/crypto/quic_crypto_client_config.cc
@@ -28,7 +28,6 @@
 #include "net/third_party/quiche/src/quic/platform/api/quic_arraysize.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_client_stats.h"
-#include "net/third_party/quiche/src/quic/platform/api/quic_endian.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_hostname_utils.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_logging.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_map_util.h"
diff --git a/quic/core/crypto/quic_crypto_client_config_test.cc b/quic/core/crypto/quic_crypto_client_config_test.cc
index 7a34d21..8b5f116 100644
--- a/quic/core/crypto/quic_crypto_client_config_test.cc
+++ b/quic/core/crypto/quic_crypto_client_config_test.cc
@@ -10,7 +10,6 @@
 #include "net/third_party/quiche/src/quic/core/quic_server_id.h"
 #include "net/third_party/quiche/src/quic/core/quic_types.h"
 #include "net/third_party/quiche/src/quic/core/quic_utils.h"
-#include "net/third_party/quiche/src/quic/platform/api/quic_endian.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_test.h"
 #include "net/third_party/quiche/src/quic/test_tools/crypto_test_utils.h"
 #include "net/third_party/quiche/src/quic/test_tools/mock_random.h"
diff --git a/quic/core/crypto/quic_crypto_server_config.cc b/quic/core/crypto/quic_crypto_server_config.cc
index 68ee910..d568986 100644
--- a/quic/core/crypto/quic_crypto_server_config.cc
+++ b/quic/core/crypto/quic_crypto_server_config.cc
@@ -38,7 +38,6 @@
 #include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_cert_utils.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_clock.h"
-#include "net/third_party/quiche/src/quic/platform/api/quic_endian.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_fallthrough.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_flag_utils.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_flags.h"
diff --git a/quic/core/http/quic_headers_stream_test.cc b/quic/core/http/quic_headers_stream_test.cc
index 973c60c..4cf11cc 100644
--- a/quic/core/http/quic_headers_stream_test.cc
+++ b/quic/core/http/quic_headers_stream_test.cc
@@ -25,6 +25,7 @@
 #include "net/third_party/quiche/src/quic/test_tools/quic_spdy_session_peer.h"
 #include "net/third_party/quiche/src/quic/test_tools/quic_stream_peer.h"
 #include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h"
+#include "net/third_party/quiche/src/common/platform/api/quiche_endian.h"
 #include "net/third_party/quiche/src/spdy/core/http2_frame_decoder_adapter.h"
 #include "net/third_party/quiche/src/spdy/core/spdy_alt_svc_wire_format.h"
 #include "net/third_party/quiche/src/spdy/core/spdy_protocol.h"
@@ -226,7 +227,7 @@
 
   QuicConsumedData SaveIov(size_t write_length) {
     char* buf = new char[write_length];
-    QuicDataWriter writer(write_length, buf, NETWORK_BYTE_ORDER);
+    QuicDataWriter writer(write_length, buf, quiche::NETWORK_BYTE_ORDER);
     headers_stream_->WriteStreamData(headers_stream_->stream_bytes_written(),
                                      write_length, &writer);
     saved_data_.append(buf, write_length);
diff --git a/quic/core/http/quic_spdy_session_test.cc b/quic/core/http/quic_spdy_session_test.cc
index b22f00d..a8deb18 100644
--- a/quic/core/http/quic_spdy_session_test.cc
+++ b/quic/core/http/quic_spdy_session_test.cc
@@ -40,6 +40,7 @@
 #include "net/third_party/quiche/src/quic/test_tools/quic_stream_peer.h"
 #include "net/third_party/quiche/src/quic/test_tools/quic_stream_send_buffer_peer.h"
 #include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h"
+#include "net/third_party/quiche/src/common/platform/api/quiche_endian.h"
 #include "net/third_party/quiche/src/spdy/core/spdy_framer.h"
 
 using spdy::kV3HighestPriority;
@@ -1249,7 +1250,7 @@
     config.ToHandshakeMessage(&crypto_message, transport_version());
     crypto_stream->SendHandshakeMessage(crypto_message);
     char buf[1000];
-    QuicDataWriter writer(1000, buf, NETWORK_BYTE_ORDER);
+    QuicDataWriter writer(1000, buf, quiche::NETWORK_BYTE_ORDER);
     crypto_stream->WriteStreamData(offset, crypto_message.size(), &writer);
   }
   EXPECT_TRUE(crypto_stream->flow_controller()->IsBlocked());
diff --git a/quic/core/quic_connection_id.cc b/quic/core/quic_connection_id.cc
index c2a8754..49e90b6 100644
--- a/quic/core/quic_connection_id.cc
+++ b/quic/core/quic_connection_id.cc
@@ -14,11 +14,11 @@
 #include "net/third_party/quiche/src/quic/core/crypto/quic_random.h"
 #include "net/third_party/quiche/src/quic/core/quic_types.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h"
-#include "net/third_party/quiche/src/quic/platform/api/quic_endian.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_flag_utils.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_flags.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_logging.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_text_utils.h"
+#include "net/third_party/quiche/src/common/platform/api/quiche_endian.h"
 
 namespace quic {
 
diff --git a/quic/core/quic_data_reader.cc b/quic/core/quic_data_reader.cc
index c9a76be..17fb6cd 100644
--- a/quic/core/quic_data_reader.cc
+++ b/quic/core/quic_data_reader.cc
@@ -9,18 +9,19 @@
 #include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_flags.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_str_cat.h"
+#include "net/third_party/quiche/src/common/platform/api/quiche_endian.h"
 
 namespace quic {
 
 QuicDataReader::QuicDataReader(QuicStringPiece data)
-    : QuicDataReader(data.data(), data.length(), NETWORK_BYTE_ORDER) {}
+    : QuicDataReader(data.data(), data.length(), quiche::NETWORK_BYTE_ORDER) {}
 
 QuicDataReader::QuicDataReader(const char* data, const size_t len)
-    : QuicDataReader(data, len, NETWORK_BYTE_ORDER) {}
+    : QuicDataReader(data, len, quiche::NETWORK_BYTE_ORDER) {}
 
 QuicDataReader::QuicDataReader(const char* data,
                                const size_t len,
-                               Endianness endianness)
+                               quiche::Endianness endianness)
     : data_(data), len_(len), pos_(0), endianness_(endianness) {}
 
 bool QuicDataReader::ReadUInt8(uint8_t* result) {
@@ -31,8 +32,8 @@
   if (!ReadBytes(result, sizeof(*result))) {
     return false;
   }
-  if (endianness_ == NETWORK_BYTE_ORDER) {
-    *result = QuicEndian::NetToHost16(*result);
+  if (endianness_ == quiche::NETWORK_BYTE_ORDER) {
+    *result = quiche::QuicheEndian::NetToHost16(*result);
   }
   return true;
 }
@@ -41,8 +42,8 @@
   if (!ReadBytes(result, sizeof(*result))) {
     return false;
   }
-  if (endianness_ == NETWORK_BYTE_ORDER) {
-    *result = QuicEndian::NetToHost32(*result);
+  if (endianness_ == quiche::NETWORK_BYTE_ORDER) {
+    *result = quiche::QuicheEndian::NetToHost32(*result);
   }
   return true;
 }
@@ -51,8 +52,8 @@
   if (!ReadBytes(result, sizeof(*result))) {
     return false;
   }
-  if (endianness_ == NETWORK_BYTE_ORDER) {
-    *result = QuicEndian::NetToHost64(*result);
+  if (endianness_ == quiche::NETWORK_BYTE_ORDER) {
+    *result = quiche::QuicheEndian::NetToHost64(*result);
   }
   return true;
 }
@@ -62,7 +63,7 @@
   if (num_bytes > sizeof(*result)) {
     return false;
   }
-  if (endianness_ == HOST_BYTE_ORDER) {
+  if (endianness_ == quiche::HOST_BYTE_ORDER) {
     return ReadBytes(result, num_bytes);
   }
 
@@ -70,7 +71,7 @@
                  num_bytes)) {
     return false;
   }
-  *result = QuicEndian::NetToHost64(*result);
+  *result = quiche::QuicheEndian::NetToHost64(*result);
   return true;
 }
 
@@ -217,7 +218,7 @@
 }
 
 QuicVariableLengthIntegerLength QuicDataReader::PeekVarInt62Length() {
-  DCHECK_EQ(endianness_, NETWORK_BYTE_ORDER);
+  DCHECK_EQ(endianness_, quiche::NETWORK_BYTE_ORDER);
   const unsigned char* next =
       reinterpret_cast<const unsigned char*>(data_ + pos_);
   if (BytesRemaining() == 0) {
@@ -275,7 +276,7 @@
 // Low-level optimization is useful here because this function will be
 // called frequently, leading to outsize benefits.
 bool QuicDataReader::ReadVarInt62(uint64_t* result) {
-  DCHECK_EQ(endianness_, NETWORK_BYTE_ORDER);
+  DCHECK_EQ(endianness_, quiche::NETWORK_BYTE_ORDER);
 
   size_t remaining = BytesRemaining();
   const unsigned char* next =
diff --git a/quic/core/quic_data_reader.h b/quic/core/quic_data_reader.h
index 74ed226..a8b6521 100644
--- a/quic/core/quic_data_reader.h
+++ b/quic/core/quic_data_reader.h
@@ -9,9 +9,9 @@
 #include <cstdint>
 
 #include "net/third_party/quiche/src/quic/core/quic_types.h"
-#include "net/third_party/quiche/src/quic/platform/api/quic_endian.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_export.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_string_piece.h"
+#include "net/third_party/quiche/src/common/platform/api/quiche_endian.h"
 
 namespace quic {
 
@@ -39,7 +39,9 @@
   QuicDataReader(const char* data, const size_t len);
   // Constructs a reader using the specified endianness.
   // Caller must provide an underlying buffer to work on.
-  QuicDataReader(const char* data, const size_t len, Endianness endianness);
+  QuicDataReader(const char* data,
+                 const size_t len,
+                 quiche::Endianness endianness);
   QuicDataReader(const QuicDataReader&) = delete;
   QuicDataReader& operator=(const QuicDataReader&) = delete;
 
@@ -152,7 +154,9 @@
   // DOES NOT forward the internal iterator.
   uint8_t PeekByte() const;
 
-  void set_endianness(Endianness endianness) { endianness_ = endianness; }
+  void set_endianness(quiche::Endianness endianness) {
+    endianness_ = endianness;
+  }
 
   // Read an IETF-encoded Variable Length Integer and place the result
   // in |*result|.
@@ -190,7 +194,7 @@
   size_t pos_;
 
   // The endianness to read integers and floating numbers.
-  Endianness endianness_;
+  quiche::Endianness endianness_;
 };
 
 }  // namespace quic
diff --git a/quic/core/quic_data_writer.cc b/quic/core/quic_data_writer.cc
index e01eb6c..d2d7113 100644
--- a/quic/core/quic_data_writer.cc
+++ b/quic/core/quic_data_writer.cc
@@ -12,13 +12,16 @@
 #include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_flags.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_str_cat.h"
+#include "net/third_party/quiche/src/common/platform/api/quiche_endian.h"
 
 namespace quic {
 
 QuicDataWriter::QuicDataWriter(size_t size, char* buffer)
-    : QuicDataWriter(size, buffer, NETWORK_BYTE_ORDER) {}
+    : QuicDataWriter(size, buffer, quiche::NETWORK_BYTE_ORDER) {}
 
-QuicDataWriter::QuicDataWriter(size_t size, char* buffer, Endianness endianness)
+QuicDataWriter::QuicDataWriter(size_t size,
+                               char* buffer,
+                               quiche::Endianness endianness)
     : buffer_(buffer), capacity_(size), length_(0), endianness_(endianness) {}
 
 QuicDataWriter::~QuicDataWriter() {}
@@ -32,22 +35,22 @@
 }
 
 bool QuicDataWriter::WriteUInt16(uint16_t value) {
-  if (endianness_ == NETWORK_BYTE_ORDER) {
-    value = QuicEndian::HostToNet16(value);
+  if (endianness_ == quiche::NETWORK_BYTE_ORDER) {
+    value = quiche::QuicheEndian::HostToNet16(value);
   }
   return WriteBytes(&value, sizeof(value));
 }
 
 bool QuicDataWriter::WriteUInt32(uint32_t value) {
-  if (endianness_ == NETWORK_BYTE_ORDER) {
-    value = QuicEndian::HostToNet32(value);
+  if (endianness_ == quiche::NETWORK_BYTE_ORDER) {
+    value = quiche::QuicheEndian::HostToNet32(value);
   }
   return WriteBytes(&value, sizeof(value));
 }
 
 bool QuicDataWriter::WriteUInt64(uint64_t value) {
-  if (endianness_ == NETWORK_BYTE_ORDER) {
-    value = QuicEndian::HostToNet64(value);
+  if (endianness_ == quiche::NETWORK_BYTE_ORDER) {
+    value = quiche::QuicheEndian::HostToNet64(value);
   }
   return WriteBytes(&value, sizeof(value));
 }
@@ -56,11 +59,11 @@
   if (num_bytes > sizeof(value)) {
     return false;
   }
-  if (endianness_ == HOST_BYTE_ORDER) {
+  if (endianness_ == quiche::HOST_BYTE_ORDER) {
     return WriteBytes(&value, num_bytes);
   }
 
-  value = QuicEndian::HostToNet64(value);
+  value = quiche::QuicheEndian::HostToNet64(value);
   return WriteBytes(reinterpret_cast<char*>(&value) + sizeof(value) - num_bytes,
                     num_bytes);
 }
@@ -101,8 +104,8 @@
     result = static_cast<uint16_t>(value + (exponent << kUFloat16MantissaBits));
   }
 
-  if (endianness_ == NETWORK_BYTE_ORDER) {
-    result = QuicEndian::HostToNet16(result);
+  if (endianness_ == quiche::NETWORK_BYTE_ORDER) {
+    result = quiche::QuicheEndian::HostToNet16(result);
   }
   return WriteBytes(&result, sizeof(result));
 }
@@ -227,7 +230,7 @@
 // Low-level optimization is useful here because this function will be
 // called frequently, leading to outsize benefits.
 bool QuicDataWriter::WriteVarInt62(uint64_t value) {
-  DCHECK_EQ(endianness_, NETWORK_BYTE_ORDER);
+  DCHECK_EQ(endianness_, quiche::NETWORK_BYTE_ORDER);
 
   size_t remaining = capacity_ - length_;
   char* next = buffer_ + length_;
@@ -298,7 +301,7 @@
 bool QuicDataWriter::WriteVarInt62(
     uint64_t value,
     QuicVariableLengthIntegerLength write_length) {
-  DCHECK_EQ(endianness_, NETWORK_BYTE_ORDER);
+  DCHECK_EQ(endianness_, quiche::NETWORK_BYTE_ORDER);
 
   size_t remaining = capacity_ - length_;
   if (remaining < write_length) {
diff --git a/quic/core/quic_data_writer.h b/quic/core/quic_data_writer.h
index c43d0ff..8f1b21d 100644
--- a/quic/core/quic_data_writer.h
+++ b/quic/core/quic_data_writer.h
@@ -9,9 +9,9 @@
 #include <cstdint>
 
 #include "net/third_party/quiche/src/quic/core/quic_types.h"
-#include "net/third_party/quiche/src/quic/platform/api/quic_endian.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_export.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_string_piece.h"
+#include "net/third_party/quiche/src/common/platform/api/quiche_endian.h"
 
 namespace quic {
 
@@ -42,7 +42,7 @@
   QuicDataWriter(size_t size, char* buffer);
   // Creates a QuicDataWriter where |buffer| is not owned
   // using the specified endianness.
-  QuicDataWriter(size_t size, char* buffer, Endianness endianness);
+  QuicDataWriter(size_t size, char* buffer, quiche::Endianness endianness);
   QuicDataWriter(const QuicDataWriter&) = delete;
   QuicDataWriter& operator=(const QuicDataWriter&) = delete;
 
@@ -144,7 +144,7 @@
   size_t length_;    // Current length of the buffer.
 
   // The endianness to write integers and floating numbers.
-  Endianness endianness_;
+  quiche::Endianness endianness_;
 };
 
 }  // namespace quic
diff --git a/quic/core/quic_data_writer_test.cc b/quic/core/quic_data_writer_test.cc
index 60abf96..104df8d 100644
--- a/quic/core/quic_data_writer_test.cc
+++ b/quic/core/quic_data_writer_test.cc
@@ -15,6 +15,7 @@
 #include "net/third_party/quiche/src/quic/platform/api/quic_flags.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_test.h"
 #include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h"
+#include "net/third_party/quiche/src/common/platform/api/quiche_endian.h"
 
 namespace quic {
 namespace test {
@@ -25,20 +26,22 @@
 }
 
 struct TestParams {
-  explicit TestParams(Endianness endianness) : endianness(endianness) {}
+  explicit TestParams(quiche::Endianness endianness) : endianness(endianness) {}
 
-  Endianness endianness;
+  quiche::Endianness endianness;
 };
 
 // Used by ::testing::PrintToStringParamName().
 std::string PrintToString(const TestParams& p) {
-  return QuicStrCat((p.endianness == NETWORK_BYTE_ORDER ? "Network" : "Host"),
-                    "ByteOrder");
+  return QuicStrCat(
+      (p.endianness == quiche::NETWORK_BYTE_ORDER ? "Network" : "Host"),
+      "ByteOrder");
 }
 
 std::vector<TestParams> GetTestParams() {
   std::vector<TestParams> params;
-  for (Endianness endianness : {NETWORK_BYTE_ORDER, HOST_BYTE_ORDER}) {
+  for (quiche::Endianness endianness :
+       {quiche::NETWORK_BYTE_ORDER, quiche::HOST_BYTE_ORDER}) {
     params.push_back(TestParams(endianness));
   }
   return params;
@@ -135,8 +138,8 @@
     QuicDataWriter writer(2, buffer, GetParam().endianness);
     EXPECT_TRUE(writer.WriteUFloat16(test_cases[i].decoded));
     uint16_t result = *reinterpret_cast<uint16_t*>(writer.data());
-    if (GetParam().endianness == NETWORK_BYTE_ORDER) {
-      result = QuicEndian::HostToNet16(result);
+    if (GetParam().endianness == quiche::NETWORK_BYTE_ORDER) {
+      result = quiche::QuicheEndian::HostToNet16(result);
     }
     EXPECT_EQ(test_cases[i].encoded, result);
   }
@@ -196,8 +199,8 @@
 
   for (int i = 0; i < num_test_cases; ++i) {
     uint16_t encoded_ufloat = test_cases[i].encoded;
-    if (GetParam().endianness == NETWORK_BYTE_ORDER) {
-      encoded_ufloat = QuicEndian::HostToNet16(encoded_ufloat);
+    if (GetParam().endianness == quiche::NETWORK_BYTE_ORDER) {
+      encoded_ufloat = quiche::QuicheEndian::HostToNet16(encoded_ufloat);
     }
     QuicDataReader reader(reinterpret_cast<char*>(&encoded_ufloat), 2,
                           GetParam().endianness);
@@ -213,8 +216,8 @@
   for (uint16_t i = 1; i < 0xFFFF; ++i) {
     // Read the two bytes.
     uint16_t read_number = i;
-    if (GetParam().endianness == NETWORK_BYTE_ORDER) {
-      read_number = QuicEndian::HostToNet16(read_number);
+    if (GetParam().endianness == quiche::NETWORK_BYTE_ORDER) {
+      read_number = quiche::QuicheEndian::HostToNet16(read_number);
     }
     QuicDataReader reader(reinterpret_cast<char*>(&read_number), 2,
                           GetParam().endianness);
@@ -243,10 +246,10 @@
     uint16_t encoded1 = *reinterpret_cast<uint16_t*>(writer.data());
     uint16_t encoded2 = *reinterpret_cast<uint16_t*>(writer.data() + 2);
     uint16_t encoded3 = *reinterpret_cast<uint16_t*>(writer.data() + 4);
-    if (GetParam().endianness == NETWORK_BYTE_ORDER) {
-      encoded1 = QuicEndian::NetToHost16(encoded1);
-      encoded2 = QuicEndian::NetToHost16(encoded2);
-      encoded3 = QuicEndian::NetToHost16(encoded3);
+    if (GetParam().endianness == quiche::NETWORK_BYTE_ORDER) {
+      encoded1 = quiche::QuicheEndian::NetToHost16(encoded1);
+      encoded2 = quiche::QuicheEndian::NetToHost16(encoded2);
+      encoded3 = quiche::QuicheEndian::NetToHost16(encoded3);
     }
     EXPECT_EQ(i - 1, encoded1);
     // Check roundtrip.
@@ -384,8 +387,8 @@
     writer.WriteUInt16(in_memory16);
     test::CompareCharArraysWithHexError(
         "uint16_t", buffer16, 2,
-        GetParam().endianness == NETWORK_BYTE_ORDER ? big_endian16
-                                                    : little_endian16,
+        GetParam().endianness == quiche::NETWORK_BYTE_ORDER ? big_endian16
+                                                            : little_endian16,
         2);
 
     uint16_t read_number16;
@@ -400,8 +403,8 @@
     writer.WriteBytesToUInt64(2, in_memory16);
     test::CompareCharArraysWithHexError(
         "uint16_t", buffer16, 2,
-        GetParam().endianness == NETWORK_BYTE_ORDER ? big_endian16
-                                                    : little_endian16,
+        GetParam().endianness == quiche::NETWORK_BYTE_ORDER ? big_endian16
+                                                            : little_endian16,
         2);
 
     uint64_t read_number16;
@@ -420,8 +423,8 @@
   writer.WriteBytesToUInt64(3, in_memory24);
   test::CompareCharArraysWithHexError(
       "uint24", buffer24, 3,
-      GetParam().endianness == NETWORK_BYTE_ORDER ? big_endian24
-                                                  : little_endian24,
+      GetParam().endianness == quiche::NETWORK_BYTE_ORDER ? big_endian24
+                                                          : little_endian24,
       3);
 
   uint64_t read_number24;
@@ -440,8 +443,8 @@
     writer.WriteUInt32(in_memory32);
     test::CompareCharArraysWithHexError(
         "uint32_t", buffer32, 4,
-        GetParam().endianness == NETWORK_BYTE_ORDER ? big_endian32
-                                                    : little_endian32,
+        GetParam().endianness == quiche::NETWORK_BYTE_ORDER ? big_endian32
+                                                            : little_endian32,
         4);
 
     uint32_t read_number32;
@@ -456,8 +459,8 @@
     writer.WriteBytesToUInt64(4, in_memory32);
     test::CompareCharArraysWithHexError(
         "uint32_t", buffer32, 4,
-        GetParam().endianness == NETWORK_BYTE_ORDER ? big_endian32
-                                                    : little_endian32,
+        GetParam().endianness == quiche::NETWORK_BYTE_ORDER ? big_endian32
+                                                            : little_endian32,
         4);
 
     uint64_t read_number32;
@@ -476,8 +479,8 @@
   writer.WriteBytesToUInt64(5, in_memory40);
   test::CompareCharArraysWithHexError(
       "uint40", buffer40, 5,
-      GetParam().endianness == NETWORK_BYTE_ORDER ? big_endian40
-                                                  : little_endian40,
+      GetParam().endianness == quiche::NETWORK_BYTE_ORDER ? big_endian40
+                                                          : little_endian40,
       5);
 
   uint64_t read_number40;
@@ -495,8 +498,8 @@
   writer.WriteBytesToUInt64(6, in_memory48);
   test::CompareCharArraysWithHexError(
       "uint48", buffer48, 6,
-      GetParam().endianness == NETWORK_BYTE_ORDER ? big_endian48
-                                                  : little_endian48,
+      GetParam().endianness == quiche::NETWORK_BYTE_ORDER ? big_endian48
+                                                          : little_endian48,
       6);
 
   uint64_t read_number48;
@@ -514,8 +517,8 @@
   writer.WriteBytesToUInt64(7, in_memory56);
   test::CompareCharArraysWithHexError(
       "uint56", buffer56, 7,
-      GetParam().endianness == NETWORK_BYTE_ORDER ? big_endian56
-                                                  : little_endian56,
+      GetParam().endianness == quiche::NETWORK_BYTE_ORDER ? big_endian56
+                                                          : little_endian56,
       7);
 
   uint64_t read_number56;
@@ -535,8 +538,9 @@
   writer.WriteBytesToUInt64(8, in_memory64);
   test::CompareCharArraysWithHexError(
       "uint64_t", buffer64, 8,
-      GetParam().endianness == NETWORK_BYTE_ORDER ? AsChars(big_endian64)
-                                                  : AsChars(little_endian64),
+      GetParam().endianness == quiche::NETWORK_BYTE_ORDER
+          ? AsChars(big_endian64)
+          : AsChars(little_endian64),
       8);
 
   uint64_t read_number64;
@@ -548,8 +552,9 @@
   writer2.WriteUInt64(in_memory64);
   test::CompareCharArraysWithHexError(
       "uint64_t", buffer64, 8,
-      GetParam().endianness == NETWORK_BYTE_ORDER ? AsChars(big_endian64)
-                                                  : AsChars(little_endian64),
+      GetParam().endianness == quiche::NETWORK_BYTE_ORDER
+          ? AsChars(big_endian64)
+          : AsChars(little_endian64),
       8);
   read_number64 = 0u;
   QuicDataReader reader2(buffer64, 8, GetParam().endianness);
@@ -674,7 +679,8 @@
   // make a writer. Note that for IETF encoding
   // we do not care about endianness... It's always big-endian,
   // but the c'tor expects to be told what endianness is in force...
-  QuicDataWriter writer(size_of_buffer, buffer, Endianness::NETWORK_BYTE_ORDER);
+  QuicDataWriter writer(size_of_buffer, buffer,
+                        quiche::Endianness::NETWORK_BYTE_ORDER);
 
   // Try to write the value.
   if (writer.WriteVarInt62(value_in) != true) {
@@ -699,7 +705,7 @@
 
   // set up a reader, just the length we've used, no more, no less.
   QuicDataReader reader(buffer, expected_length,
-                        Endianness::NETWORK_BYTE_ORDER);
+                        quiche::Endianness::NETWORK_BYTE_ORDER);
   uint64_t value_out;
 
   if (reader.ReadVarInt62(&value_out) == false) {
@@ -721,7 +727,7 @@
   // are always encoded big endian...
   memset(buffer, 0, sizeof(buffer));
   QuicDataWriter writer(sizeof(buffer), static_cast<char*>(buffer),
-                        Endianness::NETWORK_BYTE_ORDER);
+                        quiche::Endianness::NETWORK_BYTE_ORDER);
   EXPECT_TRUE(writer.WriteVarInt62(UINT64_C(0x3142f3e4d5c6b7a8)));
   EXPECT_EQ(static_cast<unsigned char>(*(writer.data() + 0)),
             (0x31 + 0xc0));  // 0xc0 for encoding
@@ -743,7 +749,7 @@
   // are always encoded big endian...
   memset(buffer, 0, sizeof(buffer));
   QuicDataWriter writer(sizeof(buffer), static_cast<char*>(buffer),
-                        Endianness::NETWORK_BYTE_ORDER);
+                        quiche::Endianness::NETWORK_BYTE_ORDER);
   EXPECT_TRUE(writer.WriteVarInt62(0x3243f4e5));
   EXPECT_EQ(static_cast<unsigned char>(*(writer.data() + 0)),
             (0x32 + 0x80));  // 0x80 for encoding
@@ -761,7 +767,7 @@
   // are always encoded big endian...
   memset(buffer, 0, sizeof(buffer));
   QuicDataWriter writer(sizeof(buffer), static_cast<char*>(buffer),
-                        Endianness::NETWORK_BYTE_ORDER);
+                        quiche::Endianness::NETWORK_BYTE_ORDER);
   EXPECT_TRUE(writer.WriteVarInt62(0x3647));
   EXPECT_EQ(static_cast<unsigned char>(*(writer.data() + 0)),
             (0x36 + 0x40));  // 0x40 for encoding
@@ -777,7 +783,7 @@
   // is correct. Bytes are always encoded big endian...
   memset(buffer, 0, sizeof(buffer));
   QuicDataWriter writer(sizeof(buffer), static_cast<char*>(buffer),
-                        Endianness::NETWORK_BYTE_ORDER);
+                        quiche::Endianness::NETWORK_BYTE_ORDER);
   EXPECT_TRUE(writer.WriteVarInt62(0x3f));
   EXPECT_EQ(static_cast<unsigned char>(*(writer.data() + 0)), 0x3f);
 }
@@ -883,7 +889,7 @@
   char buffer[8 * kMultiVarCount];
   memset(buffer, 0, sizeof(buffer));
   QuicDataWriter writer(sizeof(buffer), static_cast<char*>(buffer),
-                        Endianness::NETWORK_BYTE_ORDER);
+                        quiche::Endianness::NETWORK_BYTE_ORDER);
   // Put N values into the buffer. Adding i to the value ensures that
   // each value is different so we can detect if we overwrite values,
   // or read the same value over and over.
@@ -897,7 +903,8 @@
 
   // Now we should be able to read out the N values that were
   // successfully encoded.
-  QuicDataReader reader(buffer, sizeof(buffer), Endianness::NETWORK_BYTE_ORDER);
+  QuicDataReader reader(buffer, sizeof(buffer),
+                        quiche::Endianness::NETWORK_BYTE_ORDER);
   for (int i = 0; i < kMultiVarCount; i++) {
     EXPECT_TRUE(reader.ReadVarInt62(&test_val));
     EXPECT_EQ(test_val, (UINT64_C(0x3142f3e4d5c6b7a8) + i));
@@ -912,7 +919,7 @@
   char buffer[4 * kMultiVarCount];
   memset(buffer, 0, sizeof(buffer));
   QuicDataWriter writer(sizeof(buffer), static_cast<char*>(buffer),
-                        Endianness::NETWORK_BYTE_ORDER);
+                        quiche::Endianness::NETWORK_BYTE_ORDER);
   // Put N values into the buffer. Adding i to the value ensures that
   // each value is different so we can detect if we overwrite values,
   // or read the same value over and over.
@@ -926,7 +933,8 @@
 
   // Now we should be able to read out the N values that were
   // successfully encoded.
-  QuicDataReader reader(buffer, sizeof(buffer), Endianness::NETWORK_BYTE_ORDER);
+  QuicDataReader reader(buffer, sizeof(buffer),
+                        quiche::Endianness::NETWORK_BYTE_ORDER);
   for (int i = 0; i < kMultiVarCount; i++) {
     EXPECT_TRUE(reader.ReadVarInt62(&test_val));
     EXPECT_EQ(test_val, (UINT64_C(0x3142f3e4) + i));
@@ -941,7 +949,7 @@
   char buffer[2 * kMultiVarCount];
   memset(buffer, 0, sizeof(buffer));
   QuicDataWriter writer(sizeof(buffer), static_cast<char*>(buffer),
-                        Endianness::NETWORK_BYTE_ORDER);
+                        quiche::Endianness::NETWORK_BYTE_ORDER);
   // Put N values into the buffer. Adding i to the value ensures that
   // each value is different so we can detect if we overwrite values,
   // or read the same value over and over.
@@ -955,7 +963,8 @@
 
   // Now we should be able to read out the N values that were
   // successfully encoded.
-  QuicDataReader reader(buffer, sizeof(buffer), Endianness::NETWORK_BYTE_ORDER);
+  QuicDataReader reader(buffer, sizeof(buffer),
+                        quiche::Endianness::NETWORK_BYTE_ORDER);
   for (int i = 0; i < kMultiVarCount; i++) {
     EXPECT_TRUE(reader.ReadVarInt62(&test_val));
     EXPECT_EQ(test_val, (UINT64_C(0x3142) + i));
@@ -970,7 +979,7 @@
   char buffer[1 * kMultiVarCount];
   memset(buffer, 0, sizeof(buffer));
   QuicDataWriter writer(sizeof(buffer), static_cast<char*>(buffer),
-                        Endianness::NETWORK_BYTE_ORDER);
+                        quiche::Endianness::NETWORK_BYTE_ORDER);
   // Put N values into the buffer. Adding i to the value ensures that
   // each value is different so we can detect if we overwrite values,
   // or read the same value over and over. &0xf ensures we do not
@@ -985,7 +994,8 @@
 
   // Now we should be able to read out the N values that were
   // successfully encoded.
-  QuicDataReader reader(buffer, sizeof(buffer), Endianness::NETWORK_BYTE_ORDER);
+  QuicDataReader reader(buffer, sizeof(buffer),
+                        quiche::Endianness::NETWORK_BYTE_ORDER);
   for (int i = 0; i < kMultiVarCount; i++) {
     EXPECT_TRUE(reader.ReadVarInt62(&test_val));
     EXPECT_EQ(test_val, (UINT64_C(0x30) + (i & 0xf)));
@@ -999,7 +1009,7 @@
   char buffer[90];
   memset(buffer, 0, sizeof(buffer));
   QuicDataWriter writer(sizeof(buffer), static_cast<char*>(buffer),
-                        Endianness::NETWORK_BYTE_ORDER);
+                        quiche::Endianness::NETWORK_BYTE_ORDER);
 
   writer.WriteVarInt62(1, VARIABLE_LENGTH_INTEGER_LENGTH_1);
   writer.WriteVarInt62(1, VARIABLE_LENGTH_INTEGER_LENGTH_2);
@@ -1027,7 +1037,8 @@
 
   writer.WriteVarInt62(1073741824, VARIABLE_LENGTH_INTEGER_LENGTH_8);
 
-  QuicDataReader reader(buffer, sizeof(buffer), Endianness::NETWORK_BYTE_ORDER);
+  QuicDataReader reader(buffer, sizeof(buffer),
+                        quiche::Endianness::NETWORK_BYTE_ORDER);
 
   uint64_t test_val = 0;
   for (int i = 0; i < 4; ++i) {
@@ -1071,10 +1082,11 @@
 
   // Encode the given Stream ID.
   QuicDataWriter writer(sizeof(buffer), static_cast<char*>(buffer),
-                        Endianness::NETWORK_BYTE_ORDER);
+                        quiche::Endianness::NETWORK_BYTE_ORDER);
   EXPECT_TRUE(writer.WriteVarInt62(value_in));
 
-  QuicDataReader reader(buffer, sizeof(buffer), Endianness::NETWORK_BYTE_ORDER);
+  QuicDataReader reader(buffer, sizeof(buffer),
+                        quiche::Endianness::NETWORK_BYTE_ORDER);
   QuicStreamId received_stream_id;
   bool read_result = reader.ReadVarIntU32(&received_stream_id);
   EXPECT_EQ(expected_decode_result, read_result);
@@ -1124,28 +1136,28 @@
 TEST_P(QuicDataWriterTest, PeekVarInt62Length) {
   // In range [0, 63], variable length should be 1 byte.
   char buffer[20];
-  QuicDataWriter writer(20, buffer, NETWORK_BYTE_ORDER);
+  QuicDataWriter writer(20, buffer, quiche::NETWORK_BYTE_ORDER);
   EXPECT_TRUE(writer.WriteVarInt62(50));
-  QuicDataReader reader(buffer, 20, NETWORK_BYTE_ORDER);
+  QuicDataReader reader(buffer, 20, quiche::NETWORK_BYTE_ORDER);
   EXPECT_EQ(1, reader.PeekVarInt62Length());
   // In range (63-16383], variable length should be 2 byte2.
   char buffer2[20];
-  QuicDataWriter writer2(20, buffer2, NETWORK_BYTE_ORDER);
+  QuicDataWriter writer2(20, buffer2, quiche::NETWORK_BYTE_ORDER);
   EXPECT_TRUE(writer2.WriteVarInt62(100));
-  QuicDataReader reader2(buffer2, 20, NETWORK_BYTE_ORDER);
+  QuicDataReader reader2(buffer2, 20, quiche::NETWORK_BYTE_ORDER);
   EXPECT_EQ(2, reader2.PeekVarInt62Length());
   // In range (16383, 1073741823], variable length should be 4 bytes.
   char buffer3[20];
-  QuicDataWriter writer3(20, buffer3, NETWORK_BYTE_ORDER);
+  QuicDataWriter writer3(20, buffer3, quiche::NETWORK_BYTE_ORDER);
   EXPECT_TRUE(writer3.WriteVarInt62(20000));
-  QuicDataReader reader3(buffer3, 20, NETWORK_BYTE_ORDER);
+  QuicDataReader reader3(buffer3, 20, quiche::NETWORK_BYTE_ORDER);
   EXPECT_EQ(4, reader3.PeekVarInt62Length());
   // In range (1073741823, 4611686018427387903], variable length should be 8
   // bytes.
   char buffer4[20];
-  QuicDataWriter writer4(20, buffer4, NETWORK_BYTE_ORDER);
+  QuicDataWriter writer4(20, buffer4, quiche::NETWORK_BYTE_ORDER);
   EXPECT_TRUE(writer4.WriteVarInt62(2000000000));
-  QuicDataReader reader4(buffer4, 20, NETWORK_BYTE_ORDER);
+  QuicDataReader reader4(buffer4, 20, quiche::NETWORK_BYTE_ORDER);
   EXPECT_EQ(8, reader4.PeekVarInt62Length());
 }
 
@@ -1171,7 +1183,7 @@
   char buffer[1024];
   memset(buffer, 0, sizeof(buffer));
   QuicDataWriter writer(sizeof(buffer), static_cast<char*>(buffer),
-                        Endianness::NETWORK_BYTE_ORDER);
+                        quiche::Endianness::NETWORK_BYTE_ORDER);
   QuicDataReader reader(buffer, sizeof(buffer));
   const QuicStreamCount write_stream_count = 0xffeeddcc;
   EXPECT_TRUE(writer.WriteVarInt62(write_stream_count));
@@ -1184,7 +1196,7 @@
   char buffer[1024];
   memset(buffer, 0, sizeof(buffer));
   QuicDataWriter writer(sizeof(buffer), static_cast<char*>(buffer),
-                        Endianness::NETWORK_BYTE_ORDER);
+                        quiche::Endianness::NETWORK_BYTE_ORDER);
   QuicDataReader reader(buffer, sizeof(buffer));
   EXPECT_TRUE(writer.WriteVarInt62(UINT64_C(0x1ffeeddcc)));
   QuicStreamCount read_stream_count = 123456;
diff --git a/quic/core/quic_ietf_framer_test.cc b/quic/core/quic_ietf_framer_test.cc
index 90ae8b9..8557a35 100644
--- a/quic/core/quic_ietf_framer_test.cc
+++ b/quic/core/quic_ietf_framer_test.cc
@@ -247,8 +247,8 @@
     // initialize a writer so that the serialized packet is placed in
     // packet_buffer.
     QuicDataWriter writer(packet_buffer_size, packet_buffer,
-                          NETWORK_BYTE_ORDER);  // do not really care
-                                                // about endianness.
+                          quiche::NETWORK_BYTE_ORDER);  // do not really care
+                                                        // about endianness.
     // set up to define the source frame we wish to send.
     QuicStreamFrame source_stream_frame(
         stream_id, fin_bit, offset, xmit_packet_data, xmit_packet_data_size);
@@ -259,7 +259,8 @@
     // Better have something in the packet buffer.
     EXPECT_NE(0u, writer.length());
     // Now set up a reader to read in the frame.
-    QuicDataReader reader(packet_buffer, writer.length(), NETWORK_BYTE_ORDER);
+    QuicDataReader reader(packet_buffer, writer.length(),
+                          quiche::NETWORK_BYTE_ORDER);
 
     // A StreamFrame to hold the results... we know the frame type,
     // put it into the QuicIetfStreamFrame
@@ -323,7 +324,8 @@
 
     // Make a writer so that the serialized packet is placed in
     // packet_buffer.
-    QuicDataWriter writer(expected_size, packet_buffer, NETWORK_BYTE_ORDER);
+    QuicDataWriter writer(expected_size, packet_buffer,
+                          quiche::NETWORK_BYTE_ORDER);
 
     // Write the frame to the packet buffer.
     EXPECT_TRUE(QuicFramerPeer::AppendIetfAckFrameAndTypeByte(
@@ -338,7 +340,8 @@
     // and what is in the buffer should be the expected size.
     EXPECT_EQ(expected_size, writer.length()) << "Frame is " << transmit_frame;
     // Now set up a reader to read in the frame.
-    QuicDataReader reader(packet_buffer, writer.length(), NETWORK_BYTE_ORDER);
+    QuicDataReader reader(packet_buffer, writer.length(),
+                          quiche::NETWORK_BYTE_ORDER);
 
     // read in the frame type
     uint8_t received_frame_type;
@@ -384,7 +387,7 @@
     // Make a writer so that the serialized packet is placed in
     // packet_buffer.
     QuicDataWriter writer(packet_buffer_size, packet_buffer,
-                          NETWORK_BYTE_ORDER);
+                          quiche::NETWORK_BYTE_ORDER);
 
     QuicPathChallengeFrame transmit_frame(0, data);
 
@@ -396,7 +399,8 @@
     EXPECT_EQ(kQuicPathChallengeFrameSize, writer.length());
 
     // now set up a reader to read in the frame.
-    QuicDataReader reader(packet_buffer, writer.length(), NETWORK_BYTE_ORDER);
+    QuicDataReader reader(packet_buffer, writer.length(),
+                          quiche::NETWORK_BYTE_ORDER);
 
     QuicPathChallengeFrame receive_frame;
 
@@ -417,7 +421,7 @@
     // Make a writer so that the serialized packet is placed in
     // packet_buffer.
     QuicDataWriter writer(packet_buffer_size, packet_buffer,
-                          NETWORK_BYTE_ORDER);
+                          quiche::NETWORK_BYTE_ORDER);
 
     QuicPathResponseFrame transmit_frame(0, data);
 
@@ -429,7 +433,8 @@
     EXPECT_EQ(kQuicPathResponseFrameSize, writer.length());
 
     // Set up a reader to read in the frame.
-    QuicDataReader reader(packet_buffer, writer.length(), NETWORK_BYTE_ORDER);
+    QuicDataReader reader(packet_buffer, writer.length(),
+                          quiche::NETWORK_BYTE_ORDER);
 
     QuicPathResponseFrame receive_frame;
 
@@ -452,7 +457,7 @@
     // Initialize a writer so that the serialized packet is placed in
     // packet_buffer.
     QuicDataWriter writer(packet_buffer_size, packet_buffer,
-                          NETWORK_BYTE_ORDER);
+                          quiche::NETWORK_BYTE_ORDER);
 
     QuicRstStreamFrame transmit_frame(static_cast<QuicControlFrameId>(1),
                                       stream_id, error_code, final_offset);
@@ -465,7 +470,8 @@
     EXPECT_LT(2u, writer.length());
     EXPECT_GT(25u, writer.length());
     // Now set up a reader to read in the thing in.
-    QuicDataReader reader(packet_buffer, writer.length(), NETWORK_BYTE_ORDER);
+    QuicDataReader reader(packet_buffer, writer.length(),
+                          quiche::NETWORK_BYTE_ORDER);
 
     // A QuicRstStreamFrame to hold the results
     QuicRstStreamFrame receive_frame;
@@ -487,7 +493,7 @@
     Perspective old_perspective = framer_.perspective();
     // Set up the writer and transmit QuicMaxStreamsFrame
     QuicDataWriter writer(sizeof(packet_buffer), packet_buffer,
-                          NETWORK_BYTE_ORDER);
+                          quiche::NETWORK_BYTE_ORDER);
 
     // Set the perspective of the sender. If the stream id is supposed to
     // be server-initiated, then the sender of the MAX_STREAMS should be
@@ -512,7 +518,8 @@
                                                  : Perspective::IS_CLIENT);
 
     // Set up reader and empty receive QuicPaddingFrame.
-    QuicDataReader reader(packet_buffer, writer.length(), NETWORK_BYTE_ORDER);
+    QuicDataReader reader(packet_buffer, writer.length(),
+                          quiche::NETWORK_BYTE_ORDER);
     QuicMaxStreamsFrame receive_frame;
 
     // Deframe it
@@ -537,7 +544,7 @@
     Perspective old_perspective = framer_.perspective();
     // Set up the writer and transmit QuicStreamsBlockedFrame
     QuicDataWriter writer(sizeof(packet_buffer), packet_buffer,
-                          NETWORK_BYTE_ORDER);
+                          quiche::NETWORK_BYTE_ORDER);
 
     // Set the perspective of the sender. If the stream id is supposed to
     // be server-initiated, then the sender of the STREAMS_BLOCKED should be
@@ -562,7 +569,8 @@
                                                  : Perspective::IS_SERVER);
 
     // Set up reader and empty receive QuicPaddingFrame.
-    QuicDataReader reader(packet_buffer, writer.length(), NETWORK_BYTE_ORDER);
+    QuicDataReader reader(packet_buffer, writer.length(),
+                          quiche::NETWORK_BYTE_ORDER);
     QuicStreamsBlockedFrame receive_frame;
 
     // Deframe it
@@ -762,13 +770,14 @@
     data_producer.SaveCryptoData(ENCRYPTION_INITIAL, offset, frame_data);
 
     QuicDataWriter writer(QUIC_ARRAYSIZE(packet_buffer), packet_buffer,
-                          NETWORK_BYTE_ORDER);
+                          quiche::NETWORK_BYTE_ORDER);
 
     // Write the frame.
     EXPECT_TRUE(QuicFramerPeer::AppendCryptoFrame(&framer_, frame, &writer));
     EXPECT_NE(0u, writer.length());
     // Read it back.
-    QuicDataReader reader(packet_buffer, writer.length(), NETWORK_BYTE_ORDER);
+    QuicDataReader reader(packet_buffer, writer.length(),
+                          quiche::NETWORK_BYTE_ORDER);
     QuicCryptoFrame read_frame;
     EXPECT_TRUE(
         QuicFramerPeer::ProcessCryptoFrame(&framer_, &reader, &read_frame));
@@ -787,7 +796,7 @@
   // initialize a writer so that the serialized packet is placed in
   // packet_buffer.
   QuicDataWriter writer(sizeof(packet_buffer), packet_buffer,
-                        NETWORK_BYTE_ORDER);
+                        quiche::NETWORK_BYTE_ORDER);
 
   std::string test_string = "Ich Bin Ein Jelly Donut?";
   QuicConnectionCloseFrame sent_frame(QUIC_VERSION_99, QUIC_NO_ERROR,
@@ -802,7 +811,8 @@
   EXPECT_NE(0u, writer.length());
 
   // now set up a reader to read in the frame.
-  QuicDataReader reader(packet_buffer, writer.length(), NETWORK_BYTE_ORDER);
+  QuicDataReader reader(packet_buffer, writer.length(),
+                        quiche::NETWORK_BYTE_ORDER);
 
   // a QuicConnectionCloseFrame to hold the results.
   QuicConnectionCloseFrame sink_frame;
@@ -824,7 +834,7 @@
   // initialize a writer so that the serialized packet is placed in
   // packet_buffer.
   QuicDataWriter writer(sizeof(packet_buffer), packet_buffer,
-                        NETWORK_BYTE_ORDER);
+                        quiche::NETWORK_BYTE_ORDER);
 
   std::string test_string = "Ich Bin Ein Jelly Donut?";
   QuicConnectionCloseFrame sent_frame(QUIC_VERSION_99, QUIC_LAST_ERROR,
@@ -839,7 +849,8 @@
   EXPECT_NE(0u, writer.length());
 
   // now set up a reader to read in the frame.
-  QuicDataReader reader(packet_buffer, writer.length(), NETWORK_BYTE_ORDER);
+  QuicDataReader reader(packet_buffer, writer.length(),
+                        quiche::NETWORK_BYTE_ORDER);
 
   // a QuicConnectionCloseFrame to hold the results.
   QuicConnectionCloseFrame sink_frame;
@@ -1061,7 +1072,7 @@
   // Make a writer so that the serialized packet is placed in
   // packet_buffer.
   QuicDataWriter writer(sizeof(packet_buffer), packet_buffer,
-                        NETWORK_BYTE_ORDER);
+                        quiche::NETWORK_BYTE_ORDER);
 
   QuicAckFrame transmit_frame;
   transmit_frame.largest_acked = QuicPacketNumber(1);
@@ -1085,7 +1096,8 @@
   EXPECT_EQ(0, memcmp(packet, packet_buffer, writer.length()));
 
   // Now set up a reader to read in the frame.
-  QuicDataReader reader(packet_buffer, writer.length(), NETWORK_BYTE_ORDER);
+  QuicDataReader reader(packet_buffer, writer.length(),
+                        quiche::NETWORK_BYTE_ORDER);
 
   // an AckFrame to hold the results
   QuicAckFrame receive_frame;
@@ -1150,7 +1162,7 @@
   // Make a writer so that the serialized packet is placed in
   // packet_buffer.
   QuicDataWriter writer(sizeof(packet_buffer), packet_buffer,
-                        NETWORK_BYTE_ORDER);
+                        quiche::NETWORK_BYTE_ORDER);
 
   QuicStopSendingFrame transmit_frame;
   transmit_frame.stream_id = 12345;
@@ -1164,7 +1176,8 @@
   EXPECT_LE(3u, writer.length());
   EXPECT_GE(10u, writer.length());
 
-  QuicDataReader reader(packet_buffer, writer.length(), NETWORK_BYTE_ORDER);
+  QuicDataReader reader(packet_buffer, writer.length(),
+                        quiche::NETWORK_BYTE_ORDER);
 
   // A frame to hold the results
   QuicStopSendingFrame receive_frame;
@@ -1190,7 +1203,7 @@
 
     // Set up the writer and transmit QuicWindowUpdateFrame
     QuicDataWriter writer(sizeof(packet_buffer), packet_buffer,
-                          NETWORK_BYTE_ORDER);
+                          quiche::NETWORK_BYTE_ORDER);
     QuicWindowUpdateFrame transmit_frame(0, 99, window_size);
 
     // Add the frame.
@@ -1202,7 +1215,8 @@
     EXPECT_GE(8u, writer.length());
 
     // Set up reader and an empty QuicWindowUpdateFrame
-    QuicDataReader reader(packet_buffer, writer.length(), NETWORK_BYTE_ORDER);
+    QuicDataReader reader(packet_buffer, writer.length(),
+                          quiche::NETWORK_BYTE_ORDER);
     QuicWindowUpdateFrame receive_frame;
 
     // Deframe it
@@ -1231,7 +1245,7 @@
 
       // Set up the writer and transmit QuicWindowUpdateFrame
       QuicDataWriter writer(sizeof(packet_buffer), packet_buffer,
-                            NETWORK_BYTE_ORDER);
+                            quiche::NETWORK_BYTE_ORDER);
       QuicWindowUpdateFrame transmit_frame(0, stream_id, window_size);
 
       // Add the frame.
@@ -1243,7 +1257,8 @@
       EXPECT_GE(16u, writer.length());
 
       // Set up reader and empty receive QuicPaddingFrame.
-      QuicDataReader reader(packet_buffer, writer.length(), NETWORK_BYTE_ORDER);
+      QuicDataReader reader(packet_buffer, writer.length(),
+                            quiche::NETWORK_BYTE_ORDER);
       QuicWindowUpdateFrame receive_frame;
 
       // Deframe it
@@ -1286,7 +1301,7 @@
 
     // Set up the writer and transmit QuicBlockedFrame
     QuicDataWriter writer(sizeof(packet_buffer), packet_buffer,
-                          NETWORK_BYTE_ORDER);
+                          quiche::NETWORK_BYTE_ORDER);
     QuicBlockedFrame transmit_frame(
         0, QuicUtils::GetInvalidStreamId(framer_.transport_version()), offset);
 
@@ -1299,7 +1314,8 @@
     EXPECT_GE(8u, writer.length());
 
     // Set up reader and empty receive QuicFrame.
-    QuicDataReader reader(packet_buffer, writer.length(), NETWORK_BYTE_ORDER);
+    QuicDataReader reader(packet_buffer, writer.length(),
+                          quiche::NETWORK_BYTE_ORDER);
     QuicBlockedFrame receive_frame;
 
     // Deframe it
@@ -1328,7 +1344,7 @@
 
       // Set up the writer and transmit QuicWindowUpdateFrame
       QuicDataWriter writer(sizeof(packet_buffer), packet_buffer,
-                            NETWORK_BYTE_ORDER);
+                            quiche::NETWORK_BYTE_ORDER);
       QuicBlockedFrame transmit_frame(0, stream_id, offset);
 
       // Add the frame.
@@ -1340,7 +1356,8 @@
       EXPECT_GE(16u, writer.length());
 
       // Set up reader and empty receive QuicPaddingFrame.
-      QuicDataReader reader(packet_buffer, writer.length(), NETWORK_BYTE_ORDER);
+      QuicDataReader reader(packet_buffer, writer.length(),
+                            quiche::NETWORK_BYTE_ORDER);
       QuicBlockedFrame receive_frame;
 
       // Deframe it
@@ -1398,7 +1415,7 @@
 
   // Set up the writer and transmit a QuicNewConnectionIdFrame
   QuicDataWriter writer(sizeof(packet_buffer), packet_buffer,
-                        NETWORK_BYTE_ORDER);
+                        quiche::NETWORK_BYTE_ORDER);
 
   // Add the frame.
   EXPECT_TRUE(QuicFramerPeer::AppendNewConnectionIdFrame(
@@ -1424,7 +1441,8 @@
   EXPECT_EQ(0, memcmp(packet_buffer, packet, sizeof(packet)));
 
   // Set up reader and empty receive QuicPaddingFrame.
-  QuicDataReader reader(packet_buffer, writer.length(), NETWORK_BYTE_ORDER);
+  QuicDataReader reader(packet_buffer, writer.length(),
+                        quiche::NETWORK_BYTE_ORDER);
   QuicNewConnectionIdFrame receive_frame;
 
   // Deframe it
@@ -1449,7 +1467,7 @@
 
   // Set up the writer and transmit QuicRetireConnectionIdFrame
   QuicDataWriter writer(sizeof(packet_buffer), packet_buffer,
-                        NETWORK_BYTE_ORDER);
+                        quiche::NETWORK_BYTE_ORDER);
 
   // Add the frame.
   EXPECT_TRUE(QuicFramerPeer::AppendRetireConnectionIdFrame(
@@ -1466,7 +1484,8 @@
   EXPECT_EQ(0, memcmp(packet_buffer, packet, sizeof(packet)));
 
   // Set up reader and empty receive QuicPaddingFrame.
-  QuicDataReader reader(packet_buffer, writer.length(), NETWORK_BYTE_ORDER);
+  QuicDataReader reader(packet_buffer, writer.length(),
+                        quiche::NETWORK_BYTE_ORDER);
   QuicRetireConnectionIdFrame receive_frame;
 
   // Deframe it
diff --git a/quic/core/quic_packet_creator_test.cc b/quic/core/quic_packet_creator_test.cc
index 9aa737a..c7a38b2 100644
--- a/quic/core/quic_packet_creator_test.cc
+++ b/quic/core/quic_packet_creator_test.cc
@@ -229,7 +229,7 @@
     EXPECT_EQ(STREAM_FRAME, frame.type);
     EXPECT_EQ(stream_id, frame.stream_frame.stream_id);
     char buf[kMaxOutgoingPacketSize];
-    QuicDataWriter writer(kMaxOutgoingPacketSize, buf, HOST_BYTE_ORDER);
+    QuicDataWriter writer(kMaxOutgoingPacketSize, buf, quiche::HOST_BYTE_ORDER);
     if (frame.stream_frame.data_length > 0) {
       producer_.WriteStreamData(stream_id, frame.stream_frame.offset,
                                 frame.stream_frame.data_length, &writer);
diff --git a/quic/core/quic_session_test.cc b/quic/core/quic_session_test.cc
index 16a9917..d3df0a7 100644
--- a/quic/core/quic_session_test.cc
+++ b/quic/core/quic_session_test.cc
@@ -1563,7 +1563,7 @@
     config.ToHandshakeMessage(&crypto_message, transport_version());
     crypto_stream->SendHandshakeMessage(crypto_message);
     char buf[1000];
-    QuicDataWriter writer(1000, buf, NETWORK_BYTE_ORDER);
+    QuicDataWriter writer(1000, buf, quiche::NETWORK_BYTE_ORDER);
     crypto_stream->WriteStreamData(offset, crypto_message.size(), &writer);
   }
   EXPECT_TRUE(crypto_stream->flow_controller()->IsBlocked());
diff --git a/quic/core/quic_stream_send_buffer_test.cc b/quic/core/quic_stream_send_buffer_test.cc
index 4a37c1e..90fcd6e 100644
--- a/quic/core/quic_stream_send_buffer_test.cc
+++ b/quic/core/quic_stream_send_buffer_test.cc
@@ -64,7 +64,7 @@
   void WriteAllData() {
     // Write all data.
     char buf[4000];
-    QuicDataWriter writer(4000, buf, HOST_BYTE_ORDER);
+    QuicDataWriter writer(4000, buf, quiche::HOST_BYTE_ORDER);
     send_buffer_.WriteStreamData(0, 3840u, &writer);
 
     send_buffer_.OnStreamDataConsumed(3840u);
@@ -78,7 +78,7 @@
 
 TEST_F(QuicStreamSendBufferTest, CopyDataToBuffer) {
   char buf[4000];
-  QuicDataWriter writer(4000, buf, HOST_BYTE_ORDER);
+  QuicDataWriter writer(4000, buf, quiche::HOST_BYTE_ORDER);
   std::string copy1(1024, 'a');
   std::string copy2 =
       std::string(512, 'a') + std::string(256, 'b') + std::string(256, 'c');
@@ -95,7 +95,7 @@
   EXPECT_EQ(copy4, QuicStringPiece(buf + 3072, 768));
 
   // Test data piece across boundries.
-  QuicDataWriter writer2(4000, buf, HOST_BYTE_ORDER);
+  QuicDataWriter writer2(4000, buf, quiche::HOST_BYTE_ORDER);
   std::string copy5 =
       std::string(536, 'a') + std::string(256, 'b') + std::string(232, 'c');
   ASSERT_TRUE(send_buffer_.WriteStreamData(1000, 1024, &writer2));
@@ -105,7 +105,7 @@
   EXPECT_EQ(copy6, QuicStringPiece(buf + 1024, 1024));
 
   // Invalid data copy.
-  QuicDataWriter writer3(4000, buf, HOST_BYTE_ORDER);
+  QuicDataWriter writer3(4000, buf, quiche::HOST_BYTE_ORDER);
   EXPECT_FALSE(send_buffer_.WriteStreamData(3000, 1024, &writer3));
   EXPECT_QUIC_BUG(send_buffer_.WriteStreamData(0, 4000, &writer3),
                   "Writer fails to write.");
@@ -123,7 +123,7 @@
       std::string(512, 'a') + std::string(256, 'b') + std::string(256, 'c');
   std::string copy3 = std::string(1024, 'c') + std::string(100, 'd');
   char buf[6000];
-  QuicDataWriter writer(6000, buf, HOST_BYTE_ORDER);
+  QuicDataWriter writer(6000, buf, quiche::HOST_BYTE_ORDER);
   // Write more than one slice.
   EXPECT_EQ(0, QuicStreamSendBufferPeer::write_index(&send_buffer_));
   ASSERT_TRUE(send_buffer_.WriteStreamData(0, 1024, &writer));
@@ -290,7 +290,7 @@
 
 TEST_F(QuicStreamSendBufferTest, CurrentWriteIndex) {
   char buf[4000];
-  QuicDataWriter writer(4000, buf, HOST_BYTE_ORDER);
+  QuicDataWriter writer(4000, buf, quiche::HOST_BYTE_ORDER);
   // With data buffered, index points to the 1st slice of data.
   EXPECT_EQ(0u,
             QuicStreamSendBufferPeer::CurrentWriteSlice(&send_buffer_)->offset);
diff --git a/quic/core/quic_trace_visitor.cc b/quic/core/quic_trace_visitor.cc
index 8295e72..99681af 100644
--- a/quic/core/quic_trace_visitor.cc
+++ b/quic/core/quic_trace_visitor.cc
@@ -6,7 +6,7 @@
 
 #include <string>
 
-#include "net/third_party/quiche/src/quic/platform/api/quic_endian.h"
+#include "net/third_party/quiche/src/common/platform/api/quiche_endian.h"
 
 namespace quic {
 
@@ -265,7 +265,8 @@
 
 void QuicTraceVisitor::OnSuccessfulVersionNegotiation(
     const ParsedQuicVersion& version) {
-  uint32_t tag = QuicEndian::HostToNet32(CreateQuicVersionLabel(version));
+  uint32_t tag =
+      quiche::QuicheEndian::HostToNet32(CreateQuicVersionLabel(version));
   std::string binary_tag(reinterpret_cast<const char*>(&tag), sizeof(tag));
   trace_.set_protocol_version(binary_tag);
 }
diff --git a/quic/core/quic_utils.cc b/quic/core/quic_utils.cc
index eed0e37..a69efcd 100644
--- a/quic/core/quic_utils.cc
+++ b/quic/core/quic_utils.cc
@@ -15,11 +15,11 @@
 #include "net/third_party/quiche/src/quic/platform/api/quic_aligned.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_arraysize.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h"
-#include "net/third_party/quiche/src/quic/platform/api/quic_endian.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_flag_utils.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_flags.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_prefetch.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_uint128.h"
+#include "net/third_party/quiche/src/common/platform/api/quiche_endian.h"
 
 namespace quic {
 namespace {
diff --git a/quic/core/quic_versions.cc b/quic/core/quic_versions.cc
index 8d666a3..b68c988 100644
--- a/quic/core/quic_versions.cc
+++ b/quic/core/quic_versions.cc
@@ -11,11 +11,11 @@
 #include "net/third_party/quiche/src/quic/core/quic_types.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_arraysize.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h"
-#include "net/third_party/quiche/src/quic/platform/api/quic_endian.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_flag_utils.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_flags.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_logging.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_text_utils.h"
+#include "net/third_party/quiche/src/common/platform/api/quiche_endian.h"
 
 namespace quic {
 namespace {
@@ -324,7 +324,7 @@
 }
 
 std::string QuicVersionLabelToString(QuicVersionLabel version_label) {
-  return QuicTagToString(QuicEndian::HostToNet32(version_label));
+  return QuicTagToString(quiche::QuicheEndian::HostToNet32(version_label));
 }
 
 std::string QuicVersionLabelVectorToString(
diff --git a/quic/platform/api/quic_endian.h b/quic/platform/api/quic_endian.h
deleted file mode 100644
index 56a69a9..0000000
--- a/quic/platform/api/quic_endian.h
+++ /dev/null
@@ -1,55 +0,0 @@
-// Copyright 2017 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_QUIC_PLATFORM_API_QUIC_ENDIAN_H_
-#define QUICHE_QUIC_PLATFORM_API_QUIC_ENDIAN_H_
-
-#include "net/third_party/quiche/src/quic/platform/api/quic_export.h"
-#include "net/quic/platform/impl/quic_endian_impl.h"
-
-namespace quic {
-
-enum Endianness {
-  NETWORK_BYTE_ORDER,  // big endian
-  HOST_BYTE_ORDER      // little endian
-};
-
-// Provide utility functions that convert from/to network order (big endian)
-// to/from host order (can be either little or big endian depending on the
-// platform).
-class QUIC_EXPORT_PRIVATE QuicEndian {
- public:
-  // Convert |x| from host order (can be either little or big endian depending
-  // on the platform) to network order (big endian).
-  static uint16_t HostToNet16(uint16_t x) {
-    return QuicEndianImpl::HostToNet16(x);
-  }
-  static uint32_t HostToNet32(uint32_t x) {
-    return QuicEndianImpl::HostToNet32(x);
-  }
-  static uint64_t HostToNet64(uint64_t x) {
-    return QuicEndianImpl::HostToNet64(x);
-  }
-
-  // Convert |x| from network order (big endian) to host order (can be either
-  // little or big endian depending on the platform).
-  static uint16_t NetToHost16(uint16_t x) {
-    return QuicEndianImpl::NetToHost16(x);
-  }
-  static uint32_t NetToHost32(uint32_t x) {
-    return QuicEndianImpl::NetToHost32(x);
-  }
-  static uint64_t NetToHost64(uint64_t x) {
-    return QuicEndianImpl::NetToHost64(x);
-  }
-
-  // Returns true if current host order is little endian.
-  static bool HostIsLittleEndian() {
-    return QuicEndianImpl::HostIsLittleEndian();
-  }
-};
-
-}  // namespace quic
-
-#endif  // QUICHE_QUIC_PLATFORM_API_QUIC_ENDIAN_H_
diff --git a/quic/platform/api/quic_endian_test.cc b/quic/platform/api/quic_endian_test.cc
deleted file mode 100644
index d054d96..0000000
--- a/quic/platform/api/quic_endian_test.cc
+++ /dev/null
@@ -1,51 +0,0 @@
-// Copyright 2017 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 "net/third_party/quiche/src/quic/platform/api/quic_endian.h"
-
-#include "net/third_party/quiche/src/quic/platform/api/quic_test.h"
-
-namespace quic {
-namespace test {
-namespace {
-
-const uint16_t k16BitTestData = 0xaabb;
-const uint16_t k16BitSwappedTestData = 0xbbaa;
-const uint32_t k32BitTestData = 0xaabbccdd;
-const uint32_t k32BitSwappedTestData = 0xddccbbaa;
-const uint64_t k64BitTestData = 0xaabbccdd44332211;
-const uint64_t k64BitSwappedTestData = 0x11223344ddccbbaa;
-
-class QuicEndianTest : public QuicTest {};
-
-TEST_F(QuicEndianTest, HostToNet) {
-  if (QuicEndian::HostIsLittleEndian()) {
-    EXPECT_EQ(k16BitSwappedTestData, QuicEndian::HostToNet16(k16BitTestData));
-    EXPECT_EQ(k32BitSwappedTestData, QuicEndian::HostToNet32(k32BitTestData));
-    EXPECT_EQ(k64BitSwappedTestData, QuicEndian::HostToNet64(k64BitTestData));
-  } else {
-    EXPECT_EQ(k16BitTestData, QuicEndian::HostToNet16(k16BitTestData));
-    EXPECT_EQ(k32BitTestData, QuicEndian::HostToNet32(k32BitTestData));
-    EXPECT_EQ(k64BitTestData, QuicEndian::HostToNet64(k64BitTestData));
-  }
-}
-
-TEST_F(QuicEndianTest, NetToHost) {
-  if (QuicEndian::HostIsLittleEndian()) {
-    EXPECT_EQ(k16BitTestData, QuicEndian::NetToHost16(k16BitSwappedTestData));
-    EXPECT_EQ(k32BitTestData, QuicEndian::NetToHost32(k32BitSwappedTestData));
-    EXPECT_EQ(k64BitTestData, QuicEndian::NetToHost64(k64BitSwappedTestData));
-  } else {
-    EXPECT_EQ(k16BitSwappedTestData,
-              QuicEndian::NetToHost16(k16BitSwappedTestData));
-    EXPECT_EQ(k32BitSwappedTestData,
-              QuicEndian::NetToHost32(k32BitSwappedTestData));
-    EXPECT_EQ(k64BitSwappedTestData,
-              QuicEndian::NetToHost64(k64BitSwappedTestData));
-  }
-}
-
-}  // namespace
-}  // namespace test
-}  // namespace quic
diff --git a/quic/qbone/bonnet/icmp_reachable.cc b/quic/qbone/bonnet/icmp_reachable.cc
index 7779a8b..a6913d1 100644
--- a/quic/qbone/bonnet/icmp_reachable.cc
+++ b/quic/qbone/bonnet/icmp_reachable.cc
@@ -7,11 +7,11 @@
 #include <netinet/ip6.h>
 
 #include "net/third_party/quiche/src/quic/core/crypto/quic_random.h"
-#include "net/third_party/quiche/src/quic/platform/api/quic_endian.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_logging.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_mutex.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_text_utils.h"
 #include "net/third_party/quiche/src/quic/qbone/platform/icmp_packet.h"
+#include "net/third_party/quiche/src/common/platform/api/quiche_endian.h"
 
 namespace quic {
 namespace {
diff --git a/quic/qbone/platform/icmp_packet.cc b/quic/qbone/platform/icmp_packet.cc
index 8ba3916..9039944 100644
--- a/quic/qbone/platform/icmp_packet.cc
+++ b/quic/qbone/platform/icmp_packet.cc
@@ -5,8 +5,9 @@
 #include "net/third_party/quiche/src/quic/qbone/platform/icmp_packet.h"
 
 #include <netinet/ip6.h>
-#include "net/third_party/quiche/src/quic/platform/api/quic_endian.h"
+
 #include "net/third_party/quiche/src/quic/qbone/platform/internet_checksum.h"
+#include "net/third_party/quiche/src/common/platform/api/quiche_endian.h"
 
 namespace quic {
 namespace {
@@ -46,7 +47,8 @@
   // Set version to 6.
   icmp_packet.ip_header.ip6_vfc = 0x6 << 4;
   // Set the payload size, protocol and TTL.
-  icmp_packet.ip_header.ip6_plen = QuicEndian::HostToNet16(payload_size);
+  icmp_packet.ip_header.ip6_plen =
+      quiche::QuicheEndian::HostToNet16(payload_size);
   icmp_packet.ip_header.ip6_nxt = IPPROTO_ICMPV6;
   icmp_packet.ip_header.ip6_hops = kIcmpTtl;
   // Set the source address to the specified self IP.
@@ -58,7 +60,7 @@
   icmp_packet.icmp_header.icmp6_cksum = 0;
 
   IPv6PseudoHeader pseudo_header{};
-  pseudo_header.payload_size = QuicEndian::HostToNet32(payload_size);
+  pseudo_header.payload_size = quiche::QuicheEndian::HostToNet32(payload_size);
 
   InternetChecksum checksum;
   // Pseudoheader.
diff --git a/quic/qbone/platform/internet_checksum.cc b/quic/qbone/platform/internet_checksum.cc
index 9cbe227..b98c857 100644
--- a/quic/qbone/platform/internet_checksum.cc
+++ b/quic/qbone/platform/internet_checksum.cc
@@ -3,7 +3,6 @@
 // found in the LICENSE file.
 
 #include "net/third_party/quiche/src/quic/qbone/platform/internet_checksum.h"
-#include "net/third_party/quiche/src/quic/platform/api/quic_endian.h"
 
 namespace quic {
 
diff --git a/quic/qbone/platform/ip_range.cc b/quic/qbone/platform/ip_range.cc
index 15ebb72..03ad640 100644
--- a/quic/qbone/platform/ip_range.cc
+++ b/quic/qbone/platform/ip_range.cc
@@ -4,7 +4,7 @@
 
 #include "net/third_party/quiche/src/quic/qbone/platform/ip_range.h"
 
-#include "net/third_party/quiche/src/quic/platform/api/quic_endian.h"
+#include "net/third_party/quiche/src/common/platform/api/quiche_endian.h"
 
 namespace quic {
 
@@ -23,9 +23,9 @@
     }
     uint32_t raw_address =
         *reinterpret_cast<const uint32_t*>(input.ToPackedString().data());
-    raw_address = QuicEndian::NetToHost32(raw_address);
+    raw_address = quiche::QuicheEndian::NetToHost32(raw_address);
     raw_address &= ~0U << (kIPv4Size - *prefix_length);
-    raw_address = QuicEndian::HostToNet32(raw_address);
+    raw_address = quiche::QuicheEndian::HostToNet32(raw_address);
     output.FromPackedString(reinterpret_cast<const char*>(&raw_address),
                             sizeof(raw_address));
     return output;
@@ -42,16 +42,16 @@
     // out.
     // The endianess between raw_address[0] and raw_address[1] is handled
     // explicitly by handling lower and higher bytes separately.
-    raw_address[0] = QuicEndian::NetToHost64(raw_address[0]);
-    raw_address[1] = QuicEndian::NetToHost64(raw_address[1]);
+    raw_address[0] = quiche::QuicheEndian::NetToHost64(raw_address[0]);
+    raw_address[1] = quiche::QuicheEndian::NetToHost64(raw_address[1]);
     if (*prefix_length <= kIPv6Size / 2) {
       raw_address[0] &= ~uint64_t{0} << (kIPv6Size / 2 - *prefix_length);
       raw_address[1] = 0;
     } else {
       raw_address[1] &= ~uint64_t{0} << (kIPv6Size - *prefix_length);
     }
-    raw_address[0] = QuicEndian::HostToNet64(raw_address[0]);
-    raw_address[1] = QuicEndian::HostToNet64(raw_address[1]);
+    raw_address[0] = quiche::QuicheEndian::HostToNet64(raw_address[0]);
+    raw_address[1] = quiche::QuicheEndian::HostToNet64(raw_address[1]);
     output.FromPackedString(reinterpret_cast<const char*>(raw_address),
                             sizeof(raw_address));
     return output;
diff --git a/quic/qbone/platform/tcp_packet.cc b/quic/qbone/platform/tcp_packet.cc
index 56fa88a..2566d25 100644
--- a/quic/qbone/platform/tcp_packet.cc
+++ b/quic/qbone/platform/tcp_packet.cc
@@ -6,9 +6,9 @@
 
 #include <netinet/ip6.h>
 
-#include "net/third_party/quiche/src/quic/platform/api/quic_endian.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_logging.h"
 #include "net/third_party/quiche/src/quic/qbone/platform/internet_checksum.h"
+#include "net/third_party/quiche/src/common/platform/api/quiche_endian.h"
 
 namespace quic {
 namespace {
@@ -45,8 +45,8 @@
   if (QUIC_PREDICT_FALSE(ip6_header->ip6_nxt != IPPROTO_TCP)) {
     return;
   }
-  if (QUIC_PREDICT_FALSE(QuicEndian::NetToHost16(ip6_header->ip6_plen) <
-                         sizeof(tcphdr))) {
+  if (QUIC_PREDICT_FALSE(quiche::QuicheEndian::NetToHost16(
+                             ip6_header->ip6_plen) < sizeof(tcphdr))) {
     return;
   }
   auto* tcp_header = reinterpret_cast<const tcphdr*>(ip6_header + 1);
@@ -60,7 +60,8 @@
   // Set version to 6.
   tcp_packet.ip_header.ip6_vfc = 0x6 << 4;
   // Set the payload size, protocol and TTL.
-  tcp_packet.ip_header.ip6_plen = QuicEndian::HostToNet16(payload_size);
+  tcp_packet.ip_header.ip6_plen =
+      quiche::QuicheEndian::HostToNet16(payload_size);
   tcp_packet.ip_header.ip6_nxt = IPPROTO_TCP;
   tcp_packet.ip_header.ip6_hops = kTcpTtl;
   // Since the TCP RST is impersonating the endpoint, flip the source and
@@ -98,12 +99,12 @@
     // the sum of the sequence number and segment length of the incoming segment
     tcp_packet.tcp_header.ack = 1;
     tcp_packet.tcp_header.seq = 0;
-    tcp_packet.tcp_header.ack_seq =
-        QuicEndian::HostToNet32(QuicEndian::NetToHost32(tcp_header->seq) + 1);
+    tcp_packet.tcp_header.ack_seq = quiche::QuicheEndian::HostToNet32(
+        quiche::QuicheEndian::NetToHost32(tcp_header->seq) + 1);
   }
 
   TCPv6PseudoHeader pseudo_header{};
-  pseudo_header.payload_size = QuicEndian::HostToNet32(payload_size);
+  pseudo_header.payload_size = quiche::QuicheEndian::HostToNet32(payload_size);
 
   InternetChecksum checksum;
   // Pseudoheader.
diff --git a/quic/qbone/qbone_packet_processor.cc b/quic/qbone/qbone_packet_processor.cc
index db7a138..39b622b 100644
--- a/quic/qbone/qbone_packet_processor.cc
+++ b/quic/qbone/qbone_packet_processor.cc
@@ -7,11 +7,11 @@
 #include <cstring>
 
 #include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h"
-#include "net/third_party/quiche/src/quic/platform/api/quic_endian.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_logging.h"
 #include "net/third_party/quiche/src/quic/qbone/platform/icmp_packet.h"
 #include "net/third_party/quiche/src/quic/qbone/platform/internet_checksum.h"
 #include "net/third_party/quiche/src/quic/qbone/platform/tcp_packet.h"
+#include "net/third_party/quiche/src/common/platform/api/quiche_endian.h"
 
 namespace {
 
@@ -171,7 +171,7 @@
 
   // Check payload size.
   const size_t declared_payload_size =
-      QuicEndian::NetToHost16(header->ip6_plen);
+      quiche::QuicheEndian::NetToHost16(header->ip6_plen);
   const size_t actual_payload_size = packet->size() - kIPv6HeaderSize;
   if (declared_payload_size != actual_payload_size) {
     QUIC_DVLOG(1)
diff --git a/quic/quartc/quartc_stream_test.cc b/quic/quartc/quartc_stream_test.cc
index c8a68fc..0acaded 100644
--- a/quic/quartc/quartc_stream_test.cc
+++ b/quic/quartc/quartc_stream_test.cc
@@ -27,7 +27,6 @@
 #include "net/third_party/quiche/src/quic/core/quic_versions.h"
 #include "net/third_party/quiche/src/quic/core/quic_write_blocked_list.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_clock.h"
-#include "net/third_party/quiche/src/quic/platform/api/quic_endian.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_flags.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_ip_address.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_socket_address.h"
@@ -36,6 +35,7 @@
 #include "net/third_party/quiche/src/quic/quartc/quartc_factory.h"
 #include "net/third_party/quiche/src/quic/test_tools/mock_clock.h"
 #include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h"
+#include "net/third_party/quiche/src/common/platform/api/quiche_endian.h"
 #include "net/third_party/quiche/src/spdy/core/spdy_protocol.h"
 
 namespace quic {
@@ -73,7 +73,7 @@
     // WritevData does not pass down a iovec, data is saved in stream before
     // data is consumed. Retrieve data from stream.
     char* buf = new char[write_length];
-    QuicDataWriter writer(write_length, buf, NETWORK_BYTE_ORDER);
+    QuicDataWriter writer(write_length, buf, quiche::NETWORK_BYTE_ORDER);
     if (write_length > 0) {
       stream->WriteStreamData(offset, write_length, &writer);
     }
diff --git a/quic/test_tools/qpack/qpack_offline_decoder.cc b/quic/test_tools/qpack/qpack_offline_decoder.cc
index 1472dd4..a5a74aa 100644
--- a/quic/test_tools/qpack/qpack_offline_decoder.cc
+++ b/quic/test_tools/qpack/qpack_offline_decoder.cc
@@ -31,11 +31,11 @@
 #include <utility>
 
 #include "net/third_party/quiche/src/quic/core/quic_types.h"
-#include "net/third_party/quiche/src/quic/platform/api/quic_endian.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_file_utils.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_logging.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_text_utils.h"
 #include "net/third_party/quiche/src/quic/test_tools/qpack/qpack_test_utils.h"
+#include "net/third_party/quiche/src/common/platform/api/quiche_endian.h"
 
 namespace quic {
 
@@ -142,11 +142,11 @@
       return false;
     }
 
-    uint64_t stream_id = QuicEndian::NetToHost64(
+    uint64_t stream_id = quiche::QuicheEndian::NetToHost64(
         *reinterpret_cast<const uint64_t*>(input_data.data()));
     input_data = input_data.substr(sizeof(uint64_t));
 
-    uint32_t length = QuicEndian::NetToHost32(
+    uint32_t length = quiche::QuicheEndian::NetToHost32(
         *reinterpret_cast<const uint32_t*>(input_data.data()));
     input_data = input_data.substr(sizeof(uint32_t));
 
diff --git a/quic/test_tools/quic_test_utils.cc b/quic/test_tools/quic_test_utils.cc
index aeb4eee..1d2ec74 100644
--- a/quic/test_tools/quic_test_utils.cc
+++ b/quic/test_tools/quic_test_utils.cc
@@ -22,12 +22,12 @@
 #include "net/third_party/quiche/src/quic/core/quic_packet_creator.h"
 #include "net/third_party/quiche/src/quic/core/quic_utils.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_arraysize.h"
-#include "net/third_party/quiche/src/quic/platform/api/quic_endian.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_flags.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_logging.h"
 #include "net/third_party/quiche/src/quic/test_tools/crypto_test_utils.h"
 #include "net/third_party/quiche/src/quic/test_tools/quic_config_peer.h"
 #include "net/third_party/quiche/src/quic/test_tools/quic_connection_peer.h"
+#include "net/third_party/quiche/src/common/platform/api/quiche_endian.h"
 #include "net/third_party/quiche/src/spdy/core/spdy_frame_builder.h"
 
 using testing::_;
@@ -44,14 +44,14 @@
 
 QuicConnectionId TestConnectionId(uint64_t connection_number) {
   const uint64_t connection_id64_net =
-      QuicEndian::HostToNet64(connection_number);
+      quiche::QuicheEndian::HostToNet64(connection_number);
   return QuicConnectionId(reinterpret_cast<const char*>(&connection_id64_net),
                           sizeof(connection_id64_net));
 }
 
 QuicConnectionId TestConnectionIdNineBytesLong(uint64_t connection_number) {
   const uint64_t connection_number_net =
-      QuicEndian::HostToNet64(connection_number);
+      quiche::QuicheEndian::HostToNet64(connection_number);
   char connection_id_bytes[9] = {};
   static_assert(
       sizeof(connection_id_bytes) == 1 + sizeof(connection_number_net),
@@ -67,7 +67,7 @@
   memcpy(&connection_id64_net, connection_id.data(),
          std::min<size_t>(static_cast<size_t>(connection_id.length()),
                           sizeof(connection_id64_net)));
-  return QuicEndian::NetToHost64(connection_id64_net);
+  return quiche::QuicheEndian::NetToHost64(connection_id64_net);
 }
 
 QuicAckFrame InitAckFrame(const std::vector<QuicAckBlock>& ack_blocks) {
@@ -576,7 +576,7 @@
                                               StreamSendingState state) {
   if (write_length > 0) {
     auto buf = std::make_unique<char[]>(write_length);
-    QuicDataWriter writer(write_length, buf.get(), HOST_BYTE_ORDER);
+    QuicDataWriter writer(write_length, buf.get(), quiche::HOST_BYTE_ORDER);
     stream->WriteStreamData(offset, write_length, &writer);
   } else {
     DCHECK(state != NO_FIN);