Commit 606c9401 authored by Lily Chen's avatar Lily Chen Committed by Commit Bot

Double-key ReportingDeliveryAgent

This CL refactors ReportingDeliveryAgent to take NetworkIsolationKeys
of reports and endpoints into account.

It sorts the reports so that only reports with the same NIK and origin
are batched in the same upload. Reports for the same (NIK, origin) but
different groups can still be in the same upload if they share
an endpoint URL. Also reports that get assigned to the same endpoint URL
can be batched together, even if they are assigned to ReportingEndpoints
configured for different origins.

All the NIK fields are still empty except in tests.

Bug: 993805
Change-Id: I953f0b1ff38fbe2625c539e6e00306621f1025d1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2138566
Commit-Queue: Lily Chen <chlily@chromium.org>
Reviewed-by: default avatarMatt Menke <mmenke@chromium.org>
Cr-Commit-Position: refs/heads/master@{#770206}
parent ceb110a6
This diff is collapsed.
......@@ -19,32 +19,27 @@ namespace net {
class ReportingContext;
// Takes reports from the ReportingCache, assembles reports into deliveries to
// endpoints, and sends those deliveries using ReportingUploader.
// Batches reports fetched from the ReportingCache and uploads them using the
// ReportingUploader.
//
// Since the Reporting spec is completely silent on issues of concurrency, the
// delivery agent handles it as so:
// Reports are only considered for delivery if all of the following are true:
// - The report is not already part of a pending upload request.
// - Uploads are allowed for the report's origin (i.e. the origin of the URL
// associated with the reported event).
// - There is not already a pending upload for any reports sharing the same
// (NIK, origin, group) key.
//
// 1. An individual report can only be included in one delivery at once -- if
// SendReports is called again while a report is being delivered, it won't
// be included in another delivery during that call to SendReports. (This is,
// in fact, made redundant by rule 3, but it's included anyway in case rule 3
// changes.)
// Reports are batched for upload to an endpoint URL such that:
// - The available reports with the same (NIK, origin, group) are always
// uploaded together.
// - All reports uploaded together must share a NIK and origin.
// - Reports for the same (NIK, origin) can be uploaded separately if they are
// for different groups.
// - Reports for different groups can be batched together, if they are assigned
// to ReportingEndpoints sharing a URL (that is, the upload URL).
//
// 2. An endpoint can only be the target of one delivery at once -- if
// SendReports is called again with reports that could be delivered to that
// endpoint, they won't be delivered to that endpoint.
//
// 3. Reports for an (origin, group) tuple can only be included in one delivery
// at once -- if SendReports is called again with reports in that (origin,
// group), they won't be included in any delivery during that call to
// SendReports. (This prevents the agent from getting around rule 2 by using
// other endpoints in the same group.)
//
// 4. Reports for the same origin *can* be included in multiple parallel
// deliveries if they are in different groups within that origin.
//
// (Note that a single delivery can contain an infinite number of reports.)
// There is no limit to the number of reports that can be uploaded together.
// (Aside from the global cap on total reports.)
//
// TODO(juliatuttle): Consider capping the maximum number of reports per
// delivery attempt.
......
......@@ -55,6 +55,11 @@ ReportingReport::~ReportingReport() {
RecordReportOutcome(outcome);
}
ReportingEndpointGroupKey ReportingReport::GetGroupKey() const {
return ReportingEndpointGroupKey(network_isolation_key,
url::Origin::Create(url), group);
}
// static
void ReportingReport::RecordReportDiscardedForNoURLRequestContext() {
RecordReportOutcome(Outcome::DISCARDED_NO_URL_REQUEST_CONTEXT);
......
......@@ -12,6 +12,7 @@
#include "base/time/time.h"
#include "net/base/net_export.h"
#include "net/base/network_isolation_key.h"
#include "net/reporting/reporting_endpoint.h"
#include "url/gurl.h"
namespace base {
......@@ -65,6 +66,13 @@ struct NET_EXPORT ReportingReport {
// Records metrics about report outcome.
~ReportingReport();
// Bundles together the NIK, origin of the report URL, and group name.
// This is not exactly the same as the group key of the endpoint that the
// report will be delivered to. The origin may differ if the endpoint is
// configured for a superdomain of the report's origin. The NIK and group name
// will be the same.
ReportingEndpointGroupKey GetGroupKey() const;
static void RecordReportDiscardedForNoURLRequestContext();
static void RecordReportDiscardedForNoReportingService();
......
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