Skip to content

Commit

Permalink
Replace NetworkIsolationKey with NetworkAnonymizationKey on domain_re…
Browse files Browse the repository at this point in the history
…liability RequestInfo.

Bug: 1343856
Change-Id: Ie40222a19baacf3f1c95c1d70381484224581dba
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3921941
Reviewed-by: Matt Menke <mmenke@chromium.org>
Commit-Queue: Brianna Goldstein <brgoldstein@google.com>
Cr-Commit-Position: refs/heads/main@{#1052222}
  • Loading branch information
brgoldstein authored and Chromium LUCI CQ committed Sep 28, 2022
1 parent 290b900 commit b5e4efb
Show file tree
Hide file tree
Showing 12 changed files with 178 additions and 167 deletions.
8 changes: 4 additions & 4 deletions components/domain_reliability/beacon.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include "base/time/time.h"
#include "components/domain_reliability/domain_reliability_export.h"
#include "net/base/net_error_details.h"
#include "net/base/network_isolation_key.h"
#include "net/base/network_anonymization_key.h"
#include "url/gurl.h"

namespace base {
Expand Down Expand Up @@ -65,10 +65,10 @@ struct DOMAIN_RELIABILITY_EXPORT DomainReliabilityBeacon {
// The URL that the beacon is reporting on, if included.
// The scheme can be non-secure.
GURL url;
// The NetworkIsolationKey associated with the request being reported on. Must
// also be used to upload any report. This field does not appear in the
// The NetworkAnonymizationKey associated with the request being reported on.
// Must also be used to upload any report. This field does not appear in the
// uploaded report.
net::NetworkIsolationKey network_isolation_key;
net::NetworkAnonymizationKey network_anonymization_key;
// Status string (e.g. "ok", "dns.nxdomain", "http.403").
std::string status;
// Granular QUIC error string (e.g. "quic.peer_going_away").
Expand Down
31 changes: 17 additions & 14 deletions components/domain_reliability/context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,12 @@ void DomainReliabilityContext::StartUpload() {

// Find the first beacon with an `upload_depth` of at most
// kMaxUploadDepthToSchedule, in preparation to create a report containing all
// beacons with matching NetworkIsolationKeys.
// beacons with matching NetworkAnonymizationKeys.
bool found_beacon_to_upload = false;
for (const auto& beacon : beacons_) {
if (beacon->upload_depth <= kMaxUploadDepthToSchedule) {
uploading_beacons_network_isolation_key_ = beacon->network_isolation_key;
uploading_beacons_network_anonymization_key_ =
beacon->network_anonymization_key;
found_beacon_to_upload = true;
break;
}
Expand All @@ -152,7 +153,7 @@ void DomainReliabilityContext::StartUpload() {

uploader_->UploadReport(
report_json, max_upload_depth, collector_url,
uploading_beacons_network_isolation_key_,
uploading_beacons_network_anonymization_key_,
base::BindOnce(&DomainReliabilityContext::OnUploadComplete,
weak_factory_.GetWeakPtr()));
}
Expand All @@ -169,8 +170,9 @@ void DomainReliabilityContext::OnUploadComplete(
upload_time_ = base::TimeTicks();

// If there are pending beacons with a low enough depth, inform the scheduler
// - it's possible only some beacons were added because of NetworkIsolationKey
// mismatches, rather than due to new beacons being created.
// - it's possible only some beacons were added because of
// NetworkAnonymizationKey mismatches, rather than due to new beacons being
// created.
if (GetMinBeaconUploadDepth() <= kMaxUploadDepthToSchedule)
scheduler_.OnBeaconAdded();
}
Expand All @@ -185,9 +187,10 @@ base::Value DomainReliabilityContext::CreateReport(base::TimeTicks upload_time,

base::Value beacons_value(base::Value::Type::LIST);
for (const auto& beacon : beacons_) {
// Only include beacons with a matching NetworkIsolationKey in the report.
if (beacon->network_isolation_key !=
uploading_beacons_network_isolation_key_) {
// Only include beacons with a matching NetworkAnonymizationKey in the
// report.
if (beacon->network_anonymization_key !=
uploading_beacons_network_anonymization_key_) {
continue;
}

Expand Down Expand Up @@ -216,8 +219,8 @@ void DomainReliabilityContext::CommitUpload() {

auto last = current;
++current;
if ((*last)->network_isolation_key ==
uploading_beacons_network_isolation_key_) {
if ((*last)->network_anonymization_key ==
uploading_beacons_network_anonymization_key_) {
(*last)->outcome = DomainReliabilityBeacon::Outcome::kUploaded;
beacons_.erase(last);
--uploading_beacons_size_;
Expand All @@ -235,11 +238,11 @@ void DomainReliabilityContext::RemoveOldestBeacon() {
DVLOG(1) << "Beacon queue for " << config().origin << " full; "
<< "removing oldest beacon";

// If the beacon being removed has a NetworkIsolationKey that matches that of
// the current upload, decrement |uploading_beacons_size_|.
// If the beacon being removed has a NetworkAnonymizationKey that matches that
// of the current upload, decrement |uploading_beacons_size_|.
if (uploading_beacons_size_ > 0 &&
beacons_.front()->network_isolation_key ==
uploading_beacons_network_isolation_key_) {
beacons_.front()->network_anonymization_key ==
uploading_beacons_network_anonymization_key_) {
--uploading_beacons_size_;
}

Expand Down
14 changes: 7 additions & 7 deletions components/domain_reliability/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include "components/domain_reliability/domain_reliability_export.h"
#include "components/domain_reliability/scheduler.h"
#include "components/domain_reliability/uploader.h"
#include "net/base/network_isolation_key.h"
#include "net/base/network_anonymization_key.h"

class GURL;

Expand Down Expand Up @@ -89,7 +89,7 @@ class DOMAIN_RELIABILITY_EXPORT DomainReliabilityContext {
void OnUploadComplete(const DomainReliabilityUploader::UploadResult& result);

// Creates a report from all beacons associated with
// `uploading_beacons_network_isolation_key_`. Updates
// `uploading_beacons_network_anonymization_key_`. Updates
// `uploading_beacons_size_`.
base::Value CreateReport(base::TimeTicks upload_time,
const GURL& collector_url,
Expand Down Expand Up @@ -120,12 +120,12 @@ class DOMAIN_RELIABILITY_EXPORT DomainReliabilityContext {
std::list<std::unique_ptr<DomainReliabilityBeacon>> beacons_;

size_t uploading_beacons_size_;
// The NetworkIsolationKey associated with the beacons being uploaded. The
// The NetworkAnonymizationKey associated with the beacons being uploaded. The
// first `uploading_beacons_size_` beacons that have NIK equal to
// `uploading_beacons_network_isolation_key_` are currently being uploaded.
// It's possible for this number to be 0 when there's still an active upload
// if all currently uploading beacons have been evicted.
net::NetworkIsolationKey uploading_beacons_network_isolation_key_;
// `uploading_beacons_network_anonymization_key_` are currently being
// uploaded. It's possible for this number to be 0 when there's still an
// active upload if all currently uploading beacons have been evicted.
net::NetworkAnonymizationKey uploading_beacons_network_anonymization_key_;

base::TimeTicks upload_time_;
base::TimeTicks last_upload_time_;
Expand Down

0 comments on commit b5e4efb

Please sign in to comment.