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

Unified Diff: net/reporting/reporting_delivery_agent.cc

Issue 2751103002: Reporting: Wrap existing classes in context. (Closed)
Patch Set: rebase Created 3 years, 8 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 | « net/reporting/reporting_delivery_agent.h ('k') | net/reporting/reporting_delivery_agent_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/reporting/reporting_delivery_agent.cc
diff --git a/net/reporting/reporting_delivery_agent.cc b/net/reporting/reporting_delivery_agent.cc
index b0d54dd37e4a9e4b3008a91a7ea9663d67696fd3..f39dde936ea46b4e940c8fc9e2a9aaf8c23624f6 100644
--- a/net/reporting/reporting_delivery_agent.cc
+++ b/net/reporting/reporting_delivery_agent.cc
@@ -48,16 +48,8 @@ void SerializeReports(const std::vector<const ReportingReport*>& reports,
} // namespace
-ReportingDeliveryAgent::ReportingDeliveryAgent(
- base::TickClock* clock,
- ReportingCache* cache,
- ReportingUploader* uploader,
- const BackoffEntry::Policy* endpoint_backoff_policy)
- : clock_(clock),
- cache_(cache),
- uploader_(uploader),
- endpoint_manager_(clock, cache, endpoint_backoff_policy),
- weak_factory_(this) {}
+ReportingDeliveryAgent::ReportingDeliveryAgent(ReportingContext* context)
+ : context_(context), weak_factory_(this) {}
ReportingDeliveryAgent::~ReportingDeliveryAgent() {}
class ReportingDeliveryAgent::Delivery {
@@ -74,7 +66,7 @@ class ReportingDeliveryAgent::Delivery {
void ReportingDeliveryAgent::SendReports() {
std::vector<const ReportingReport*> reports;
- cache_->GetReports(&reports);
+ cache()->GetReports(&reports);
// Sort reports into (origin, group) buckets.
std::map<OriginGroup, std::vector<const ReportingReport*>>
@@ -95,7 +87,7 @@ void ReportingDeliveryAgent::SendReports() {
continue;
GURL endpoint_url;
- if (!endpoint_manager_.FindEndpointForOriginAndGroup(
+ if (!endpoint_manager()->FindEndpointForOriginAndGroup(
origin_group.first, origin_group.second, &endpoint_url)) {
continue;
}
@@ -110,13 +102,13 @@ void ReportingDeliveryAgent::SendReports() {
const GURL& endpoint = it.first;
const std::vector<const ReportingReport*>& reports = it.second;
- endpoint_manager_.SetEndpointPending(endpoint);
- cache_->SetReportsPending(reports);
+ endpoint_manager()->SetEndpointPending(endpoint);
+ cache()->SetReportsPending(reports);
std::string json;
- SerializeReports(reports, clock_->NowTicks(), &json);
+ SerializeReports(reports, tick_clock()->NowTicks(), &json);
- uploader_->StartUpload(
+ uploader()->StartUpload(
endpoint, json,
base::Bind(&ReportingDeliveryAgent::OnUploadComplete,
weak_factory_.GetWeakPtr(),
@@ -128,23 +120,23 @@ void ReportingDeliveryAgent::OnUploadComplete(
const std::unique_ptr<Delivery>& delivery,
ReportingUploader::Outcome outcome) {
if (outcome == ReportingUploader::Outcome::SUCCESS) {
- cache_->RemoveReports(delivery->reports);
- endpoint_manager_.InformOfEndpointRequest(delivery->endpoint, true);
+ cache()->RemoveReports(delivery->reports);
+ endpoint_manager()->InformOfEndpointRequest(delivery->endpoint, true);
} else {
- cache_->IncrementReportsAttempts(delivery->reports);
- endpoint_manager_.InformOfEndpointRequest(delivery->endpoint, false);
+ cache()->IncrementReportsAttempts(delivery->reports);
+ endpoint_manager()->InformOfEndpointRequest(delivery->endpoint, false);
}
if (outcome == ReportingUploader::Outcome::REMOVE_ENDPOINT)
- cache_->RemoveClientsForEndpoint(delivery->endpoint);
+ cache()->RemoveClientsForEndpoint(delivery->endpoint);
for (const ReportingReport* report : delivery->reports) {
pending_origin_groups_.erase(
OriginGroup(url::Origin(report->url), report->group));
}
- cache_->ClearReportsPending(delivery->reports);
- endpoint_manager_.ClearEndpointPending(delivery->endpoint);
+ endpoint_manager()->ClearEndpointPending(delivery->endpoint);
+ cache()->ClearReportsPending(delivery->reports);
}
} // namespace net
« no previous file with comments | « net/reporting/reporting_delivery_agent.h ('k') | net/reporting/reporting_delivery_agent_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698