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,22 +48,22 @@ 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",
SpdyPushedStreamFate::kClientRequestNotRange);
SpdySession::RecordSpdyPushedStreamFateHistogram(
SpdyPushedStreamFate::kClientRequestNotRange);
return false;
}
spdy::SpdyHeaderBlock::const_iterator pushed_request_range_it =
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",
SpdyPushedStreamFate::kPushedRequestNotRange);
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",
SpdyPushedStreamFate::kRangeMismatch);
SpdySession::RecordSpdyPushedStreamFateHistogram(
SpdyPushedStreamFate::kRangeMismatch);
return false;
}
}
......@@ -75,20 +75,20 @@ 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",
SpdyPushedStreamFate::kAcceptedNoVary);
SpdySession::RecordSpdyPushedStreamFateHistogram(
SpdyPushedStreamFate::kAcceptedNoVary);
return true;
}
if (vary_data.MatchesRequest(request_info,
*pushed_response_info.headers.get())) {
UMA_HISTOGRAM_ENUMERATION("Net.SpdyPushedStreamFate",
SpdyPushedStreamFate::kAcceptedMatchingVary);
SpdySession::RecordSpdyPushedStreamFateHistogram(
SpdyPushedStreamFate::kAcceptedMatchingVary);
return true;
}
UMA_HISTOGRAM_ENUMERATION("Net.SpdyPushedStreamFate",
SpdyPushedStreamFate::kVaryMismatch);
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,8 +1648,8 @@ 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",
SpdyPushedStreamFate::kStreamIdOutOfOrder);
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,8 +1697,8 @@ 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",
SpdyPushedStreamFate::kInactiveAssociatedStream);
RecordSpdyPushedStreamFateHistogram(
SpdyPushedStreamFate::kInactiveAssociatedStream);
EnqueueResetStreamFrame(stream_id, request_priority,
spdy::ERROR_CODE_STREAM_CLOSED,
"Inactive associated stream.");
......@@ -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,16 +1719,15 @@ void SpdySession::TryCreatePushStream(spdy::SpdyStreamId stream_id,
}
} else {
if (!gurl.SchemeIs(url::kHttpsScheme)) {
UMA_HISTOGRAM_ENUMERATION("Net.SpdyPushedStreamFate",
SpdyPushedStreamFate::kNonHttpsPushedScheme);
RecordSpdyPushedStreamFateHistogram(
SpdyPushedStreamFate::kNonHttpsPushedScheme);
EnqueueResetStreamFrame(stream_id, request_priority,
spdy::ERROR_CODE_REFUSED_STREAM,
"Pushed URL must have https scheme.");
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,8 +1738,8 @@ 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",
SpdyPushedStreamFate::kCertificateMismatch);
RecordSpdyPushedStreamFateHistogram(
SpdyPushedStreamFate::kCertificateMismatch);
EnqueueResetStreamFrame(stream_id, request_priority,
spdy::ERROR_CODE_REFUSED_STREAM,
"Certificate does not match pushed URL.");
......@@ -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,8 +3072,8 @@ 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",
SpdyPushedStreamFate::kTooManyPushedStreams);
RecordSpdyPushedStreamFateHistogram(
SpdyPushedStreamFate::kTooManyPushedStreams);
ResetStream(stream_id, ERR_SPDY_CLIENT_REFUSED_STREAM,
"Stream concurrency limit reached.");
return;
......
......@@ -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