Refactor ReportingCache's storage of reports
This converts storage of ReportingReports in the ReportingCache into a
flat_set. Also slightly refactors the interface exposed to the
ReportingDeliveryAgent (in preparation for double-keying it).
Bug: 1035660
Change-Id: I4f85283079ecf2e40e4840aac038078a646ec0bc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1978218
Reviewed-by: David Benjamin <[email protected]>
Commit-Queue: Lily Chen <[email protected]>
Cr-Commit-Position: refs/heads/master@{#728307}
diff --git a/net/reporting/reporting_report.cc b/net/reporting/reporting_report.cc
index 6818f0d4..5c7f3e5 100644
--- a/net/reporting/reporting_report.cc
+++ b/net/reporting/reporting_report.cc
@@ -39,12 +39,17 @@
body(std::move(body)),
depth(depth),
queued(queued),
- attempts(attempts),
- outcome(Outcome::UNKNOWN),
- recorded_outcome(false) {}
+ attempts(attempts) {}
ReportingReport::~ReportingReport() {
- DCHECK(recorded_outcome);
+ if (outcome == Outcome::DELIVERED) {
+ // |delivered| should always have a value here, since the ReportingCache
+ // records the delivery time for any successful delivery.
+ UMA_HISTOGRAM_LONG_TIMES_100("Net.Reporting.ReportDeliveredLatency",
+ delivered.value() - queued);
+ UMA_HISTOGRAM_COUNTS_100("Net.Reporting.ReportDeliveredAttempts", attempts);
+ }
+ RecordReportOutcome(outcome);
}
// static
@@ -57,18 +62,8 @@
RecordReportOutcome(Outcome::DISCARDED_NO_REPORTING_SERVICE);
}
-void ReportingReport::RecordOutcome(base::TimeTicks now) {
- DCHECK(!recorded_outcome);
-
- RecordReportOutcome(outcome);
-
- if (outcome == Outcome::DELIVERED) {
- UMA_HISTOGRAM_LONG_TIMES_100("Net.Reporting.ReportDeliveredLatency",
- now - queued);
- UMA_HISTOGRAM_COUNTS_100("Net.Reporting.ReportDeliveredAttempts", attempts);
- }
-
- recorded_outcome = true;
+bool ReportingReport::IsUploadPending() const {
+ return status == Status::PENDING || status == Status::DOOMED;
}
} // namespace net