Use absl::StartsWith/EndsWith in QUIC directly.
PiperOrigin-RevId: 339124179
Change-Id: Icc501c054ab354387b8ff0af567d6b14ce5634cb
diff --git a/common/platform/api/quiche_text_utils.h b/common/platform/api/quiche_text_utils.h
index 3e83063..4de3647 100644
--- a/common/platform/api/quiche_text_utils.h
+++ b/common/platform/api/quiche_text_utils.h
@@ -17,22 +17,6 @@
// Various utilities for manipulating text.
class QUICHE_EXPORT QuicheTextUtils {
public:
- // Returns true if |data| starts with |prefix|, case sensitively.
- static bool StartsWith(absl::string_view data, absl::string_view prefix) {
- return quiche::QuicheTextUtilsImpl::StartsWith(data, prefix);
- }
-
- // Returns true if |data| ends with |suffix|, case sensitively.
- static bool EndsWith(absl::string_view data, absl::string_view suffix) {
- return quiche::QuicheTextUtilsImpl::EndsWith(data, suffix);
- }
-
- // Returns true if |data| ends with |suffix|, case insensitively.
- static bool EndsWithIgnoreCase(absl::string_view data,
- absl::string_view suffix) {
- return quiche::QuicheTextUtilsImpl::EndsWithIgnoreCase(data, suffix);
- }
-
// Returns a new string in which |data| has been converted to lower case.
static std::string ToLower(absl::string_view data) {
return quiche::QuicheTextUtilsImpl::ToLower(data);
diff --git a/common/platform/api/quiche_text_utils_test.cc b/common/platform/api/quiche_text_utils_test.cc
index c2f302d..bbea2cd 100644
--- a/common/platform/api/quiche_text_utils_test.cc
+++ b/common/platform/api/quiche_text_utils_test.cc
@@ -13,28 +13,6 @@
class QuicheTextUtilsTest : public QuicheTest {};
-TEST_F(QuicheTextUtilsTest, StartsWith) {
- EXPECT_TRUE(quiche::QuicheTextUtils::StartsWith("hello world", "hello"));
- EXPECT_TRUE(
- quiche::QuicheTextUtils::StartsWith("hello world", "hello world"));
- EXPECT_TRUE(quiche::QuicheTextUtils::StartsWith("hello world", ""));
- EXPECT_FALSE(quiche::QuicheTextUtils::StartsWith("hello world", "Hello"));
- EXPECT_FALSE(quiche::QuicheTextUtils::StartsWith("hello world", "world"));
- EXPECT_FALSE(quiche::QuicheTextUtils::StartsWith("hello world", "bar"));
-}
-
-TEST_F(QuicheTextUtilsTest, EndsWithIgnoreCase) {
- EXPECT_TRUE(
- quiche::QuicheTextUtils::EndsWithIgnoreCase("hello world", "world"));
- EXPECT_TRUE(quiche::QuicheTextUtils::EndsWithIgnoreCase("hello world",
- "hello world"));
- EXPECT_TRUE(quiche::QuicheTextUtils::EndsWithIgnoreCase("hello world", ""));
- EXPECT_TRUE(
- quiche::QuicheTextUtils::EndsWithIgnoreCase("hello world", "WORLD"));
- EXPECT_FALSE(
- quiche::QuicheTextUtils::EndsWithIgnoreCase("hello world", "hello"));
-}
-
TEST_F(QuicheTextUtilsTest, ToLower) {
EXPECT_EQ("lower", quiche::QuicheTextUtils::ToLower("LOWER"));
EXPECT_EQ("lower", quiche::QuicheTextUtils::ToLower("lower"));
diff --git a/quic/core/chlo_extractor.cc b/quic/core/chlo_extractor.cc
index e469e0d..851967a 100644
--- a/quic/core/chlo_extractor.cc
+++ b/quic/core/chlo_extractor.cc
@@ -4,6 +4,7 @@
#include "net/third_party/quiche/src/quic/core/chlo_extractor.h"
+#include "absl/strings/match.h"
#include "absl/strings/string_view.h"
#include "net/third_party/quiche/src/quic/core/crypto/crypto_framer.h"
#include "net/third_party/quiche/src/quic/core/crypto/crypto_handshake.h"
@@ -160,7 +161,7 @@
absl::string_view data(frame.data_buffer, frame.data_length);
if (QuicUtils::IsCryptoStreamId(framer_->transport_version(),
frame.stream_id) &&
- frame.offset == 0 && quiche::QuicheTextUtils::StartsWith(data, "CHLO")) {
+ frame.offset == 0 && absl::StartsWith(data, "CHLO")) {
return OnHandshakeData(data);
}
return true;
@@ -172,7 +173,7 @@
return false;
}
absl::string_view data(frame.data_buffer, frame.data_length);
- if (frame.offset == 0 && quiche::QuicheTextUtils::StartsWith(data, "CHLO")) {
+ if (frame.offset == 0 && absl::StartsWith(data, "CHLO")) {
return OnHandshakeData(data);
}
return true;
diff --git a/quic/core/crypto/certificate_view.cc b/quic/core/crypto/certificate_view.cc
index 2335769..58cfe19 100644
--- a/quic/core/crypto/certificate_view.cc
+++ b/quic/core/crypto/certificate_view.cc
@@ -9,6 +9,7 @@
#include <memory>
#include <string>
+#include "absl/strings/match.h"
#include "absl/strings/string_view.h"
#include "absl/types/optional.h"
#include "third_party/boringssl/src/include/openssl/base.h"
@@ -149,8 +150,8 @@
QuicheTextUtils::RemoveLeadingAndTrailingWhitespace(&line);
// Handle BEGIN lines.
- if (!pending_message && QuicheTextUtils::StartsWith(line, kPemBegin) &&
- QuicheTextUtils::EndsWith(line, kPemDashes)) {
+ if (!pending_message && absl::StartsWith(line, kPemBegin) &&
+ absl::EndsWith(line, kPemDashes)) {
result.type = std::string(
line.substr(kPemBegin.size(),
line.size() - kPemDashes.size() - kPemBegin.size()));
diff --git a/quic/core/crypto/quic_crypto_client_config.cc b/quic/core/crypto/quic_crypto_client_config.cc
index c54c5d3..1026781 100644
--- a/quic/core/crypto/quic_crypto_client_config.cc
+++ b/quic/core/crypto/quic_crypto_client_config.cc
@@ -9,6 +9,7 @@
#include <string>
#include "absl/base/macros.h"
+#include "absl/strings/match.h"
#include "absl/strings/string_view.h"
#include "third_party/boringssl/src/include/openssl/ssl.h"
#include "net/third_party/quiche/src/quic/core/crypto/cert_compressor.h"
@@ -858,8 +859,7 @@
DCHECK(server_state->IsEmpty());
size_t i = 0;
for (; i < canonical_suffixes_.size(); ++i) {
- if (quiche::QuicheTextUtils::EndsWithIgnoreCase(server_id.host(),
- canonical_suffixes_[i])) {
+ if (absl::EndsWithIgnoreCase(server_id.host(), canonical_suffixes_[i])) {
break;
}
}
diff --git a/quic/core/crypto/quic_crypto_server_config_test.cc b/quic/core/crypto/quic_crypto_server_config_test.cc
index b91113d..e612a33 100644
--- a/quic/core/crypto/quic_crypto_server_config_test.cc
+++ b/quic/core/crypto/quic_crypto_server_config_test.cc
@@ -9,6 +9,7 @@
#include <memory>
#include <string>
+#include "absl/strings/match.h"
#include "absl/strings/string_view.h"
#include "net/third_party/quiche/src/quic/core/crypto/cert_compressor.h"
#include "net/third_party/quiche/src/quic/core/crypto/chacha20_poly1305_encrypter.h"
@@ -355,8 +356,7 @@
QuicCryptoServerConfig::GenerateConfig(rand_, &clock_, options);
protobuf.set_primary_time(primary_time);
protobuf.set_priority(priority);
- if (quiche::QuicheTextUtils::StartsWith(std::string(server_config_id),
- "INVALID")) {
+ if (absl::StartsWith(std::string(server_config_id), "INVALID")) {
protobuf.clear_key();
has_invalid = true;
}
diff --git a/quic/core/quic_framer_test.cc b/quic/core/quic_framer_test.cc
index 2fbab61..aa7fa8b 100644
--- a/quic/core/quic_framer_test.cc
+++ b/quic/core/quic_framer_test.cc
@@ -13,6 +13,7 @@
#include <vector>
#include "absl/base/macros.h"
+#include "absl/strings/match.h"
#include "absl/strings/string_view.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"
@@ -4080,8 +4081,8 @@
AsChars(framer_.version().HasIetfInvariantHeader() ? packet46 : packet),
ABSL_ARRAYSIZE(packet), false);
EXPECT_FALSE(framer_.ProcessPacket(encrypted));
- EXPECT_TRUE(quiche::QuicheTextUtils::StartsWith(
- framer_.detailed_error(), "delta_from_largest_observed too high"));
+ EXPECT_TRUE(absl::StartsWith(framer_.detailed_error(),
+ "delta_from_largest_observed too high"));
}
TEST_P(QuicFramerTest, AckFrameTimeStampSecondDeltaTooHigh) {
@@ -4153,8 +4154,8 @@
AsChars(framer_.version().HasIetfInvariantHeader() ? packet46 : packet),
ABSL_ARRAYSIZE(packet), false);
EXPECT_FALSE(framer_.ProcessPacket(encrypted));
- EXPECT_TRUE(quiche::QuicheTextUtils::StartsWith(
- framer_.detailed_error(), "delta_from_largest_observed too high"));
+ EXPECT_TRUE(absl::StartsWith(framer_.detailed_error(),
+ "delta_from_largest_observed too high"));
}
TEST_P(QuicFramerTest, NewStopWaitingFrame) {
diff --git a/quic/test_tools/qpack/qpack_offline_decoder.cc b/quic/test_tools/qpack/qpack_offline_decoder.cc
index 2fcf62a..211417f 100644
--- a/quic/test_tools/qpack/qpack_offline_decoder.cc
+++ b/quic/test_tools/qpack/qpack_offline_decoder.cc
@@ -30,6 +30,7 @@
#include <string>
#include <utility>
+#include "absl/strings/match.h"
#include "absl/strings/string_view.h"
#include "net/third_party/quiche/src/quic/core/quic_types.h"
#include "net/third_party/quiche/src/quic/platform/api/quic_file_utils.h"
@@ -316,8 +317,7 @@
decoded_header_list.begin();
decoded_it != decoded_header_list.end();) {
const absl::string_view key = decoded_it->first;
- if (key != kContentLength &&
- !quiche::QuicheTextUtils::StartsWith(key, kPseudoHeaderPrefix)) {
+ if (key != kContentLength && !absl::StartsWith(key, kPseudoHeaderPrefix)) {
++decoded_it;
continue;
}
diff --git a/quic/test_tools/quic_test_client.cc b/quic/test_tools/quic_test_client.cc
index ee99d9d..8896cac 100644
--- a/quic/test_tools/quic_test_client.cc
+++ b/quic/test_tools/quic_test_client.cc
@@ -8,6 +8,7 @@
#include <utility>
#include <vector>
+#include "absl/strings/match.h"
#include "absl/strings/string_view.h"
#include "third_party/boringssl/src/include/openssl/x509.h"
#include "net/third_party/quiche/src/quic/core/crypto/proof_verifier.h"
@@ -939,8 +940,7 @@
const std::string& uri,
spdy::SpdyHeaderBlock* headers) {
std::string url;
- if (quiche::QuicheTextUtils::StartsWith(uri, "https://") ||
- quiche::QuicheTextUtils::StartsWith(uri, "http://")) {
+ if (absl::StartsWith(uri, "https://") || absl::StartsWith(uri, "http://")) {
url = uri;
} else if (uri[0] == '/') {
url = "https://" + client_->server_id().host() + uri;
diff --git a/quic/tools/quic_client_test.cc b/quic/tools/quic_client_test.cc
index 219fa70..034c4dd 100644
--- a/quic/tools/quic_client_test.cc
+++ b/quic/tools/quic_client_test.cc
@@ -10,6 +10,7 @@
#include <memory>
#include <utility>
+#include "absl/strings/match.h"
#include "absl/strings/string_view.h"
#include "net/third_party/quiche/src/quic/platform/api/quic_epoll.h"
#include "net/third_party/quiche/src/quic/platform/api/quic_port_utils.h"
@@ -46,7 +47,7 @@
}
std::string fd_path = ReadLink(quiche::QuicheStrCat(kPathToFds, "/", name));
- if (quiche::QuicheTextUtils::StartsWith(fd_path, "socket:")) {
+ if (absl::StartsWith(fd_path, "socket:")) {
socket_count++;
}
}
diff --git a/quic/tools/quic_memory_cache_backend.cc b/quic/tools/quic_memory_cache_backend.cc
index 497cdfd..84596fd 100644
--- a/quic/tools/quic_memory_cache_backend.cc
+++ b/quic/tools/quic_memory_cache_backend.cc
@@ -6,6 +6,7 @@
#include <utility>
+#include "absl/strings/match.h"
#include "absl/strings/string_view.h"
#include "net/third_party/quiche/src/quic/core/http/spdy_utils.h"
#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h"
@@ -122,9 +123,9 @@
absl::string_view QuicMemoryCacheBackend::ResourceFile::RemoveScheme(
absl::string_view url) {
- if (quiche::QuicheTextUtils::StartsWith(url, "https://")) {
+ if (absl::StartsWith(url, "https://")) {
url.remove_prefix(8);
- } else if (quiche::QuicheTextUtils::StartsWith(url, "http://")) {
+ } else if (absl::StartsWith(url, "http://")) {
url.remove_prefix(7);
}
return url;
diff --git a/quic/tools/quic_memory_cache_backend_test.cc b/quic/tools/quic_memory_cache_backend_test.cc
index 2bdd294..1902146 100644
--- a/quic/tools/quic_memory_cache_backend_test.cc
+++ b/quic/tools/quic_memory_cache_backend_test.cc
@@ -4,6 +4,7 @@
#include "net/third_party/quiche/src/quic/tools/quic_memory_cache_backend.h"
+#include "absl/strings/match.h"
#include "net/third_party/quiche/src/quic/platform/api/quic_file_utils.h"
#include "net/third_party/quiche/src/quic/platform/api/quic_map_util.h"
#include "net/third_party/quiche/src/quic/platform/api/quic_test.h"
@@ -123,7 +124,7 @@
std::string dir;
std::string path = "map.html";
for (const std::string& file : ReadFileContents(CacheDirectory())) {
- if (quiche::QuicheTextUtils::EndsWithIgnoreCase(file, "map.html")) {
+ if (absl::EndsWithIgnoreCase(file, "map.html")) {
dir = file;
dir.erase(dir.length() - path.length() - 1);
break;