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

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

Issue 2862453002: Add metrics for certificate report uploads (Closed)
Patch Set: Rebase and address comments Created 3 years, 7 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
Index: chrome/browser/safe_browsing/certificate_reporting_service.cc
diff --git a/chrome/browser/safe_browsing/certificate_reporting_service.cc b/chrome/browser/safe_browsing/certificate_reporting_service.cc
index f75d1cebd9b51f2e8990da6abae80659abec581b..af74d09002cc6dce92a35a5ae33f763c993dd821 100644
--- a/chrome/browser/safe_browsing/certificate_reporting_service.cc
+++ b/chrome/browser/safe_browsing/certificate_reporting_service.cc
@@ -37,6 +37,12 @@ void RecordUMAOnFailure(int net_error) {
UMA_HISTOGRAM_SPARSE_SLOWLY("SSL.CertificateErrorReportFailure", -net_error);
}
+void RecordUMAEvent(CertificateReportingService::ReportOutcome outcome) {
+ UMA_HISTOGRAM_ENUMERATION(CertificateReportingService::kReportEventHistogram,
+ outcome,
+ CertificateReportingService::REPORT_EVENT_COUNT);
+}
+
void CleanupOnIOThread(
std::unique_ptr<CertificateReportingService::Reporter> reporter) {
reporter.reset();
@@ -44,6 +50,9 @@ void CleanupOnIOThread(
} // namespace
+const char CertificateReportingService::kReportEventHistogram[] =
+ "SSL.CertificateErrorReportEvent";
+
CertificateReportingService::BoundedReportList::BoundedReportList(
size_t max_size)
: max_size_(max_size) {
@@ -61,10 +70,12 @@ void CertificateReportingService::BoundedReportList::Add(const Report& item) {
const Report& last = items_.back();
if (item.creation_time <= last.creation_time) {
// Report older than the oldest item in the queue, ignore.
+ RecordUMAEvent(REPORT_DROPPED_OR_IGNORED);
return;
}
// Reached the maximum item count, remove the oldest item.
items_.pop_back();
+ RecordUMAEvent(REPORT_DROPPED_OR_IGNORED);
}
items_.push_back(item);
std::sort(items_.begin(), items_.end(), ReportCompareFunc);
@@ -114,6 +125,7 @@ void CertificateReportingService::Reporter::SendPending() {
for (Report& report : items) {
if (report.creation_time < now - report_ttl_) {
// Report too old, ignore.
+ RecordUMAEvent(REPORT_DROPPED_OR_IGNORED);
continue;
}
if (!report.is_retried) {
@@ -144,6 +156,7 @@ void CertificateReportingService::Reporter::SendInternal(
const CertificateReportingService::Report& report) {
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
inflight_reports_.insert(std::make_pair(report.report_id, report));
+ RecordUMAEvent(REPORT_SUBMITTED);
error_reporter_->SendExtendedReportingReport(
report.serialized_report,
base::Bind(&CertificateReportingService::Reporter::SuccessCallback,
@@ -159,6 +172,7 @@ void CertificateReportingService::Reporter::ErrorCallback(
int http_response_code) {
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
RecordUMAOnFailure(net_error);
+ RecordUMAEvent(REPORT_FAILED);
if (retries_enabled_) {
auto it = inflight_reports_.find(report_id);
DCHECK(it != inflight_reports_.end());
@@ -169,6 +183,7 @@ void CertificateReportingService::Reporter::ErrorCallback(
void CertificateReportingService::Reporter::SuccessCallback(int report_id) {
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
+ RecordUMAEvent(REPORT_SUCCESSFUL);
CHECK_GT(inflight_reports_.erase(report_id), 0u);
}

Powered by Google App Engine
This is Rietveld 408576698