Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7591)

Unified Diff: chrome/browser/safe_browsing/protocol_manager.cc

Issue 1563763002: Adds UMA histogram metrics for SafeBrowsing PVer4 methods. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@osb-pm-3
Patch Set: Rebase Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/safe_browsing/protocol_manager.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/safe_browsing/protocol_manager.cc
diff --git a/chrome/browser/safe_browsing/protocol_manager.cc b/chrome/browser/safe_browsing/protocol_manager.cc
index cd69a9713a04dc360ad8a79ce96e993f21feeb52..f56103ff9ae8c328727aac6d31181c8d97fcadaf 100644
--- a/chrome/browser/safe_browsing/protocol_manager.cc
+++ b/chrome/browser/safe_browsing/protocol_manager.cc
@@ -93,6 +93,8 @@ static const size_t kSbMaxBackOff = 8;
const char kGetHashUmaResponseMetricName[] = "SB2.GetHashResponseOrErrorCode";
const char kGetChunkUmaResponseMetricName[] = "SB2.GetChunkResponseOrErrorCode";
+const char kUmaV4ResponseMetricName[] =
+ "SafeBrowsing.GetV4HashHttpResponseOrErrorCode";
// The V4 URL prefix where browser fetches hashes from the V4 server.
const char kSbV4UrlPrefix[] = "https://safebrowsing.googleapis.com/v4";
@@ -216,6 +218,13 @@ void SafeBrowsingProtocolManager::RecordGetHashResult(bool is_download,
}
}
+// static
+void SafeBrowsingProtocolManager::RecordGetV4HashResult(
+ ResultType result_type) {
+ UMA_HISTOGRAM_ENUMERATION("SafeBrowsing.GetV4HashResult", result_type,
+ GET_HASH_RESULT_MAX);
+}
+
void SafeBrowsingProtocolManager::RecordHttpResponseOrErrorCode(
const char* metric_name,
const net::URLRequestStatus& status,
@@ -373,7 +382,11 @@ void SafeBrowsingProtocolManager::GetV4FullHashes(
// proceed with the request. If not, we are required to return empty results
// (i.e. treat the page as safe).
if (Time::Now() <= next_gethash_v4_time_) {
- // TODO(kcarattini): Add UMA recording.
+ if (gethash_v4_error_count_) {
+ RecordGetV4HashResult(GET_HASH_BACKOFF_ERROR);
+ } else {
+ RecordGetV4HashResult(GET_HASH_MIN_WAIT_DURATION_ERROR);
+ }
std::vector<SBFullHashResult> full_hashes;
callback.Run(full_hashes, base::TimeDelta());
return;
@@ -477,24 +490,34 @@ void SafeBrowsingProtocolManager::OnURLFetchComplete(
hash_requests_.erase(it);
} else if (v4_it != v4_hash_requests_.end()) {
// V4 FindFullHashes response.
+ // TODO(kcarattini): Consider pulling all the V4 handling out into a
+ // separate V4ProtocolManager class.
+ RecordHttpResponseOrErrorCode(kUmaV4ResponseMetricName, status,
+ response_code);
const FullHashDetails& details = v4_it->second;
std::vector<SBFullHashResult> full_hashes;
base::TimeDelta negative_cache_duration;
if (status.is_success() && response_code == net::HTTP_OK) {
- // TODO(kcarattini): Add UMA reporting.
+ RecordGetV4HashResult(GET_HASH_STATUS_200);
ResetGetHashV4Errors();
std::string data;
source->GetResponseAsString(&data);
if (!ParseV4HashResponse(data, &full_hashes, &negative_cache_duration)) {
full_hashes.clear();
- // TODO(kcarattini): Add UMA reporting.
+ RecordGetV4HashResult(GET_HASH_PARSE_ERROR);
Steven Holte 2016/01/13 21:25:43 It's usually preferable to have non-overlapping en
kcarattini 2016/01/13 22:53:20 Nathan, please correct me if I'm wrong, but I assu
Nathan Parker 2016/01/14 02:04:25 I agree with Steven but if it's already overlappin
}
} else {
HandleGetHashV4Error(Time::Now());
- // TODO(kcarattini): Add UMA reporting.
+
DVLOG(1) << "SafeBrowsing GetEncodedFullHashes request for: " <<
source->GetURL() << " failed with error: " << status.error() <<
" and response code: " << response_code;
+
+ if (status.status() == net::URLRequestStatus::FAILED) {
+ RecordGetV4HashResult(GET_HASH_NETWORK_ERROR);
+ } else {
+ RecordGetV4HashResult(GET_HASH_HTTP_ERROR);
+ }
}
// Invoke the callback with full_hashes, even if there was a parse error or
« no previous file with comments | « chrome/browser/safe_browsing/protocol_manager.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698