gfe-relnote: Rename the max_age field of spdy::AlternativeService to max_age_seconds.
In a downstream PR, I noticed a unit conversion bug which would have been avoided by this rename.
PiperOrigin-RevId: 398059356
diff --git a/http2/core/http2_trace_logging.cc b/http2/core/http2_trace_logging.cc
index d2ef702..2c1bee3 100644
--- a/http2/core/http2_trace_logging.cc
+++ b/http2/core/http2_trace_logging.cc
@@ -99,8 +99,8 @@
const { // NOLINT
out << "{"
<< "protocol_id=" << altsvc.protocol_id << " host=" << altsvc.host
- << " port=" << altsvc.port << " max_age=" << altsvc.max_age
- << " version=";
+ << " port=" << altsvc.port
+ << " max_age_seconds=" << altsvc.max_age_seconds << " version=";
for (auto v : altsvc.version) {
out << v << ",";
}
diff --git a/spdy/core/spdy_alt_svc_wire_format.cc b/spdy/core/spdy_alt_svc_wire_format.cc
index f1cca0d..de37a12 100644
--- a/spdy/core/spdy_alt_svc_wire_format.cc
+++ b/spdy/core/spdy_alt_svc_wire_format.cc
@@ -39,15 +39,12 @@
SpdyAltSvcWireFormat::AlternativeService::AlternativeService() = default;
SpdyAltSvcWireFormat::AlternativeService::AlternativeService(
- const std::string& protocol_id,
- const std::string& host,
- uint16_t port,
- uint32_t max_age,
- VersionVector version)
+ const std::string& protocol_id, const std::string& host, uint16_t port,
+ uint32_t max_age_seconds, VersionVector version)
: protocol_id(protocol_id),
host(host),
port(port),
- max_age(max_age),
+ max_age_seconds(max_age_seconds),
version(std::move(version)) {}
SpdyAltSvcWireFormat::AlternativeService::~AlternativeService() = default;
@@ -113,7 +110,7 @@
}
++c;
// Parse parameters.
- uint32_t max_age = 86400;
+ uint32_t max_age_seconds = 86400;
VersionVector version;
absl::string_view::const_iterator parameters_end =
std::find(c, value.end(), ',');
@@ -147,7 +144,8 @@
return false;
}
if (parameter_name == "ma") {
- if (!ParsePositiveInteger32(parameter_value_begin, c, &max_age)) {
+ if (!ParsePositiveInteger32(parameter_value_begin, c,
+ &max_age_seconds)) {
return false;
}
} else if (!is_ietf_format_quic && parameter_name == "v") {
@@ -204,7 +202,8 @@
version.push_back(quic_version);
}
}
- altsvc_vector->emplace_back(protocol_id, host, port, max_age, version);
+ altsvc_vector->emplace_back(protocol_id, host, port, max_age_seconds,
+ version);
for (; c != value.end() && (*c == ' ' || *c == '\t' || *c == ','); ++c) {
}
}
@@ -266,8 +265,8 @@
value.push_back(c);
}
absl::StrAppend(&value, ":", altsvc.port, "\"");
- if (altsvc.max_age != 86400) {
- absl::StrAppend(&value, "; ma=", altsvc.max_age);
+ if (altsvc.max_age_seconds != 86400) {
+ absl::StrAppend(&value, "; ma=", altsvc.max_age_seconds);
}
if (!altsvc.version.empty()) {
if (is_ietf_format_quic) {
diff --git a/spdy/core/spdy_alt_svc_wire_format.h b/spdy/core/spdy_alt_svc_wire_format.h
index a8e1094..664dc1c 100644
--- a/spdy/core/spdy_alt_svc_wire_format.h
+++ b/spdy/core/spdy_alt_svc_wire_format.h
@@ -35,15 +35,13 @@
// Default is 0: invalid port.
uint16_t port = 0;
// Default is one day.
- uint32_t max_age = 86400;
+ uint32_t max_age_seconds = 86400;
// Default is empty: unspecified version.
VersionVector version;
AlternativeService();
- AlternativeService(const std::string& protocol_id,
- const std::string& host,
- uint16_t port,
- uint32_t max_age,
+ AlternativeService(const std::string& protocol_id, const std::string& host,
+ uint16_t port, uint32_t max_age_seconds,
VersionVector version);
AlternativeService(const AlternativeService& other);
~AlternativeService();
@@ -51,7 +49,7 @@
bool operator==(const AlternativeService& other) const {
return protocol_id == other.protocol_id && host == other.host &&
port == other.port && version == other.version &&
- max_age == other.max_age;
+ max_age_seconds == other.max_age_seconds;
}
};
// An empty vector means alternative services should be cleared for given
diff --git a/spdy/core/spdy_alt_svc_wire_format_test.cc b/spdy/core/spdy_alt_svc_wire_format_test.cc
index 497f19d..70e708b 100644
--- a/spdy/core/spdy_alt_svc_wire_format_test.cc
+++ b/spdy/core/spdy_alt_svc_wire_format_test.cc
@@ -30,13 +30,15 @@
}
static bool ParsePositiveInteger16(absl::string_view::const_iterator c,
absl::string_view::const_iterator end,
- uint16_t* max_age) {
- return SpdyAltSvcWireFormat::ParsePositiveInteger16(c, end, max_age);
+ uint16_t* max_age_seconds) {
+ return SpdyAltSvcWireFormat::ParsePositiveInteger16(c, end,
+ max_age_seconds);
}
static bool ParsePositiveInteger32(absl::string_view::const_iterator c,
absl::string_view::const_iterator end,
- uint32_t* max_age) {
- return SpdyAltSvcWireFormat::ParsePositiveInteger32(c, end, max_age);
+ uint32_t* max_age_seconds) {
+ return SpdyAltSvcWireFormat::ParsePositiveInteger32(c, end,
+ max_age_seconds);
}
static char HexDigitToInt(char c) {
return SpdyAltSvcWireFormat::HexDigitToInt(c);
@@ -79,7 +81,7 @@
header_field_value->append(" ");
}
if (i & 3 << 3) {
- expected_altsvc->max_age = 1111;
+ expected_altsvc->max_age_seconds = 1111;
header_field_value->append(";");
if (i & 1 << 3) {
header_field_value->append(" ");
@@ -114,7 +116,7 @@
}
}
if (i & 1 << 8) {
- expected_altsvc->max_age = 999999999;
+ expected_altsvc->max_age_seconds = 999999999;
header_field_value->append("; Ma=999999999");
}
if (i & 1 << 9) {
@@ -148,7 +150,7 @@
}
expected_header_field_value->append(":42\"");
if (i & 1 << 1) {
- altsvc->max_age = 1111;
+ altsvc->max_age_seconds = 1111;
expected_header_field_value->append("; ma=1111");
}
if (i & 1 << 2) {
@@ -165,7 +167,7 @@
EXPECT_EQ("", altsvc.protocol_id);
EXPECT_EQ("", altsvc.host);
EXPECT_EQ(0u, altsvc.port);
- EXPECT_EQ(86400u, altsvc.max_age);
+ EXPECT_EQ(86400u, altsvc.max_age_seconds);
EXPECT_TRUE(altsvc.version.empty());
}
@@ -196,7 +198,8 @@
EXPECT_EQ(expected_altsvc.protocol_id, altsvc_vector[0].protocol_id);
EXPECT_EQ(expected_altsvc.host, altsvc_vector[0].host);
EXPECT_EQ(expected_altsvc.port, altsvc_vector[0].port);
- EXPECT_EQ(expected_altsvc.max_age, altsvc_vector[0].max_age);
+ EXPECT_EQ(expected_altsvc.max_age_seconds,
+ altsvc_vector[0].max_age_seconds);
EXPECT_EQ(expected_altsvc.version, altsvc_vector[0].version);
// Roundtrip test starting with |altsvc_vector|.
@@ -210,7 +213,8 @@
roundtrip_altsvc_vector[0].protocol_id);
EXPECT_EQ(expected_altsvc.host, roundtrip_altsvc_vector[0].host);
EXPECT_EQ(expected_altsvc.port, roundtrip_altsvc_vector[0].port);
- EXPECT_EQ(expected_altsvc.max_age, roundtrip_altsvc_vector[0].max_age);
+ EXPECT_EQ(expected_altsvc.max_age_seconds,
+ roundtrip_altsvc_vector[0].max_age_seconds);
EXPECT_EQ(expected_altsvc.version, roundtrip_altsvc_vector[0].version);
}
}
@@ -240,7 +244,8 @@
altsvc_vector[j].protocol_id);
EXPECT_EQ(expected_altsvc_vector[j].host, altsvc_vector[j].host);
EXPECT_EQ(expected_altsvc_vector[j].port, altsvc_vector[j].port);
- EXPECT_EQ(expected_altsvc_vector[j].max_age, altsvc_vector[j].max_age);
+ EXPECT_EQ(expected_altsvc_vector[j].max_age_seconds,
+ altsvc_vector[j].max_age_seconds);
EXPECT_EQ(expected_altsvc_vector[j].version, altsvc_vector[j].version);
}
@@ -258,8 +263,8 @@
roundtrip_altsvc_vector[j].host);
EXPECT_EQ(expected_altsvc_vector[j].port,
roundtrip_altsvc_vector[j].port);
- EXPECT_EQ(expected_altsvc_vector[j].max_age,
- roundtrip_altsvc_vector[j].max_age);
+ EXPECT_EQ(expected_altsvc_vector[j].max_age_seconds,
+ roundtrip_altsvc_vector[j].max_age_seconds);
EXPECT_EQ(expected_altsvc_vector[j].version,
roundtrip_altsvc_vector[j].version);
}
@@ -290,7 +295,7 @@
EXPECT_EQ(altsvc.protocol_id, parsed_altsvc_vector[0].protocol_id);
EXPECT_EQ(altsvc.host, parsed_altsvc_vector[0].host);
EXPECT_EQ(altsvc.port, parsed_altsvc_vector[0].port);
- EXPECT_EQ(altsvc.max_age, parsed_altsvc_vector[0].max_age);
+ EXPECT_EQ(altsvc.max_age_seconds, parsed_altsvc_vector[0].max_age_seconds);
EXPECT_EQ(altsvc.version, parsed_altsvc_vector[0].version);
// Test SerializeHeaderFieldValue().
@@ -325,7 +330,7 @@
EXPECT_EQ(expected_it->protocol_id, parsed_it->protocol_id);
EXPECT_EQ(expected_it->host, parsed_it->host);
EXPECT_EQ(expected_it->port, parsed_it->port);
- EXPECT_EQ(expected_it->max_age, parsed_it->max_age);
+ EXPECT_EQ(expected_it->max_age_seconds, parsed_it->max_age_seconds);
EXPECT_EQ(expected_it->version, parsed_it->version);
}
@@ -566,7 +571,7 @@
EXPECT_EQ("quic", altsvc_vector[0].protocol_id);
EXPECT_EQ("[2003:8:0:16::509d:9615]", altsvc_vector[0].host);
EXPECT_EQ(443u, altsvc_vector[0].port);
- EXPECT_EQ(60u, altsvc_vector[0].max_age);
+ EXPECT_EQ(60u, altsvc_vector[0].max_age_seconds);
EXPECT_THAT(altsvc_vector[0].version, ::testing::ElementsAre(36, 35));
}