Adds SpdyStringPieceCaseHash and SpdyStringPieceCaseEq, for future use in SpdyHeaderBlock. SpdyStringPieceCaseHash could be implemented by incorporating Chromium's ToLowerASCII into a function object like StringPieceHashImpl: https://cs.chromium.org/chromium/src/base/strings/string_util.h?l=87&rcl=b493570b9e803c8423c3b9de45a36b6fb82dd970 https://cs.chromium.org/chromium/src/base/strings/string_piece.h?l=532&rcl=9c7be4ec394e834bc5e687c82ccacb379ae26cd3 SpdyStringPieceCaseEq could be implemented using Chromium's EqualsCaseInsensitiveASCII: https://cs.chromium.org/chromium/src/base/strings/string_util.h?l=139&rcl=b493570b9e803c8423c3b9de45a36b6fb82dd970 gfe-relnote: n/a (new code, not yet used in the GFE) PiperOrigin-RevId: 287994767 Change-Id: Ie47ac5e93a7f61d12ceef28abaa1e18e9a62fb06
diff --git a/spdy/platform/api/spdy_string_utils.h b/spdy/platform/api/spdy_string_utils.h index e2f709d..7619fb0 100644 --- a/spdy/platform/api/spdy_string_utils.h +++ b/spdy/platform/api/spdy_string_utils.h
@@ -53,6 +53,10 @@ return SpdyHexDumpImpl(data); } +using SpdyStringPieceCaseHash = SpdyStringPieceCaseHashImpl; + +using SpdyStringPieceCaseEq = SpdyStringPieceCaseEqImpl; + } // namespace spdy #endif // QUICHE_SPDY_PLATFORM_API_SPDY_STRING_UTILS_H_
diff --git a/spdy/platform/api/spdy_string_utils_test.cc b/spdy/platform/api/spdy_string_utils_test.cc index f6f094f..76a2a35 100644 --- a/spdy/platform/api/spdy_string_utils_test.cc +++ b/spdy/platform/api/spdy_string_utils_test.cc
@@ -237,6 +237,28 @@ EXPECT_EQ("10000001", SpdyHexEncodeUInt32AndTrim(0x10000001)); } +TEST(SpdyStringUtilsTest, SpdyStringPieceCaseHash) { + SpdyStringPieceCaseHash hasher; + auto mixed = hasher("To Be Or Not To Be, That is The Question"); + auto lower = hasher("to be or not to be, that is the question"); + EXPECT_EQ(mixed, lower); + auto lower2 = hasher("to be or not to be, that is the question"); + EXPECT_EQ(lower, lower2); + auto different = hasher("to see or not to see, that is the question"); + EXPECT_NE(lower, different); + EXPECT_NE(lower, hasher("")); +} + +TEST(SpdyStringUtilsTest, SpdyStringPieceCaseEq) { + SpdyStringPieceCaseEq eq; + EXPECT_TRUE(eq("To Be Or Not To Be, That is The Question", + "to be or not to be, that is the question")); + EXPECT_TRUE(eq("to be or not to be, that is the question", + "to be or not to be, that is the question")); + EXPECT_FALSE(eq("to be or not to be, that is the question", + "to see or not to see, that is the question")); +} + } // namespace } // namespace test } // namespace spdy