Replace QUICHE_ARRAYSIZE with ABSL_ARRAYSIZE. Delete QUICHE_ARRAYSIZE. PiperOrigin-RevId: 338065680 Change-Id: I2e9c80c2cadb9c4386e4d848b76d6f197ac685ea
diff --git a/common/platform/api/quiche_arraysize.h b/common/platform/api/quiche_arraysize.h deleted file mode 100644 index 9e50d17..0000000 --- a/common/platform/api/quiche_arraysize.h +++ /dev/null
@@ -1,12 +0,0 @@ -// Copyright 2019 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef QUICHE_COMMON_PLATFORM_API_QUICHE_ARRAYSIZE_H_ -#define QUICHE_COMMON_PLATFORM_API_QUICHE_ARRAYSIZE_H_ - -#include "net/quiche/common/platform/impl/quiche_arraysize_impl.h" - -#define QUICHE_ARRAYSIZE(array) QUICHE_ARRAYSIZE_IMPL(array) - -#endif // QUICHE_COMMON_PLATFORM_API_QUICHE_ARRAYSIZE_H_
diff --git a/common/quiche_data_writer_test.cc b/common/quiche_data_writer_test.cc index 0c62568..22e8c08 100644 --- a/common/quiche_data_writer_test.cc +++ b/common/quiche_data_writer_test.cc
@@ -7,8 +7,8 @@ #include <cstdint> #include <cstring> +#include "absl/base/macros.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_arraysize.h" #include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" #include "net/third_party/quiche/src/common/platform/api/quiche_test.h" #include "net/third_party/quiche/src/common/quiche_data_reader.h" @@ -332,24 +332,24 @@ TEST_P(QuicheDataWriterTest, WriteBytes) { char bytes[] = {0, 1, 2, 3, 4, 5, 6, 7, 8}; - char buf[QUICHE_ARRAYSIZE(bytes)]; - QuicheDataWriter writer(QUICHE_ARRAYSIZE(buf), buf, GetParam().endianness); - EXPECT_TRUE(writer.WriteBytes(bytes, QUICHE_ARRAYSIZE(bytes))); - for (unsigned int i = 0; i < QUICHE_ARRAYSIZE(bytes); ++i) { + char buf[ABSL_ARRAYSIZE(bytes)]; + QuicheDataWriter writer(ABSL_ARRAYSIZE(buf), buf, GetParam().endianness); + EXPECT_TRUE(writer.WriteBytes(bytes, ABSL_ARRAYSIZE(bytes))); + for (unsigned int i = 0; i < ABSL_ARRAYSIZE(bytes); ++i) { EXPECT_EQ(bytes[i], buf[i]); } } TEST_P(QuicheDataWriterTest, Seek) { char buffer[3] = {}; - QuicheDataWriter writer(QUICHE_ARRAYSIZE(buffer), buffer, + QuicheDataWriter writer(ABSL_ARRAYSIZE(buffer), buffer, GetParam().endianness); EXPECT_TRUE(writer.WriteUInt8(42)); EXPECT_TRUE(writer.Seek(1)); EXPECT_TRUE(writer.WriteUInt8(3)); char expected[] = {42, 0, 3}; - for (size_t i = 0; i < QUICHE_ARRAYSIZE(expected); ++i) { + for (size_t i = 0; i < ABSL_ARRAYSIZE(expected); ++i) { EXPECT_EQ(buffer[i], expected[i]); } } @@ -359,7 +359,7 @@ // Check that one can seek to the end of the writer, but not past. { - QuicheDataWriter writer(QUICHE_ARRAYSIZE(buffer), buffer, + QuicheDataWriter writer(ABSL_ARRAYSIZE(buffer), buffer, GetParam().endianness); EXPECT_TRUE(writer.Seek(20)); EXPECT_FALSE(writer.Seek(1)); @@ -367,14 +367,14 @@ // Seeking several bytes past the end fails. { - QuicheDataWriter writer(QUICHE_ARRAYSIZE(buffer), buffer, + QuicheDataWriter writer(ABSL_ARRAYSIZE(buffer), buffer, GetParam().endianness); EXPECT_FALSE(writer.Seek(100)); } // Seeking so far that arithmetic overflow could occur also fails. { - QuicheDataWriter writer(QUICHE_ARRAYSIZE(buffer), buffer, + QuicheDataWriter writer(ABSL_ARRAYSIZE(buffer), buffer, GetParam().endianness); EXPECT_TRUE(writer.Seek(10)); EXPECT_FALSE(writer.Seek(std::numeric_limits<size_t>::max()));
diff --git a/http2/hpack/huffman/hpack_huffman_decoder_test.cc b/http2/hpack/huffman/hpack_huffman_decoder_test.cc index 46dd2a5..0ff3413 100644 --- a/http2/hpack/huffman/hpack_huffman_decoder_test.cc +++ b/http2/hpack/huffman/hpack_huffman_decoder_test.cc
@@ -8,12 +8,12 @@ #include <iostream> +#include "absl/base/macros.h" #include "net/third_party/quiche/src/http2/decoder/decode_buffer.h" #include "net/third_party/quiche/src/http2/decoder/decode_status.h" #include "net/third_party/quiche/src/http2/platform/api/http2_string_utils.h" #include "net/third_party/quiche/src/http2/platform/api/http2_test_helpers.h" #include "net/third_party/quiche/src/http2/tools/random_decoder_test.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_arraysize.h" #include "net/third_party/quiche/src/common/platform/api/quiche_test.h" using ::testing::AssertionResult; @@ -197,7 +197,7 @@ Http2HexDecode("25a849e95bb8e8b4bf"), "custom-value", }; - for (size_t i = 0; i != QUICHE_ARRAYSIZE(test_table); i += 2) { + for (size_t i = 0; i != ABSL_ARRAYSIZE(test_table); i += 2) { const std::string& huffman_encoded(test_table[i]); const std::string& plain_string(test_table[i + 1]); std::string buffer; @@ -228,7 +228,7 @@ "foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU; max-age=3600; version=1", }; // clang-format on - for (size_t i = 0; i != QUICHE_ARRAYSIZE(test_table); i += 2) { + for (size_t i = 0; i != ABSL_ARRAYSIZE(test_table); i += 2) { const std::string& huffman_encoded(test_table[i]); const std::string& plain_string(test_table[i + 1]); std::string buffer;
diff --git a/http2/hpack/huffman/hpack_huffman_encoder_test.cc b/http2/hpack/huffman/hpack_huffman_encoder_test.cc index 7fd899b..c9743f5 100644 --- a/http2/hpack/huffman/hpack_huffman_encoder_test.cc +++ b/http2/hpack/huffman/hpack_huffman_encoder_test.cc
@@ -4,8 +4,8 @@ #include "net/third_party/quiche/src/http2/hpack/huffman/hpack_huffman_encoder.h" +#include "absl/base/macros.h" #include "net/third_party/quiche/src/http2/platform/api/http2_string_utils.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_arraysize.h" #include "net/third_party/quiche/src/common/platform/api/quiche_test.h" namespace http2 { @@ -49,7 +49,7 @@ Http2HexDecode("25a849e95bb8e8b4bf"), "custom-value", }; - for (size_t i = 0; i != QUICHE_ARRAYSIZE(test_table); i += 2) { + for (size_t i = 0; i != ABSL_ARRAYSIZE(test_table); i += 2) { const std::string& huffman_encoded(test_table[i]); const std::string& plain_string(test_table[i + 1]); size_t encoded_size = HuffmanSize(plain_string); @@ -80,7 +80,7 @@ "foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU; max-age=3600; version=1", }; // clang-format on - for (size_t i = 0; i != QUICHE_ARRAYSIZE(test_table); i += 2) { + for (size_t i = 0; i != ABSL_ARRAYSIZE(test_table); i += 2) { const std::string& huffman_encoded(test_table[i]); const std::string& plain_string(test_table[i + 1]); size_t encoded_size = HuffmanSize(plain_string); @@ -103,10 +103,10 @@ }; // Modify last |test_table| entry to cover all codes. for (size_t i = 0; i != 256; ++i) { - test_table[QUICHE_ARRAYSIZE(test_table) - 1][i] = static_cast<char>(i); + test_table[ABSL_ARRAYSIZE(test_table) - 1][i] = static_cast<char>(i); } - for (size_t i = 0; i != QUICHE_ARRAYSIZE(test_table); ++i) { + for (size_t i = 0; i != ABSL_ARRAYSIZE(test_table); ++i) { const std::string& plain_string = test_table[i]; size_t encoded_size = HuffmanSize(plain_string); std::string huffman_encoded;
diff --git a/http2/hpack/varint/hpack_varint_decoder_test.cc b/http2/hpack/varint/hpack_varint_decoder_test.cc index 5b22f8b..7be2710 100644 --- a/http2/hpack/varint/hpack_varint_decoder_test.cc +++ b/http2/hpack/varint/hpack_varint_decoder_test.cc
@@ -8,11 +8,11 @@ #include <stddef.h> +#include "absl/base/macros.h" #include "absl/strings/string_view.h" #include "net/third_party/quiche/src/http2/platform/api/http2_logging.h" #include "net/third_party/quiche/src/http2/platform/api/http2_string_utils.h" #include "net/third_party/quiche/src/http2/tools/random_decoder_test.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_arraysize.h" #include "net/third_party/quiche/src/common/platform/api/quiche_test.h" using ::testing::AssertionFailure; @@ -260,7 +260,7 @@ }; TEST_P(HpackVarintDecoderTest, Success) { - for (size_t i = 0; i < QUICHE_ARRAYSIZE(kSuccessTestData); ++i) { + for (size_t i = 0; i < ABSL_ARRAYSIZE(kSuccessTestData); ++i) { DecodeExpectSuccess(Http2HexDecode(kSuccessTestData[i].data), kSuccessTestData[i].prefix_length, kSuccessTestData[i].expected_value); @@ -301,7 +301,7 @@ {"ff80feffffffffffffff8100", 8}}; TEST_P(HpackVarintDecoderTest, Error) { - for (size_t i = 0; i < QUICHE_ARRAYSIZE(kErrorTestData); ++i) { + for (size_t i = 0; i < ABSL_ARRAYSIZE(kErrorTestData); ++i) { DecodeExpectError(Http2HexDecode(kErrorTestData[i].data), kErrorTestData[i].prefix_length); }
diff --git a/http2/hpack/varint/hpack_varint_encoder_test.cc b/http2/hpack/varint/hpack_varint_encoder_test.cc index dcbff8a..979ffc5 100644 --- a/http2/hpack/varint/hpack_varint_encoder_test.cc +++ b/http2/hpack/varint/hpack_varint_encoder_test.cc
@@ -4,8 +4,8 @@ #include "net/third_party/quiche/src/http2/hpack/varint/hpack_varint_encoder.h" +#include "absl/base/macros.h" #include "net/third_party/quiche/src/http2/platform/api/http2_string_utils.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_arraysize.h" #include "net/third_party/quiche/src/common/platform/api/quiche_test.h" @@ -30,7 +30,7 @@ // Encode integers that fit in the prefix. TEST(HpackVarintEncoderTest, Short) { - for (size_t i = 0; i < QUICHE_ARRAYSIZE(kShortTestData); ++i) { + for (size_t i = 0; i < ABSL_ARRAYSIZE(kShortTestData); ++i) { std::string output; HpackVarintEncoder::Encode(kShortTestData[i].high_bits, kShortTestData[i].prefix_length, @@ -103,7 +103,7 @@ TEST(HpackVarintEncoderTest, Long) { // Test encoding byte by byte, also test encoding in // a single ResumeEncoding() call. - for (size_t i = 0; i < QUICHE_ARRAYSIZE(kLongTestData); ++i) { + for (size_t i = 0; i < ABSL_ARRAYSIZE(kLongTestData); ++i) { std::string expected_encoding = Http2HexDecode(kLongTestData[i].expected_encoding); @@ -130,7 +130,7 @@ // Make sure that the encoder outputs the last byte even when it is zero. This // happens exactly when encoding the value 2^prefix_length - 1. TEST(HpackVarintEncoderTest, LastByteIsZero) { - for (size_t i = 0; i < QUICHE_ARRAYSIZE(kLastByteIsZeroTestData); ++i) { + for (size_t i = 0; i < ABSL_ARRAYSIZE(kLastByteIsZeroTestData); ++i) { std::string output; HpackVarintEncoder::Encode(kLastByteIsZeroTestData[i].high_bits, kLastByteIsZeroTestData[i].prefix_length,
diff --git a/quic/platform/api/quic_hostname_utils_test.cc b/quic/platform/api/quic_hostname_utils_test.cc index eba97c4..d1808fb 100644 --- a/quic/platform/api/quic_hostname_utils_test.cc +++ b/quic/platform/api/quic_hostname_utils_test.cc
@@ -6,8 +6,8 @@ #include <string> +#include "absl/base/macros.h" #include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_arraysize.h" namespace quic { namespace test { @@ -78,7 +78,7 @@ }; // clang-format on - for (size_t i = 0; i < QUICHE_ARRAYSIZE(tests); ++i) { + for (size_t i = 0; i < ABSL_ARRAYSIZE(tests); ++i) { EXPECT_EQ(std::string(tests[i].expected), QuicHostnameUtils::NormalizeHostname(tests[i].input)); }
diff --git a/quic/quic_transport/quic_transport_client_session_test.cc b/quic/quic_transport/quic_transport_client_session_test.cc index fe85576..129c87e 100644 --- a/quic/quic_transport/quic_transport_client_session_test.cc +++ b/quic/quic_transport/quic_transport_client_session_test.cc
@@ -7,6 +7,7 @@ #include <memory> #include <utility> +#include "absl/base/macros.h" #include "url/gurl.h" #include "net/third_party/quiche/src/quic/core/quic_data_writer.h" #include "net/third_party/quiche/src/quic/core/quic_server_id.h" @@ -19,7 +20,6 @@ #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/quic/test_tools/quic_transport_test_tools.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_arraysize.h" namespace quic { namespace test { @@ -116,7 +116,7 @@ const std::string client_indication = DataInStream(client_indication_stream); const std::string expected_client_indication{ kTestOriginClientIndication, - QUICHE_ARRAYSIZE(kTestOriginClientIndication) - 1}; + ABSL_ARRAYSIZE(kTestOriginClientIndication) - 1}; EXPECT_EQ(client_indication, expected_client_indication); } @@ -142,7 +142,7 @@ const std::string client_indication = DataInStream(client_indication_stream); const std::string expected_client_indication{ kTestOriginClientIndication, - QUICHE_ARRAYSIZE(kTestOriginClientIndication) - 1}; + ABSL_ARRAYSIZE(kTestOriginClientIndication) - 1}; EXPECT_EQ(client_indication, expected_client_indication); }
diff --git a/quic/test_tools/fuzzing/quic_framer_process_data_packet_fuzzer.cc b/quic/test_tools/fuzzing/quic_framer_process_data_packet_fuzzer.cc index a35919e..2ceef38 100644 --- a/quic/test_tools/fuzzing/quic_framer_process_data_packet_fuzzer.cc +++ b/quic/test_tools/fuzzing/quic_framer_process_data_packet_fuzzer.cc
@@ -7,6 +7,7 @@ #include <cstdint> #include <string> +#include "absl/base/macros.h" #include "net/third_party/quiche/src/quic/core/crypto/null_decrypter.h" #include "net/third_party/quiche/src/quic/core/crypto/null_encrypter.h" #include "net/third_party/quiche/src/quic/core/quic_connection_id.h" @@ -18,7 +19,6 @@ #include "net/third_party/quiche/src/quic/core/quic_versions.h" #include "net/third_party/quiche/src/quic/test_tools/quic_framer_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_arraysize.h" using quic::DiversificationNonce; using quic::EncryptionLevel; @@ -65,7 +65,7 @@ return ParsedQuicVersion( quic::PROTOCOL_QUIC_CRYPTO, transport_versions[provider->ConsumeIntegralInRange<uint8_t>( - 0, QUICHE_ARRAYSIZE(transport_versions) - 1)]); + 0, ABSL_ARRAYSIZE(transport_versions) - 1)]); } // QuicSelfContainedPacketHeader is a QuicPacketHeader with built-in stroage for
diff --git a/quic/test_tools/quic_test_utils.cc b/quic/test_tools/quic_test_utils.cc index 9f58985..b286764 100644 --- a/quic/test_tools/quic_test_utils.cc +++ b/quic/test_tools/quic_test_utils.cc
@@ -9,6 +9,7 @@ #include <memory> #include <utility> +#include "absl/base/macros.h" #include "absl/strings/string_view.h" #include "third_party/boringssl/src/include/openssl/chacha.h" #include "third_party/boringssl/src/include/openssl/sha.h" @@ -35,7 +36,6 @@ #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_arraysize.h" #include "net/third_party/quiche/src/common/quiche_endian.h" #include "net/third_party/quiche/src/spdy/core/spdy_frame_builder.h" @@ -206,7 +206,7 @@ char buffer[SHA_DIGEST_LENGTH]; SHA1(reinterpret_cast<const uint8_t*>(data.data()), data.size(), reinterpret_cast<uint8_t*>(buffer)); - return std::string(buffer, QUICHE_ARRAYSIZE(buffer)); + return std::string(buffer, ABSL_ARRAYSIZE(buffer)); } bool ClearControlFrame(const QuicFrame& frame) {
diff --git a/quic/test_tools/test_ticket_crypter.cc b/quic/test_tools/test_ticket_crypter.cc index afd2db4..87ff202 100644 --- a/quic/test_tools/test_ticket_crypter.cc +++ b/quic/test_tools/test_ticket_crypter.cc
@@ -6,7 +6,7 @@ #include <cstring> -#include "net/third_party/quiche/src/common/platform/api/quiche_arraysize.h" +#include "absl/base/macros.h" namespace quic { namespace test { @@ -26,11 +26,11 @@ } // namespace size_t TestTicketCrypter::MaxOverhead() { - return QUICHE_ARRAYSIZE(kTicketPrefix); + return ABSL_ARRAYSIZE(kTicketPrefix); } std::vector<uint8_t> TestTicketCrypter::Encrypt(absl::string_view in) { - size_t prefix_len = QUICHE_ARRAYSIZE(kTicketPrefix); + size_t prefix_len = ABSL_ARRAYSIZE(kTicketPrefix); std::vector<uint8_t> out(prefix_len + in.size()); memcpy(out.data(), kTicketPrefix, prefix_len); memcpy(out.data() + prefix_len, in.data(), in.size()); @@ -38,7 +38,7 @@ } std::vector<uint8_t> TestTicketCrypter::Decrypt(absl::string_view in) { - size_t prefix_len = QUICHE_ARRAYSIZE(kTicketPrefix); + size_t prefix_len = ABSL_ARRAYSIZE(kTicketPrefix); if (fail_decrypt_ || in.size() < prefix_len || memcmp(kTicketPrefix, in.data(), prefix_len) != 0) { return std::vector<uint8_t>();
diff --git a/quic/tools/quic_server_test.cc b/quic/tools/quic_server_test.cc index 3c43720..06aa105 100644 --- a/quic/tools/quic_server_test.cc +++ b/quic/tools/quic_server_test.cc
@@ -4,6 +4,7 @@ #include "net/third_party/quiche/src/quic/tools/quic_server.h" +#include "absl/base/macros.h" #include "net/third_party/quiche/src/quic/core/crypto/quic_random.h" #include "net/third_party/quiche/src/quic/core/quic_epoll_alarm_factory.h" #include "net/third_party/quiche/src/quic/core/quic_epoll_connection_helper.h" @@ -19,7 +20,6 @@ #include "net/third_party/quiche/src/quic/test_tools/quic_server_peer.h" #include "net/third_party/quiche/src/quic/tools/quic_memory_cache_backend.h" #include "net/third_party/quiche/src/quic/tools/quic_simple_crypto_server_stream_helper.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_arraysize.h" namespace quic { namespace test { @@ -136,9 +136,9 @@ ASSERT_LT(0, fd); char buf[1024]; - memset(buf, 0, QUICHE_ARRAYSIZE(buf)); + memset(buf, 0, ABSL_ARRAYSIZE(buf)); sockaddr_storage storage = server_address_.generic_address(); - int rc = sendto(fd, buf, QUICHE_ARRAYSIZE(buf), 0, + int rc = sendto(fd, buf, ABSL_ARRAYSIZE(buf), 0, reinterpret_cast<sockaddr*>(&storage), sizeof(storage)); if (rc < 0) { QUIC_DLOG(INFO) << errno << " " << strerror(errno); @@ -202,7 +202,7 @@ }; // clang-format on QuicReceivedPacket encrypted_valid_packet( - reinterpret_cast<char*>(valid_packet), QUICHE_ARRAYSIZE(valid_packet), + reinterpret_cast<char*>(valid_packet), ABSL_ARRAYSIZE(valid_packet), QuicTime::Zero(), false); EXPECT_CALL(dispatcher_, ProcessPacket(_, _, _)).Times(1);
diff --git a/quic/tools/quic_simple_server_stream_test.cc b/quic/tools/quic_simple_server_stream_test.cc index 251f02d..c4d4572 100644 --- a/quic/tools/quic_simple_server_stream_test.cc +++ b/quic/tools/quic_simple_server_stream_test.cc
@@ -8,6 +8,7 @@ #include <memory> #include <utility> +#include "absl/base/macros.h" #include "absl/strings/string_view.h" #include "absl/types/optional.h" #include "net/third_party/quiche/src/quic/core/http/http_encoder.h" @@ -29,7 +30,6 @@ #include "net/third_party/quiche/src/quic/tools/quic_backend_response.h" #include "net/third_party/quiche/src/quic/tools/quic_memory_cache_backend.h" #include "net/third_party/quiche/src/quic/tools/quic_simple_server_session.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_arraysize.h" using testing::_; using testing::AnyNumber; @@ -772,7 +772,7 @@ 0x54, 0x54, 0x50, 0x2f, // TTP/ 0x31, 0x2e, 0x31, // 1.1 }; - absl::string_view data(arr, QUICHE_ARRAYSIZE(arr)); + absl::string_view data(arr, ABSL_ARRAYSIZE(arr)); QuicStreamFrame frame(stream_->id(), true, 0, data); // Verify that we don't crash when we get a invalid headers in stream frame. stream_->OnStreamFrame(frame);