Remove Http2StrCat, use QuicheStrCat instead. gfe-relnote: n/a, no functional change. PiperOrigin-RevId: 289866176 Change-Id: I87a1f30ed7efc348196d8666b719ba0a7de97f3f
diff --git a/http2/hpack/decoder/hpack_block_decoder.cc b/http2/hpack/decoder/hpack_block_decoder.cc index bb86597..04e4d29 100644 --- a/http2/hpack/decoder/hpack_block_decoder.cc +++ b/http2/hpack/decoder/hpack_block_decoder.cc
@@ -8,6 +8,7 @@ #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/common/platform/api/quiche_str_cat.h" namespace http2 { @@ -49,10 +50,10 @@ } std::string HpackBlockDecoder::DebugString() const { - return Http2StrCat("HpackBlockDecoder(", entry_decoder_.DebugString(), - ", listener@", - Http2Hex(reinterpret_cast<intptr_t>(listener_)), - (before_entry_ ? ", between entries)" : ", in an entry)")); + return quiche::QuicheStrCat( + "HpackBlockDecoder(", entry_decoder_.DebugString(), ", listener@", + Http2Hex(reinterpret_cast<intptr_t>(listener_)), + (before_entry_ ? ", between entries)" : ", in an entry)")); } std::ostream& operator<<(std::ostream& out, const HpackBlockDecoder& v) {
diff --git a/http2/hpack/decoder/hpack_entry_type_decoder.cc b/http2/hpack/decoder/hpack_entry_type_decoder.cc index ce91978..ebb5779 100644 --- a/http2/hpack/decoder/hpack_entry_type_decoder.cc +++ b/http2/hpack/decoder/hpack_entry_type_decoder.cc
@@ -7,11 +7,12 @@ #include "net/third_party/quiche/src/http2/platform/api/http2_bug_tracker.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/common/platform/api/quiche_str_cat.h" namespace http2 { std::string HpackEntryTypeDecoder::DebugString() const { - return Http2StrCat( + return quiche::QuicheStrCat( "HpackEntryTypeDecoder(varint_decoder=", varint_decoder_.DebugString(), ", entry_type=", entry_type_, ")"); }
diff --git a/http2/hpack/decoder/hpack_string_decoder.cc b/http2/hpack/decoder/hpack_string_decoder.cc index f74e536..ad5bb54 100644 --- a/http2/hpack/decoder/hpack_string_decoder.cc +++ b/http2/hpack/decoder/hpack_string_decoder.cc
@@ -4,15 +4,15 @@ #include "net/third_party/quiche/src/http2/hpack/decoder/hpack_string_decoder.h" -#include "net/third_party/quiche/src/http2/platform/api/http2_string_utils.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" namespace http2 { std::string HpackStringDecoder::DebugString() const { - return Http2StrCat("HpackStringDecoder(state=", StateToString(state_), - ", length=", length_decoder_.DebugString(), - ", remaining=", remaining_, - ", huffman=", huffman_encoded_ ? "true)" : "false)"); + return quiche::QuicheStrCat( + "HpackStringDecoder(state=", StateToString(state_), + ", length=", length_decoder_.DebugString(), ", remaining=", remaining_, + ", huffman=", huffman_encoded_ ? "true)" : "false)"); } // static @@ -25,7 +25,7 @@ case kResumeDecodingLength: return "kResumeDecodingLength"; } - return Http2StrCat("UNKNOWN_STATE(", static_cast<uint32_t>(v), ")"); + return quiche::QuicheStrCat("UNKNOWN_STATE(", static_cast<uint32_t>(v), ")"); } std::ostream& operator<<(std::ostream& out, const HpackStringDecoder& v) {
diff --git a/http2/hpack/hpack_string.cc b/http2/hpack/hpack_string.cc index 77ae5a3..cb22f51 100644 --- a/http2/hpack/hpack_string.cc +++ b/http2/hpack/hpack_string.cc
@@ -7,7 +7,7 @@ #include <utility> #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/common/platform/api/quiche_str_cat.h" namespace http2 { @@ -62,8 +62,8 @@ } std::string HpackStringPair::DebugString() const { - return Http2StrCat("HpackStringPair(name=", name.ToString(), - ", value=", value.ToString(), ")"); + return quiche::QuicheStrCat("HpackStringPair(name=", name.ToString(), + ", value=", value.ToString(), ")"); } std::ostream& operator<<(std::ostream& os, const HpackStringPair& p) {
diff --git a/http2/hpack/http2_hpack_constants.cc b/http2/hpack/http2_hpack_constants.cc index d697db0..4b121ac 100644 --- a/http2/hpack/http2_hpack_constants.cc +++ b/http2/hpack/http2_hpack_constants.cc
@@ -4,7 +4,7 @@ #include "net/third_party/quiche/src/http2/hpack/http2_hpack_constants.h" -#include "net/third_party/quiche/src/http2/platform/api/http2_string_utils.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" namespace http2 { @@ -21,7 +21,8 @@ case HpackEntryType::kNeverIndexedLiteralHeader: return "kNeverIndexedLiteralHeader"; } - return Http2StrCat("UnknownHpackEntryType(", static_cast<int>(v), ")"); + return quiche::QuicheStrCat("UnknownHpackEntryType(", static_cast<int>(v), + ")"); } std::ostream& operator<<(std::ostream& out, HpackEntryType v) {
diff --git a/http2/hpack/tools/hpack_example.cc b/http2/hpack/tools/hpack_example.cc index 5e0e40c..31de86d 100644 --- a/http2/hpack/tools/hpack_example.cc +++ b/http2/hpack/tools/hpack_example.cc
@@ -9,6 +9,7 @@ #include "net/third_party/quiche/src/http2/platform/api/http2_bug_tracker.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/common/platform/api/quiche_str_cat.h" namespace http2 { namespace test { @@ -41,7 +42,7 @@ continue; } HTTP2_BUG << "Can't parse byte " << static_cast<int>(c0) - << Http2StrCat(" (0x", Http2Hex(c0), ")") + << quiche::QuicheStrCat(" (0x", Http2Hex(c0), ")") << "\nExample: " << example; } CHECK_LT(0u, output->size()) << "Example is empty.";
diff --git a/http2/hpack/varint/hpack_varint_decoder.cc b/http2/hpack/varint/hpack_varint_decoder.cc index e7e2c9c..e3fe745 100644 --- a/http2/hpack/varint/hpack_varint_decoder.cc +++ b/http2/hpack/varint/hpack_varint_decoder.cc
@@ -5,6 +5,7 @@ #include "net/third_party/quiche/src/http2/hpack/varint/hpack_varint_decoder.h" #include "net/third_party/quiche/src/http2/platform/api/http2_string_utils.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" namespace http2 { @@ -121,8 +122,8 @@ } std::string HpackVarintDecoder::DebugString() const { - return Http2StrCat("HpackVarintDecoder(value=", value_, ", offset=", offset_, - ")"); + return quiche::QuicheStrCat("HpackVarintDecoder(value=", value_, + ", offset=", offset_, ")"); } DecodeStatus HpackVarintDecoder::StartForTest(uint8_t prefix_value,
diff --git a/http2/hpack/varint/hpack_varint_round_trip_test.cc b/http2/hpack/varint/hpack_varint_round_trip_test.cc index 58fc2c3..59473a7 100644 --- a/http2/hpack/varint/hpack_varint_round_trip_test.cc +++ b/http2/hpack/varint/hpack_varint_round_trip_test.cc
@@ -18,6 +18,7 @@ #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_str_cat.h" #include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" using ::testing::AssertionFailure; @@ -161,10 +162,10 @@ for (const uint64_t value : values) { Encode(value, prefix_length); // Sets buffer_. - std::string msg = Http2StrCat("value=", value, " (0x", Http2Hex(value), - "), prefix_length=", prefix_length, - ", expected_bytes=", expected_bytes, "\n", - Http2HexDump(buffer_)); + std::string msg = quiche::QuicheStrCat( + "value=", value, " (0x", Http2Hex(value), + "), prefix_length=", prefix_length, + ", expected_bytes=", expected_bytes, "\n", Http2HexDump(buffer_)); if (value == minimum) { HTTP2_LOG(INFO) << "Checking minimum; " << msg;
diff --git a/http2/http2_constants.cc b/http2/http2_constants.cc index 37df919..daed778 100644 --- a/http2/http2_constants.cc +++ b/http2/http2_constants.cc
@@ -6,6 +6,7 @@ #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/common/platform/api/quiche_str_cat.h" #include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace http2 { @@ -35,7 +36,7 @@ case Http2FrameType::ALTSVC: return "ALTSVC"; } - return Http2StrCat("UnknownFrameType(", static_cast<int>(v), ")"); + return quiche::QuicheStrCat("UnknownFrameType(", static_cast<int>(v), ")"); } std::string Http2FrameTypeToString(uint8_t v) { @@ -121,7 +122,7 @@ case 0xd: return "HTTP_1_1_REQUIRED"; } - return Http2StrCat("UnknownErrorCode(0x", Http2Hex(v), ")"); + return quiche::QuicheStrCat("UnknownErrorCode(0x", Http2Hex(v), ")"); } std::string Http2ErrorCodeToString(Http2ErrorCode v) { return Http2ErrorCodeToString(static_cast<uint32_t>(v)); @@ -142,7 +143,7 @@ case 0x6: return "MAX_HEADER_LIST_SIZE"; } - return Http2StrCat("UnknownSettingsParameter(0x", Http2Hex(v), ")"); + return quiche::QuicheStrCat("UnknownSettingsParameter(0x", Http2Hex(v), ")"); } std::string Http2SettingsParameterToString(Http2SettingsParameter v) { return Http2SettingsParameterToString(static_cast<uint32_t>(v));
diff --git a/http2/http2_structures.cc b/http2/http2_structures.cc index 7b00db4..3558331 100644 --- a/http2/http2_structures.cc +++ b/http2/http2_structures.cc
@@ -8,6 +8,7 @@ #include <sstream> #include "net/third_party/quiche/src/http2/platform/api/http2_string_utils.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" namespace http2 { @@ -20,9 +21,9 @@ } std::string Http2FrameHeader::ToString() const { - return Http2StrCat("length=", payload_length, - ", type=", Http2FrameTypeToString(type), - ", flags=", FlagsToString(), ", stream=", stream_id); + return quiche::QuicheStrCat( + "length=", payload_length, ", type=", Http2FrameTypeToString(type), + ", flags=", FlagsToString(), ", stream=", stream_id); } std::string Http2FrameHeader::FlagsToString() const {
diff --git a/http2/http2_structures_test.cc b/http2/http2_structures_test.cc index 4903226..06ddc75 100644 --- a/http2/http2_structures_test.cc +++ b/http2/http2_structures_test.cc
@@ -25,6 +25,7 @@ #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/test_tools/http2_random.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" using ::testing::AssertionResult; using ::testing::AssertionSuccess; @@ -440,7 +441,8 @@ std::stringstream s; s << v; - EXPECT_EQ(Http2StrCat("promised_stream_id=", promised_stream_id), s.str()); + EXPECT_EQ(quiche::QuicheStrCat("promised_stream_id=", promised_stream_id), + s.str()); // High-bit is reserved, but not used, so we can set it. promised_stream_id |= 0x80000000; @@ -497,8 +499,9 @@ std::stringstream s; s << v; - EXPECT_EQ(Http2StrCat("window_size_increment=", window_size_increment), - s.str()); + EXPECT_EQ( + quiche::QuicheStrCat("window_size_increment=", window_size_increment), + s.str()); // High-bit is reserved, but not used, so we can set it. window_size_increment |= 0x80000000; @@ -522,7 +525,7 @@ std::stringstream s; s << v; - EXPECT_EQ(Http2StrCat("origin_length=", origin_length), s.str()); + EXPECT_EQ(quiche::QuicheStrCat("origin_length=", origin_length), s.str()); Http2AltSvcFields w{++origin_length}; EXPECT_EQ(w, w);
diff --git a/http2/platform/api/http2_string_utils.h b/http2/platform/api/http2_string_utils.h index 4a4e0b8..f14d93a 100644 --- a/http2/platform/api/http2_string_utils.h +++ b/http2/platform/api/http2_string_utils.h
@@ -15,11 +15,6 @@ namespace http2 { template <typename... Args> -inline std::string Http2StrCat(const Args&... args) { - return Http2StrCatImpl(std::forward<const Args&>(args)...); -} - -template <typename... Args> inline void Http2StrAppend(std::string* output, const Args&... args) { Http2StrAppendImpl(output, std::forward<const Args&>(args)...); }
diff --git a/http2/platform/api/http2_string_utils_test.cc b/http2/platform/api/http2_string_utils_test.cc index 6f04c9c..bff55cc 100644 --- a/http2/platform/api/http2_string_utils_test.cc +++ b/http2/platform/api/http2_string_utils_test.cc
@@ -7,69 +7,13 @@ #include <cstdint> #include "testing/gtest/include/gtest/gtest.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" #include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace http2 { namespace test { namespace { -TEST(Http2StringUtilsTest, Http2StrCat) { - // No arguments. - EXPECT_EQ("", Http2StrCat()); - - // Single string-like argument. - const char kFoo[] = "foo"; - const std::string string_foo(kFoo); - const quiche::QuicheStringPiece stringpiece_foo(string_foo); - EXPECT_EQ("foo", Http2StrCat(kFoo)); - EXPECT_EQ("foo", Http2StrCat(string_foo)); - EXPECT_EQ("foo", Http2StrCat(stringpiece_foo)); - - // Two string-like arguments. - const char kBar[] = "bar"; - const quiche::QuicheStringPiece stringpiece_bar(kBar); - const std::string string_bar(kBar); - EXPECT_EQ("foobar", Http2StrCat(kFoo, kBar)); - EXPECT_EQ("foobar", Http2StrCat(kFoo, string_bar)); - EXPECT_EQ("foobar", Http2StrCat(kFoo, stringpiece_bar)); - EXPECT_EQ("foobar", Http2StrCat(string_foo, kBar)); - EXPECT_EQ("foobar", Http2StrCat(string_foo, string_bar)); - EXPECT_EQ("foobar", Http2StrCat(string_foo, stringpiece_bar)); - EXPECT_EQ("foobar", Http2StrCat(stringpiece_foo, kBar)); - EXPECT_EQ("foobar", Http2StrCat(stringpiece_foo, string_bar)); - EXPECT_EQ("foobar", Http2StrCat(stringpiece_foo, stringpiece_bar)); - - // Many-many arguments. - EXPECT_EQ( - "foobarbazquxquuxquuzcorgegraultgarplywaldofredplughxyzzythud", - Http2StrCat("foo", "bar", "baz", "qux", "quux", "quuz", "corge", "grault", - "garply", "waldo", "fred", "plugh", "xyzzy", "thud")); - - // Numerical arguments. - const int16_t i = 1; - const uint64_t u = 8; - const double d = 3.1415; - - EXPECT_EQ("1 8", Http2StrCat(i, " ", u)); - EXPECT_EQ("3.14151181", Http2StrCat(d, i, i, u, i)); - EXPECT_EQ("i: 1, u: 8, d: 3.1415", - Http2StrCat("i: ", i, ", u: ", u, ", d: ", d)); - - // Boolean arguments. - const bool t = true; - const bool f = false; - - EXPECT_EQ("1", Http2StrCat(t)); - EXPECT_EQ("0", Http2StrCat(f)); - EXPECT_EQ("0110", Http2StrCat(f, t, t, f)); - - // Mixed string-like, numerical, and Boolean arguments. - EXPECT_EQ("foo1foo081bar3.14151", - Http2StrCat(kFoo, i, string_foo, f, u, t, stringpiece_bar, d, t)); - EXPECT_EQ("3.141511bar18bar13.14150", - Http2StrCat(d, t, t, string_bar, i, u, kBar, t, d, f)); -} - TEST(Http2StringUtilsTest, Http2StrAppend) { // No arguments on empty string. std::string output;