Commit 40e9c223 authored by Bence Béky's avatar Bence Béky Committed by Commit Bot

Do not expand UMA_HISTOGRAM_ENUMERATION in 19 places.

Instead of expanding UMA_HISTOGRAM_ENUMERATION macro in 19 places, use a
single static method to log this histogram.  The motivation for this
change is to avoid binary bloat.

This is a follow-up to https://crrev.com/c/1055949.

This CL results in 2384 byte decrease in binary size for locally
compiled release build on Linux, and no change for debug build.

Bug: 831536
Change-Id: I0b5e741e29529c9f6ae22336b3a6c3d194042249
Reviewed-on: https://chromium-review.googlesource.com/1071731Reviewed-by: default avatarCharlie Harrison <csharrison@chromium.org>
Commit-Queue: Bence Béky <bnc@chromium.org>
Cr-Commit-Position: refs/heads/master@{#561607}
parent 33fa7cfd
......@@ -48,7 +48,7 @@ bool ValidatePushedHeaders(const HttpRequestInfo& request_info,
if (!request_info.extra_headers.GetHeader(HttpRequestHeaders::kRange,
&client_request_range)) {
// Client initiated request is not a range request.
UMA_HISTOGRAM_ENUMERATION("Net.SpdyPushedStreamFate",
SpdySession::RecordSpdyPushedStreamFateHistogram(
SpdyPushedStreamFate::kClientRequestNotRange);
return false;
}
......@@ -56,13 +56,13 @@ bool ValidatePushedHeaders(const HttpRequestInfo& request_info,
pushed_request_headers.find("range");
if (pushed_request_range_it == pushed_request_headers.end()) {
// Pushed request is not a range request.
UMA_HISTOGRAM_ENUMERATION("Net.SpdyPushedStreamFate",
SpdySession::RecordSpdyPushedStreamFateHistogram(
SpdyPushedStreamFate::kPushedRequestNotRange);
return false;
}
if (client_request_range != pushed_request_range_it->second) {
// Client and pushed request ranges do not match.
UMA_HISTOGRAM_ENUMERATION("Net.SpdyPushedStreamFate",
SpdySession::RecordSpdyPushedStreamFateHistogram(
SpdyPushedStreamFate::kRangeMismatch);
return false;
}
......@@ -75,19 +75,19 @@ bool ValidatePushedHeaders(const HttpRequestInfo& request_info,
if (!vary_data.Init(pushed_request_info,
*pushed_response_info.headers.get())) {
// Pushed response did not contain non-empty Vary header.
UMA_HISTOGRAM_ENUMERATION("Net.SpdyPushedStreamFate",
SpdySession::RecordSpdyPushedStreamFateHistogram(
SpdyPushedStreamFate::kAcceptedNoVary);
return true;
}
if (vary_data.MatchesRequest(request_info,
*pushed_response_info.headers.get())) {
UMA_HISTOGRAM_ENUMERATION("Net.SpdyPushedStreamFate",
SpdySession::RecordSpdyPushedStreamFateHistogram(
SpdyPushedStreamFate::kAcceptedMatchingVary);
return true;
}
UMA_HISTOGRAM_ENUMERATION("Net.SpdyPushedStreamFate",
SpdySession::RecordSpdyPushedStreamFateHistogram(
SpdyPushedStreamFate::kVaryMismatch);
return false;
}
......
......@@ -1477,6 +1477,12 @@ bool SpdySession::ChangeSocketTag(const SocketTag& new_tag) {
return true;
}
// static
void SpdySession::RecordSpdyPushedStreamFateHistogram(
SpdyPushedStreamFate value) {
UMA_HISTOGRAM_ENUMERATION("Net.SpdyPushedStreamFate", value);
}
// {,Try}CreateStream() can be called with |in_io_loop_| set if a stream is
// being created in response to another being closed due to received data.
......@@ -1620,8 +1626,7 @@ void SpdySession::TryCreatePushStream(spdy::SpdyStreamId stream_id,
"Received invalid pushed stream id %d (must be even) on stream id %d.",
stream_id, associated_stream_id);
LOG(WARNING) << description;
UMA_HISTOGRAM_ENUMERATION(
"Net.SpdyPushedStreamFate",
RecordSpdyPushedStreamFateHistogram(
SpdyPushedStreamFate::kPromisedStreamIdParityError);
CloseSessionOnError(ERR_SPDY_PROTOCOL_ERROR, description);
return;
......@@ -1632,8 +1637,7 @@ void SpdySession::TryCreatePushStream(spdy::SpdyStreamId stream_id,
"Received pushed stream id %d on invalid stream id %d (must be odd).",
stream_id, associated_stream_id);
LOG(WARNING) << description;
UMA_HISTOGRAM_ENUMERATION(
"Net.SpdyPushedStreamFate",
RecordSpdyPushedStreamFateHistogram(
SpdyPushedStreamFate::kAssociatedStreamIdParityError);
CloseSessionOnError(ERR_SPDY_PROTOCOL_ERROR, description);
return;
......@@ -1644,7 +1648,7 @@ void SpdySession::TryCreatePushStream(spdy::SpdyStreamId stream_id,
"Received pushed stream id %d must be larger than last accepted id %d.",
stream_id, last_accepted_push_stream_id_);
LOG(WARNING) << description;
UMA_HISTOGRAM_ENUMERATION("Net.SpdyPushedStreamFate",
RecordSpdyPushedStreamFateHistogram(
SpdyPushedStreamFate::kStreamIdOutOfOrder);
CloseSessionOnError(ERR_SPDY_PROTOCOL_ERROR, description);
return;
......@@ -1660,8 +1664,7 @@ void SpdySession::TryCreatePushStream(spdy::SpdyStreamId stream_id,
const RequestPriority request_priority = IDLE;
if (availability_state_ == STATE_GOING_AWAY) {
UMA_HISTOGRAM_ENUMERATION("Net.SpdyPushedStreamFate",
SpdyPushedStreamFate::kGoingAway);
RecordSpdyPushedStreamFateHistogram(SpdyPushedStreamFate::kGoingAway);
EnqueueResetStreamFrame(stream_id, request_priority,
spdy::ERROR_CODE_REFUSED_STREAM,
"Push stream request received while going away.");
......@@ -1673,8 +1676,7 @@ void SpdySession::TryCreatePushStream(spdy::SpdyStreamId stream_id,
// Verify that the response had a URL for us.
GURL gurl(SpdyUtils::GetPromisedUrlFromHeaders(headers));
if (!gurl.is_valid()) {
UMA_HISTOGRAM_ENUMERATION("Net.SpdyPushedStreamFate",
SpdyPushedStreamFate::kInvalidUrl);
RecordSpdyPushedStreamFateHistogram(SpdyPushedStreamFate::kInvalidUrl);
EnqueueResetStreamFrame(stream_id, request_priority,
spdy::ERROR_CODE_REFUSED_STREAM,
"Invalid pushed request headers.");
......@@ -1695,7 +1697,7 @@ void SpdySession::TryCreatePushStream(spdy::SpdyStreamId stream_id,
ActiveStreamMap::iterator associated_it =
active_streams_.find(associated_stream_id);
if (associated_it == active_streams_.end()) {
UMA_HISTOGRAM_ENUMERATION("Net.SpdyPushedStreamFate",
RecordSpdyPushedStreamFateHistogram(
SpdyPushedStreamFate::kInactiveAssociatedStream);
EnqueueResetStreamFrame(stream_id, request_priority,
spdy::ERROR_CODE_STREAM_CLOSED,
......@@ -1708,8 +1710,7 @@ void SpdySession::TryCreatePushStream(spdy::SpdyStreamId stream_id,
if (associated_url.GetOrigin() != gurl.GetOrigin()) {
if (is_trusted_proxy_) {
if (!gurl.SchemeIs(url::kHttpScheme)) {
UMA_HISTOGRAM_ENUMERATION(
"Net.SpdyPushedStreamFate",
RecordSpdyPushedStreamFateHistogram(
SpdyPushedStreamFate::kNonHttpSchemeFromTrustedProxy);
EnqueueResetStreamFrame(
stream_id, request_priority, spdy::ERROR_CODE_REFUSED_STREAM,
......@@ -1718,7 +1719,7 @@ void SpdySession::TryCreatePushStream(spdy::SpdyStreamId stream_id,
}
} else {
if (!gurl.SchemeIs(url::kHttpsScheme)) {
UMA_HISTOGRAM_ENUMERATION("Net.SpdyPushedStreamFate",
RecordSpdyPushedStreamFateHistogram(
SpdyPushedStreamFate::kNonHttpsPushedScheme);
EnqueueResetStreamFrame(stream_id, request_priority,
spdy::ERROR_CODE_REFUSED_STREAM,
......@@ -1726,8 +1727,7 @@ void SpdySession::TryCreatePushStream(spdy::SpdyStreamId stream_id,
return;
}
if (!associated_url.SchemeIs(url::kHttpsScheme)) {
UMA_HISTOGRAM_ENUMERATION(
"Net.SpdyPushedStreamFate",
RecordSpdyPushedStreamFateHistogram(
SpdyPushedStreamFate::kNonHttpsAssociatedScheme);
EnqueueResetStreamFrame(stream_id, request_priority,
spdy::ERROR_CODE_REFUSED_STREAM,
......@@ -1738,7 +1738,7 @@ void SpdySession::TryCreatePushStream(spdy::SpdyStreamId stream_id,
CHECK(GetSSLInfo(&ssl_info));
if (!CanPool(transport_security_state_, ssl_info, associated_url.host(),
gurl.host())) {
UMA_HISTOGRAM_ENUMERATION("Net.SpdyPushedStreamFate",
RecordSpdyPushedStreamFateHistogram(
SpdyPushedStreamFate::kCertificateMismatch);
EnqueueResetStreamFrame(stream_id, request_priority,
spdy::ERROR_CODE_REFUSED_STREAM,
......@@ -1751,8 +1751,7 @@ void SpdySession::TryCreatePushStream(spdy::SpdyStreamId stream_id,
// Insertion fails if there already is a pushed stream with the same path.
if (!pool_->push_promise_index()->RegisterUnclaimedPushedStream(
gurl, stream_id, this)) {
UMA_HISTOGRAM_ENUMERATION("Net.SpdyPushedStreamFate",
SpdyPushedStreamFate::kDuplicateUrl);
RecordSpdyPushedStreamFateHistogram(SpdyPushedStreamFate::kDuplicateUrl);
EnqueueResetStreamFrame(stream_id, request_priority,
spdy::ERROR_CODE_REFUSED_STREAM,
"Duplicate pushed stream with url: " + gurl.spec());
......@@ -2713,8 +2712,7 @@ void SpdySession::CancelPushedStreamIfUnclaimed(spdy::SpdyStreamId stream_id) {
return;
}
UMA_HISTOGRAM_ENUMERATION("Net.SpdyPushedStreamFate",
SpdyPushedStreamFate::kTimeout);
RecordSpdyPushedStreamFateHistogram(SpdyPushedStreamFate::kTimeout);
LogAbandonedActiveStream(active_it, ERR_TIMED_OUT);
// CloseActiveStreamIterator() will remove the stream from
......@@ -3074,7 +3072,7 @@ void SpdySession::OnHeaders(spdy::SpdyStreamId stream_id,
DCHECK_EQ(SPDY_PUSH_STREAM, stream->type());
if (max_concurrent_pushed_streams_ &&
num_active_pushed_streams_ >= max_concurrent_pushed_streams_) {
UMA_HISTOGRAM_ENUMERATION("Net.SpdyPushedStreamFate",
RecordSpdyPushedStreamFateHistogram(
SpdyPushedStreamFate::kTooManyPushedStreams);
ResetStream(stream_id, ERR_SPDY_CLIENT_REFUSED_STREAM,
"Stream concurrency limit reached.");
......
......@@ -547,6 +547,8 @@ class NET_EXPORT SpdySession : public BufferedSpdyFramerVisitorInterface,
// Change this session's socket tag to |new_tag|. Returns true on success.
bool ChangeSocketTag(const SocketTag& new_tag);
static void RecordSpdyPushedStreamFateHistogram(SpdyPushedStreamFate value);
private:
friend class test::SpdyStreamTest;
friend class base::RefCounted<SpdySession>;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment