Remove spdy_endianness_util.
Use quiche/common/quiche_endian.h instead.
PiperOrigin-RevId: 337654862
Change-Id: If5934e6121425bd2887319efda71b64f37d07e35
diff --git a/spdy/core/http2_frame_decoder_adapter.cc b/spdy/core/http2_frame_decoder_adapter.cc
index 8f62a93..1313c7d 100644
--- a/spdy/core/http2_frame_decoder_adapter.cc
+++ b/spdy/core/http2_frame_decoder_adapter.cc
@@ -21,6 +21,7 @@
#include "net/third_party/quiche/src/http2/decoder/http2_frame_decoder_listener.h"
#include "net/third_party/quiche/src/http2/http2_constants.h"
#include "net/third_party/quiche/src/http2/http2_structures.h"
+#include "net/third_party/quiche/src/common/quiche_endian.h"
#include "net/third_party/quiche/src/spdy/core/hpack/hpack_decoder_adapter.h"
#include "net/third_party/quiche/src/spdy/core/hpack/hpack_header_table.h"
#include "net/third_party/quiche/src/spdy/core/spdy_alt_svc_wire_format.h"
@@ -28,7 +29,6 @@
#include "net/third_party/quiche/src/spdy/core/spdy_headers_handler_interface.h"
#include "net/third_party/quiche/src/spdy/core/spdy_protocol.h"
#include "net/third_party/quiche/src/spdy/platform/api/spdy_bug_tracker.h"
-#include "net/third_party/quiche/src/spdy/platform/api/spdy_endianness_util.h"
#include "net/third_party/quiche/src/spdy/platform/api/spdy_estimate_memory_usage.h"
#include "net/third_party/quiche/src/spdy/platform/api/spdy_flags.h"
#include "net/third_party/quiche/src/spdy/platform/api/spdy_logging.h"
@@ -67,7 +67,7 @@
uint64_t ToSpdyPingId(const Http2PingFields& ping) {
uint64_t v;
std::memcpy(&v, ping.opaque_bytes, Http2PingFields::EncodedSize());
- return spdy::SpdyNetToHost64(v);
+ return quiche::QuicheEndian::NetToHost64(v);
}
// Overwrites the fields of the header with invalid values, for the purpose
diff --git a/spdy/core/spdy_frame_builder.h b/spdy/core/spdy_frame_builder.h
index f840099..9079a72 100644
--- a/spdy/core/spdy_frame_builder.h
+++ b/spdy/core/spdy_frame_builder.h
@@ -11,10 +11,10 @@
#include "absl/strings/string_view.h"
#include "net/third_party/quiche/src/common/platform/api/quiche_export.h"
+#include "net/third_party/quiche/src/common/quiche_endian.h"
#include "net/third_party/quiche/src/spdy/core/spdy_protocol.h"
#include "net/third_party/quiche/src/spdy/core/zero_copy_output_buffer.h"
#include "net/third_party/quiche/src/spdy/platform/api/spdy_bug_tracker.h"
-#include "net/third_party/quiche/src/spdy/platform/api/spdy_endianness_util.h"
namespace spdy {
@@ -83,20 +83,22 @@
// host to network form.
bool WriteUInt8(uint8_t value) { return WriteBytes(&value, sizeof(value)); }
bool WriteUInt16(uint16_t value) {
- value = SpdyHostToNet16(value);
+ value = quiche::QuicheEndian::HostToNet16(value);
return WriteBytes(&value, sizeof(value));
}
bool WriteUInt24(uint32_t value) {
- value = SpdyHostToNet32(value);
+ value = quiche::QuicheEndian::HostToNet32(value);
return WriteBytes(reinterpret_cast<char*>(&value) + 1, sizeof(value) - 1);
}
bool WriteUInt32(uint32_t value) {
- value = SpdyHostToNet32(value);
+ value = quiche::QuicheEndian::HostToNet32(value);
return WriteBytes(&value, sizeof(value));
}
bool WriteUInt64(uint64_t value) {
- uint32_t upper = SpdyHostToNet32(static_cast<uint32_t>(value >> 32));
- uint32_t lower = SpdyHostToNet32(static_cast<uint32_t>(value));
+ uint32_t upper =
+ quiche::QuicheEndian::HostToNet32(static_cast<uint32_t>(value >> 32));
+ uint32_t lower =
+ quiche::QuicheEndian::HostToNet32(static_cast<uint32_t>(value));
return (WriteBytes(&upper, sizeof(upper)) &&
WriteBytes(&lower, sizeof(lower)));
}
diff --git a/spdy/core/spdy_frame_reader.cc b/spdy/core/spdy_frame_reader.cc
index a76beb3..a53a8ac 100644
--- a/spdy/core/spdy_frame_reader.cc
+++ b/spdy/core/spdy_frame_reader.cc
@@ -4,8 +4,8 @@
#include "net/third_party/quiche/src/spdy/core/spdy_frame_reader.h"
+#include "net/third_party/quiche/src/common/quiche_endian.h"
#include "net/third_party/quiche/src/spdy/core/spdy_protocol.h"
-#include "net/third_party/quiche/src/spdy/platform/api/spdy_endianness_util.h"
namespace spdy {
@@ -36,7 +36,8 @@
}
// Read into result.
- *result = SpdyNetToHost16(*(reinterpret_cast<const uint16_t*>(data_ + ofs_)));
+ *result = quiche::QuicheEndian::NetToHost16(
+ *(reinterpret_cast<const uint16_t*>(data_ + ofs_)));
// Iterate.
ofs_ += 2;
@@ -52,7 +53,8 @@
}
// Read into result.
- *result = SpdyNetToHost32(*(reinterpret_cast<const uint32_t*>(data_ + ofs_)));
+ *result = quiche::QuicheEndian::NetToHost32(
+ *(reinterpret_cast<const uint32_t*>(data_ + ofs_)));
// Iterate.
ofs_ += 4;
@@ -68,10 +70,10 @@
}
// Read into result. Network byte order is big-endian.
- uint64_t upper =
- SpdyNetToHost32(*(reinterpret_cast<const uint32_t*>(data_ + ofs_)));
- uint64_t lower =
- SpdyNetToHost32(*(reinterpret_cast<const uint32_t*>(data_ + ofs_ + 4)));
+ uint64_t upper = quiche::QuicheEndian::NetToHost32(
+ *(reinterpret_cast<const uint32_t*>(data_ + ofs_)));
+ uint64_t lower = quiche::QuicheEndian::NetToHost32(
+ *(reinterpret_cast<const uint32_t*>(data_ + ofs_ + 4)));
*result = (upper << 32) + lower;
// Iterate.
@@ -101,7 +103,7 @@
// Read into result.
*result = 0;
memcpy(reinterpret_cast<char*>(result) + 1, data_ + ofs_, 3);
- *result = SpdyNetToHost32(*result);
+ *result = quiche::QuicheEndian::NetToHost32(*result);
// Iterate.
ofs_ += 3;
diff --git a/spdy/core/spdy_frame_reader_test.cc b/spdy/core/spdy_frame_reader_test.cc
index 2a79caf..df0dfcc 100644
--- a/spdy/core/spdy_frame_reader_test.cc
+++ b/spdy/core/spdy_frame_reader_test.cc
@@ -8,15 +8,15 @@
#include "net/third_party/quiche/src/common/platform/api/quiche_arraysize.h"
#include "net/third_party/quiche/src/common/platform/api/quiche_test.h"
-#include "net/third_party/quiche/src/spdy/platform/api/spdy_endianness_util.h"
+#include "net/third_party/quiche/src/common/quiche_endian.h"
namespace spdy {
TEST(SpdyFrameReaderTest, ReadUInt16) {
// Frame data in network byte order.
const uint16_t kFrameData[] = {
- SpdyHostToNet16(1),
- SpdyHostToNet16(1 << 15),
+ quiche::QuicheEndian::HostToNet16(1),
+ quiche::QuicheEndian::HostToNet16(1 << 15),
};
SpdyFrameReader frame_reader(reinterpret_cast<const char*>(kFrameData),
@@ -36,8 +36,8 @@
TEST(SpdyFrameReaderTest, ReadUInt32) {
// Frame data in network byte order.
const uint32_t kFrameData[] = {
- SpdyHostToNet32(1),
- SpdyHostToNet32(0x80000000),
+ quiche::QuicheEndian::HostToNet32(1),
+ quiche::QuicheEndian::HostToNet32(0x80000000),
};
SpdyFrameReader frame_reader(reinterpret_cast<const char*>(kFrameData),
diff --git a/spdy/core/spdy_test_utils.cc b/spdy/core/spdy_test_utils.cc
index cf926b4..6eb15ec 100644
--- a/spdy/core/spdy_test_utils.cc
+++ b/spdy/core/spdy_test_utils.cc
@@ -12,7 +12,7 @@
#include <vector>
#include "net/third_party/quiche/src/common/platform/api/quiche_test.h"
-#include "net/third_party/quiche/src/spdy/platform/api/spdy_endianness_util.h"
+#include "net/third_party/quiche/src/common/quiche_endian.h"
#include "net/third_party/quiche/src/spdy/platform/api/spdy_logging.h"
namespace spdy {
@@ -95,7 +95,7 @@
void SetFrameLength(SpdySerializedFrame* frame, size_t length) {
CHECK_GT(1u << 14, length);
{
- int32_t wire_length = SpdyHostToNet32(length);
+ int32_t wire_length = quiche::QuicheEndian::HostToNet32(length);
memcpy(frame->data(), reinterpret_cast<char*>(&wire_length) + 1, 3);
}
}
diff --git a/spdy/platform/api/spdy_endianness_util.h b/spdy/platform/api/spdy_endianness_util.h
deleted file mode 100644
index e4074d7..0000000
--- a/spdy/platform/api/spdy_endianness_util.h
+++ /dev/null
@@ -1,44 +0,0 @@
-// Copyright (c) 2018 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_SPDY_PLATFORM_API_SPDY_ENDIANNESS_UTIL_H_
-#define QUICHE_SPDY_PLATFORM_API_SPDY_ENDIANNESS_UTIL_H_
-
-#include <stdint.h>
-
-#include "net/spdy/platform/impl/spdy_endianness_util_impl.h"
-
-namespace spdy {
-
-// Converts the bytes in |x| from network to host order (endianness), and
-// returns the result.
-inline uint16_t SpdyNetToHost16(uint16_t x) {
- return SpdyNetToHost16Impl(x);
-}
-
-inline uint32_t SpdyNetToHost32(uint32_t x) {
- return SpdyNetToHost32Impl(x);
-}
-
-inline uint64_t SpdyNetToHost64(uint64_t x) {
- return SpdyNetToHost64Impl(x);
-}
-
-// Converts the bytes in |x| from host to network order (endianness), and
-// returns the result.
-inline uint16_t SpdyHostToNet16(uint16_t x) {
- return SpdyHostToNet16Impl(x);
-}
-
-inline uint32_t SpdyHostToNet32(uint32_t x) {
- return SpdyHostToNet32Impl(x);
-}
-
-inline uint64_t SpdyHostToNet64(uint64_t x) {
- return SpdyHostToNet64Impl(x);
-}
-
-} // namespace spdy
-
-#endif // QUICHE_SPDY_PLATFORM_API_SPDY_ENDIANNESS_UTIL_H_