Use std::optional in //content/browser/aggregation_service
I generated these changes with the following commands:
cd content/browser/aggregation_service/
git sed absl::nullopt std::nullopt
git sed absl::optional std::optional
git sed '"third_party/abseil-cpp/absl/types/optional.h"' '<optional>'
git cl format
This was not entirely automatic, as I had to manually move '#include
<optional>' into the correct block of includes.
Bug: 1503962
Low-Coverage-Reason: TRIVIAL_CHANGE
Change-Id: I4d7a89bfc5507e2dff395a85fead41a77c47f0d0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5047250
Auto-Submit: Dan McArdle <dmcardle@chromium.org>
Commit-Queue: Nan Lin <linnan@chromium.org>
Reviewed-by: Andrew Paseltiner <apaseltiner@chromium.org>
Reviewed-by: Nan Lin <linnan@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1227578}
diff --git a/content/browser/aggregation_service/aggregatable_report.cc b/content/browser/aggregation_service/aggregatable_report.cc
index 723a32c..14e5b08 100644
--- a/content/browser/aggregation_service/aggregatable_report.cc
+++ b/content/browser/aggregation_service/aggregatable_report.cc
@@ -41,7 +41,6 @@
#include "content/browser/aggregation_service/public_key.h"
#include "services/network/public/cpp/is_potentially_trustworthy.h"
#include "third_party/abseil-cpp/absl/numeric/int128.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
#include "third_party/blink/public/mojom/private_aggregation/aggregatable_report.mojom.h"
#include "third_party/boringssl/src/include/openssl/hpke.h"
#include "third_party/distributed_point_functions/dpf/distributed_point_function.pb.h"
@@ -62,7 +61,7 @@
std::vector<GURL> GetDefaultProcessingUrls(
blink::mojom::AggregationServiceMode aggregation_mode,
- const absl::optional<url::Origin>& aggregation_coordinator_origin) {
+ const std::optional<url::Origin>& aggregation_coordinator_origin) {
switch (aggregation_mode) {
case blink::mojom::AggregationServiceMode::kTeeBased:
if (base::FeatureList::IsEnabled(
@@ -154,7 +153,7 @@
value.emplace(kOperationKey, kHistogramValue);
value.emplace("dpf_key", std::move(serialized_key));
- absl::optional<std::vector<uint8_t>> unencrypted_payload =
+ std::optional<std::vector<uint8_t>> unencrypted_payload =
cbor::Writer::Write(cbor::Value(std::move(value)));
if (!unencrypted_payload.has_value()) {
@@ -233,7 +232,7 @@
value.emplace("data", std::move(data));
- absl::optional<std::vector<uint8_t>> unencrypted_payload =
+ std::optional<std::vector<uint8_t>> unencrypted_payload =
cbor::Writer::Write(cbor::Value(std::move(value)));
if (!unencrypted_payload.has_value()) {
@@ -293,12 +292,12 @@
return payload;
}
-absl::optional<AggregationServicePayloadContents>
+std::optional<AggregationServicePayloadContents>
ConvertPayloadContentsFromProto(
const proto::AggregationServicePayloadContents& proto) {
if (proto.operation() !=
proto::AggregationServicePayloadContents_Operation_HISTOGRAM) {
- return absl::nullopt;
+ return std::nullopt;
}
AggregationServicePayloadContents::Operation operation(
AggregationServicePayloadContents::Operation::kHistogram);
@@ -323,10 +322,10 @@
blink::mojom::AggregationServiceMode::kExperimentalPoplar;
break;
default:
- return absl::nullopt;
+ return std::nullopt;
}
- absl::optional<url::Origin> aggregation_coordinator_origin;
+ std::optional<url::Origin> aggregation_coordinator_origin;
if (proto.has_aggregation_coordinator_origin()) {
aggregation_coordinator_origin =
url::Origin::Create(GURL(proto.aggregation_coordinator_origin()));
@@ -334,7 +333,7 @@
int max_contributions_allowed = proto.max_contributions_allowed();
if (max_contributions_allowed < 0) {
- return absl::nullopt;
+ return std::nullopt;
} else if (max_contributions_allowed == 0) {
// Don't pad reports stored before padding was implemented.
max_contributions_allowed = contributions.size();
@@ -346,7 +345,7 @@
std::move(aggregation_coordinator_origin), max_contributions_allowed);
}
-absl::optional<AggregatableReportSharedInfo> ConvertSharedInfoFromProto(
+std::optional<AggregatableReportSharedInfo> ConvertSharedInfoFromProto(
const proto::AggregatableReportSharedInfo& proto) {
base::Time scheduled_report_time = base::Time::FromDeltaSinceWindowsEpoch(
base::Microseconds(proto.scheduled_report_time()));
@@ -363,7 +362,7 @@
debug_mode = AggregatableReportSharedInfo::DebugMode::kEnabled;
break;
default:
- return absl::nullopt;
+ return std::nullopt;
}
std::string api_version = proto.api_version();
@@ -379,21 +378,21 @@
std::move(api_version), std::move(api_identifier));
}
-absl::optional<AggregatableReportRequest> ConvertReportRequestFromProto(
+std::optional<AggregatableReportRequest> ConvertReportRequestFromProto(
proto::AggregatableReportRequest request_proto) {
- absl::optional<AggregationServicePayloadContents> payload_contents(
+ std::optional<AggregationServicePayloadContents> payload_contents(
ConvertPayloadContentsFromProto(request_proto.payload_contents()));
if (!payload_contents.has_value()) {
- return absl::nullopt;
+ return std::nullopt;
}
- absl::optional<AggregatableReportSharedInfo> shared_info(
+ std::optional<AggregatableReportSharedInfo> shared_info(
ConvertSharedInfoFromProto(request_proto.shared_info()));
if (!shared_info.has_value()) {
- return absl::nullopt;
+ return std::nullopt;
}
- absl::optional<uint64_t> debug_key;
+ std::optional<uint64_t> debug_key;
if (request_proto.has_debug_key()) {
debug_key = request_proto.debug_key();
}
@@ -521,7 +520,7 @@
std::vector<blink::mojom::AggregatableReportHistogramContribution>
contributions,
blink::mojom::AggregationServiceMode aggregation_mode,
- absl::optional<url::Origin> aggregation_coordinator_origin,
+ std::optional<url::Origin> aggregation_coordinator_origin,
int max_contributions_allowed)
: operation(operation),
contributions(std::move(contributions)),
@@ -609,11 +608,11 @@
}
// static
-absl::optional<AggregatableReportRequest> AggregatableReportRequest::Create(
+std::optional<AggregatableReportRequest> AggregatableReportRequest::Create(
AggregationServicePayloadContents payload_contents,
AggregatableReportSharedInfo shared_info,
std::string reporting_path,
- absl::optional<uint64_t> debug_key,
+ std::optional<uint64_t> debug_key,
base::flat_map<std::string, std::string> additional_fields,
int failed_send_attempts) {
std::vector<GURL> processing_urls =
@@ -626,13 +625,13 @@
}
// static
-absl::optional<AggregatableReportRequest>
+std::optional<AggregatableReportRequest>
AggregatableReportRequest::CreateForTesting(
std::vector<GURL> processing_urls,
AggregationServicePayloadContents payload_contents,
AggregatableReportSharedInfo shared_info,
std::string reporting_path,
- absl::optional<uint64_t> debug_key,
+ std::optional<uint64_t> debug_key,
base::flat_map<std::string, std::string> additional_fields,
int failed_send_attempts) {
return CreateInternal(std::move(processing_urls), std::move(payload_contents),
@@ -642,55 +641,55 @@
}
// static
-absl::optional<AggregatableReportRequest>
+std::optional<AggregatableReportRequest>
AggregatableReportRequest::CreateInternal(
std::vector<GURL> processing_urls,
AggregationServicePayloadContents payload_contents,
AggregatableReportSharedInfo shared_info,
std::string reporting_path,
- absl::optional<uint64_t> debug_key,
+ std::optional<uint64_t> debug_key,
base::flat_map<std::string, std::string> additional_fields,
int failed_send_attempts) {
if (!AggregatableReport::IsNumberOfProcessingUrlsValid(
processing_urls.size(), payload_contents.aggregation_mode)) {
- return absl::nullopt;
+ return std::nullopt;
}
if (!base::ranges::all_of(processing_urls,
network::IsUrlPotentiallyTrustworthy)) {
- return absl::nullopt;
+ return std::nullopt;
}
if (!AggregatableReport::IsNumberOfHistogramContributionsValid(
payload_contents.contributions.size(),
payload_contents.aggregation_mode)) {
- return absl::nullopt;
+ return std::nullopt;
}
if (base::ranges::any_of(
payload_contents.contributions,
[](const blink::mojom::AggregatableReportHistogramContribution&
contribution) { return contribution.value < 0; })) {
- return absl::nullopt;
+ return std::nullopt;
}
if (!shared_info.report_id.is_valid()) {
- return absl::nullopt;
+ return std::nullopt;
}
if (debug_key.has_value() &&
shared_info.debug_mode ==
AggregatableReportSharedInfo::DebugMode::kDisabled) {
- return absl::nullopt;
+ return std::nullopt;
}
if (failed_send_attempts < 0) {
- return absl::nullopt;
+ return std::nullopt;
}
if (payload_contents.max_contributions_allowed <
static_cast<int>(payload_contents.contributions.size())) {
- return absl::nullopt;
+ return std::nullopt;
}
// Ensure the ordering of urls is deterministic. This is required for
@@ -708,7 +707,7 @@
AggregationServicePayloadContents payload_contents,
AggregatableReportSharedInfo shared_info,
std::string reporting_path,
- absl::optional<uint64_t> debug_key,
+ std::optional<uint64_t> debug_key,
base::flat_map<std::string, std::string> additional_fields,
int failed_send_attempts)
: processing_urls_(std::move(processing_urls)),
@@ -734,13 +733,12 @@
return shared_info().reporting_origin.GetURL().Resolve(reporting_path_);
}
-absl::optional<AggregatableReportRequest>
-AggregatableReportRequest::Deserialize(
+std::optional<AggregatableReportRequest> AggregatableReportRequest::Deserialize(
base::span<const uint8_t> serialized_proto) {
proto::AggregatableReportRequest request_proto;
if (!request_proto.ParseFromArray(serialized_proto.data(),
serialized_proto.size())) {
- return absl::nullopt;
+ return std::nullopt;
}
return ConvertReportRequestFromProto(std::move(request_proto));
@@ -762,7 +760,7 @@
AggregatableReport::AggregationServicePayload::AggregationServicePayload(
std::vector<uint8_t> payload,
std::string key_id,
- absl::optional<std::vector<uint8_t>> debug_cleartext_payload)
+ std::optional<std::vector<uint8_t>> debug_cleartext_payload)
: payload(std::move(payload)),
key_id(std::move(key_id)),
debug_cleartext_payload(std::move(debug_cleartext_payload)) {}
@@ -783,9 +781,9 @@
AggregatableReport::AggregatableReport(
std::vector<AggregationServicePayload> payloads,
std::string shared_info,
- absl::optional<uint64_t> debug_key,
+ std::optional<uint64_t> debug_key,
base::flat_map<std::string, std::string> additional_fields,
- absl::optional<url::Origin> aggregation_coordinator_origin)
+ std::optional<url::Origin> aggregation_coordinator_origin)
: payloads_(std::move(payloads)),
shared_info_(std::move(shared_info)),
debug_key_(debug_key),
@@ -818,7 +816,7 @@
AggregatableReport::Provider::~Provider() = default;
-absl::optional<AggregatableReport>
+std::optional<AggregatableReport>
AggregatableReport::Provider::CreateFromRequestAndPublicKeys(
const AggregatableReportRequest& report_request,
std::vector<PublicKey> public_keys) const {
@@ -853,7 +851,7 @@
}
if (unencrypted_payloads.empty()) {
- return absl::nullopt;
+ return std::nullopt;
}
std::string encoded_shared_info =
@@ -876,10 +874,10 @@
/*authenticated_info=*/authenticated_info);
if (encrypted_payload.empty()) {
- return absl::nullopt;
+ return std::nullopt;
}
- absl::optional<std::vector<uint8_t>> debug_cleartext_payload;
+ std::optional<std::vector<uint8_t>> debug_cleartext_payload;
if (report_request.shared_info().debug_mode ==
AggregatableReportSharedInfo::DebugMode::kEnabled) {
debug_cleartext_payload = std::move(unencrypted_payloads[i]);
diff --git a/content/browser/aggregation_service/aggregatable_report.h b/content/browser/aggregation_service/aggregatable_report.h
index 0b98b3cb2a..d1c5667 100644
--- a/content/browser/aggregation_service/aggregatable_report.h
+++ b/content/browser/aggregation_service/aggregatable_report.h
@@ -8,6 +8,7 @@
#include <stddef.h>
#include <stdint.h>
+#include <optional>
#include <ostream>
#include <string>
#include <vector>
@@ -21,7 +22,6 @@
#include "content/browser/aggregation_service/public_key.h"
#include "content/common/content_export.h"
#include "third_party/abseil-cpp/absl/numeric/int128.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
#include "third_party/blink/public/mojom/private_aggregation/aggregatable_report.mojom.h"
#include "url/gurl.h"
#include "url/origin.h"
@@ -41,7 +41,7 @@
};
// The default aggregation coordinator origin will be used if
- // `aggregation_coordinator_origin` is `absl::nullopt`.
+ // `aggregation_coordinator_origin` is `std::nullopt`.
// `max_contributions_allowed` specifies the maximum number of contributions
// per report for use in padding.
AggregationServicePayloadContents(
@@ -49,7 +49,7 @@
std::vector<blink::mojom::AggregatableReportHistogramContribution>
contributions,
blink::mojom::AggregationServiceMode aggregation_mode,
- absl::optional<url::Origin> aggregation_coordinator_origin,
+ std::optional<url::Origin> aggregation_coordinator_origin,
int max_contributions_allowed);
AggregationServicePayloadContents(
@@ -65,7 +65,7 @@
std::vector<blink::mojom::AggregatableReportHistogramContribution>
contributions;
blink::mojom::AggregationServiceMode aggregation_mode;
- absl::optional<url::Origin> aggregation_coordinator_origin;
+ std::optional<url::Origin> aggregation_coordinator_origin;
int max_contributions_allowed;
};
@@ -122,7 +122,7 @@
AggregationServicePayload(
std::vector<uint8_t> payload,
std::string key_id,
- absl::optional<std::vector<uint8_t>> debug_cleartext_payload);
+ std::optional<std::vector<uint8_t>> debug_cleartext_payload);
AggregationServicePayload(const AggregationServicePayload& other);
AggregationServicePayload& operator=(
const AggregationServicePayload& other);
@@ -151,8 +151,8 @@
std::string key_id;
// If the request's shared info had a `kEnabled` debug_mode, contains the
- // cleartext payload for debugging. Otherwise, it is `absl::nullopt`.
- absl::optional<std::vector<uint8_t>> debug_cleartext_payload;
+ // cleartext payload for debugging. Otherwise, it is `std::nullopt`.
+ std::optional<std::vector<uint8_t>> debug_cleartext_payload;
};
// Used to allow mocking `CreateFromRequestAndPublicKeys()` in tests.
@@ -163,8 +163,8 @@
// Processes and serializes the information in `report_request` and encrypts
// using the `public_keys` as necessary. The order of `public_keys` should
// correspond to `report_request.processing_urls`, which should be
- // sorted. Returns `absl::nullopt` if an error occurred during construction.
- virtual absl::optional<AggregatableReport> CreateFromRequestAndPublicKeys(
+ // sorted. Returns `std::nullopt` if an error occurred during construction.
+ virtual std::optional<AggregatableReport> CreateFromRequestAndPublicKeys(
const AggregatableReportRequest& report_request,
std::vector<PublicKey> public_keys) const;
@@ -190,12 +190,11 @@
static constexpr base::StringPiece kDomainSeparationPrefix =
"aggregation_service";
- AggregatableReport(
- std::vector<AggregationServicePayload> payloads,
- std::string shared_info,
- absl::optional<uint64_t> debug_key,
- base::flat_map<std::string, std::string> additional_fields,
- absl::optional<url::Origin> aggregation_coordinator_origin);
+ AggregatableReport(std::vector<AggregationServicePayload> payloads,
+ std::string shared_info,
+ std::optional<uint64_t> debug_key,
+ base::flat_map<std::string, std::string> additional_fields,
+ std::optional<url::Origin> aggregation_coordinator_origin);
AggregatableReport(const AggregatableReport& other);
AggregatableReport& operator=(const AggregatableReport& other);
AggregatableReport(AggregatableReport&& other);
@@ -206,11 +205,11 @@
return payloads_;
}
const std::string& shared_info() const { return shared_info_; }
- absl::optional<uint64_t> debug_key() const { return debug_key_; }
+ std::optional<uint64_t> debug_key() const { return debug_key_; }
const base::flat_map<std::string, std::string>& additional_fields() const {
return additional_fields_;
}
- const absl::optional<url::Origin>& aggregation_coordinator_origin() const {
+ const std::optional<url::Origin>& aggregation_coordinator_origin() const {
return aggregation_coordinator_origin_;
}
@@ -273,11 +272,11 @@
// Should only be set if the debug mode is enabled (but can still be empty).
// Used as part of the temporary debugging mechanism.
- absl::optional<uint64_t> debug_key_;
+ std::optional<uint64_t> debug_key_;
base::flat_map<std::string, std::string> additional_fields_;
- absl::optional<url::Origin> aggregation_coordinator_origin_;
+ std::optional<url::Origin> aggregation_coordinator_origin_;
};
// Represents a request for an AggregatableReport. Contains all the data
@@ -285,45 +284,45 @@
// processing URL.
class CONTENT_EXPORT AggregatableReportRequest {
public:
- // Returns `absl::nullopt` if `payload_contents.contributions.size()` is not
+ // Returns `std::nullopt` if `payload_contents.contributions.size()` is not
// valid for the `payload_contents.aggregation_mode` (see
// `IsNumberOfHistogramContributionsValid()` above). Also returns
- // `absl::nullopt` if any contribution has a negative value, if
+ // `std::nullopt` if any contribution has a negative value, if
// `shared_info.report_id` is not valid, or if `debug_key.has_value()` but
- // `shared_info.debug_mode` is `kDisabled`. Also returns `absl::nullopt` if
+ // `shared_info.debug_mode` is `kDisabled`. Also returns `std::nullopt` if
// `failed_send_attempts` is negative or if
// `payload_contents.max_contributions_allowed` is less than the number of
// contributions.
// TODO(alexmt): Add validation for scheduled_report_time being non-null/inf.
- static absl::optional<AggregatableReportRequest> Create(
+ static std::optional<AggregatableReportRequest> Create(
AggregationServicePayloadContents payload_contents,
AggregatableReportSharedInfo shared_info,
std::string reporting_path = std::string(),
- absl::optional<uint64_t> debug_key = absl::nullopt,
+ std::optional<uint64_t> debug_key = std::nullopt,
base::flat_map<std::string, std::string> additional_fields = {},
int failed_send_attempts = 0);
- // Returns `absl::nullopt` if `payload_contents.contributions.size()` or
+ // Returns `std::nullopt` if `payload_contents.contributions.size()` or
// `processing_url.size()` is not valid for the
// `payload_contents.aggregation_mode` (see
// `IsNumberOfHistogramContributionsValid()` and
// `IsNumberOfProcessingUrlsValid`, respectively). Also returns
- // `absl::nullopt` if any contribution has a negative value, if
+ // `std::nullopt` if any contribution has a negative value, if
// `shared_info.report_id` is not valid, or if `debug_key.has_value()` but
- // `shared_info.debug_mode` is `kDisabled`. Also returns `absl::nullopt` if
+ // `shared_info.debug_mode` is `kDisabled`. Also returns `std::nullopt` if
// `failed_send_attempts` is negative
- static absl::optional<AggregatableReportRequest> CreateForTesting(
+ static std::optional<AggregatableReportRequest> CreateForTesting(
std::vector<GURL> processing_urls,
AggregationServicePayloadContents payload_contents,
AggregatableReportSharedInfo shared_info,
std::string reporting_path = std::string(),
- absl::optional<uint64_t> debug_key = absl::nullopt,
+ std::optional<uint64_t> debug_key = std::nullopt,
base::flat_map<std::string, std::string> additional_fields = {},
int failed_send_attempts = 0);
// Deserializes a bytestring generated by `Serialize()`. Returns
- // `absl::nullopt` in the case of a deserialization error.
- static absl::optional<AggregatableReportRequest> Deserialize(
+ // `std::nullopt` in the case of a deserialization error.
+ static std::optional<AggregatableReportRequest> Deserialize(
base::span<const uint8_t> serialized_proto);
// Move-only.
@@ -339,7 +338,7 @@
return shared_info_;
}
const std::string& reporting_path() const { return reporting_path_; }
- absl::optional<uint64_t> debug_key() const { return debug_key_; }
+ std::optional<uint64_t> debug_key() const { return debug_key_; }
const base::flat_map<std::string, std::string>& additional_fields() const {
return additional_fields_;
}
@@ -354,12 +353,12 @@
std::vector<uint8_t> Serialize();
private:
- static absl::optional<AggregatableReportRequest> CreateInternal(
+ static std::optional<AggregatableReportRequest> CreateInternal(
std::vector<GURL> processing_urls,
AggregationServicePayloadContents payload_contents,
AggregatableReportSharedInfo shared_info,
std::string reporting_path,
- absl::optional<uint64_t> debug_key,
+ std::optional<uint64_t> debug_key,
base::flat_map<std::string, std::string> additional_fields,
int failed_send_attempts);
@@ -368,7 +367,7 @@
AggregationServicePayloadContents payload_contents,
AggregatableReportSharedInfo shared_info,
std::string reporting_path,
- absl::optional<uint64_t> debug_key,
+ std::optional<uint64_t> debug_key,
base::flat_map<std::string, std::string> additional_fields,
int failed_send_attempts);
@@ -383,7 +382,7 @@
// Can only be set if `shared_info_.debug_mode` is `kEnabled` (but can still
// be empty). Used as part of the temporary debugging mechanism.
- absl::optional<uint64_t> debug_key_;
+ std::optional<uint64_t> debug_key_;
base::flat_map<std::string, std::string> additional_fields_;
diff --git a/content/browser/aggregation_service/aggregatable_report_assembler.cc b/content/browser/aggregation_service/aggregatable_report_assembler.cc
index 83113ad..0a84b6d 100644
--- a/content/browser/aggregation_service/aggregatable_report_assembler.cc
+++ b/content/browser/aggregation_service/aggregatable_report_assembler.cc
@@ -5,6 +5,7 @@
#include "content/browser/aggregation_service/aggregatable_report_assembler.h"
#include <memory>
+#include <optional>
#include <utility>
#include <vector>
@@ -24,7 +25,6 @@
#include "content/browser/aggregation_service/public_key.h"
#include "content/public/browser/storage_partition.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace content {
@@ -126,7 +126,7 @@
if (pending_requests_.size() >= kMaxSimultaneousRequests) {
RecordAssemblyStatus(AssemblyStatus::kTooManySimultaneousRequests);
- std::move(callback).Run(std::move(report_request), absl::nullopt,
+ std::move(callback).Run(std::move(report_request), std::nullopt,
AssemblyStatus::kTooManySimultaneousRequests);
return;
}
@@ -153,7 +153,7 @@
void AggregatableReportAssembler::OnPublicKeyFetched(
int64_t report_id,
size_t processing_url_index,
- absl::optional<PublicKey> key,
+ std::optional<PublicKey> key,
AggregationServiceKeyFetcher::PublicKeyFetchStatus status) {
DCHECK_EQ(key.has_value(),
status == AggregationServiceKeyFetcher::PublicKeyFetchStatus::kOk);
@@ -177,12 +177,12 @@
int64_t report_id,
PendingRequest& pending_request) {
std::vector<PublicKey> public_keys;
- for (absl::optional<PublicKey> elem : pending_request.processing_url_keys) {
+ for (std::optional<PublicKey> elem : pending_request.processing_url_keys) {
if (!elem.has_value()) {
RecordAssemblyStatus(AssemblyStatus::kPublicKeyFetchFailed);
std::move(pending_request.callback)
- .Run(std::move(pending_request.report_request), absl::nullopt,
+ .Run(std::move(pending_request.report_request), std::nullopt,
AssemblyStatus::kPublicKeyFetchFailed);
pending_requests_.erase(report_id);
return;
@@ -191,7 +191,7 @@
public_keys.push_back(std::move(elem.value()));
}
- absl::optional<AggregatableReport> assembled_report =
+ std::optional<AggregatableReport> assembled_report =
report_provider_->CreateFromRequestAndPublicKeys(
pending_request.report_request, std::move(public_keys));
AssemblyStatus assembly_status =
diff --git a/content/browser/aggregation_service/aggregatable_report_assembler.h b/content/browser/aggregation_service/aggregatable_report_assembler.h
index d948e95..65533b7 100644
--- a/content/browser/aggregation_service/aggregatable_report_assembler.h
+++ b/content/browser/aggregation_service/aggregatable_report_assembler.h
@@ -10,6 +10,7 @@
#include <array>
#include <memory>
+#include <optional>
#include <vector>
#include "base/containers/flat_map.h"
@@ -18,7 +19,6 @@
#include "content/browser/aggregation_service/aggregation_service_key_fetcher.h"
#include "content/browser/aggregation_service/public_key.h"
#include "content/common/content_export.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
template <class T>
class scoped_refptr;
@@ -55,7 +55,7 @@
using AssemblyCallback =
base::OnceCallback<void(AggregatableReportRequest,
- absl::optional<AggregatableReport>,
+ std::optional<AggregatableReport>,
AssemblyStatus)>;
// While we shouldn't hit these limits in typical usage, we protect against
@@ -114,9 +114,9 @@
// The PublicKey returned for each key fetch request. Indices correspond to
// the ordering of `report_request.processing_urls`. Each element is
- // `absl::nullopt` if that key fetch either has not yet returned or has
+ // `std::nullopt` if that key fetch either has not yet returned or has
// returned an error.
- std::vector<absl::optional<PublicKey>> processing_url_keys;
+ std::vector<std::optional<PublicKey>> processing_url_keys;
};
AggregatableReportAssembler(
@@ -131,7 +131,7 @@
void OnPublicKeyFetched(
int64_t report_id,
size_t processing_url_index,
- absl::optional<PublicKey> key,
+ std::optional<PublicKey> key,
AggregationServiceKeyFetcher::PublicKeyFetchStatus status);
// Call when all results have been returned from the key fetcher. Handles
diff --git a/content/browser/aggregation_service/aggregatable_report_assembler_unittest.cc b/content/browser/aggregation_service/aggregatable_report_assembler_unittest.cc
index 1909564..6e6ffe8 100644
--- a/content/browser/aggregation_service/aggregatable_report_assembler_unittest.cc
+++ b/content/browser/aggregation_service/aggregatable_report_assembler_unittest.cc
@@ -7,6 +7,7 @@
#include <stddef.h>
#include <memory>
+#include <optional>
#include <utility>
#include <vector>
@@ -23,7 +24,6 @@
#include "content/browser/aggregation_service/public_key.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
#include "third_party/blink/public/mojom/private_aggregation/aggregatable_report.mojom.h"
#include "url/gurl.h"
@@ -47,7 +47,7 @@
constexpr char kReportAssemblerStatusHistogramName[] =
"PrivacySandbox.AggregationService.ReportAssembler.Status";
-auto CloneRequestAndReturnReport(absl::optional<AggregatableReportRequest>* out,
+auto CloneRequestAndReturnReport(std::optional<AggregatableReportRequest>* out,
AggregatableReport report) {
return [out, report = std::move(report)](
const AggregatableReportRequest& report_request,
@@ -71,7 +71,7 @@
class MockAggregatableReportProvider : public AggregatableReport::Provider {
public:
- MOCK_METHOD(absl::optional<AggregatableReport>,
+ MOCK_METHOD(std::optional<AggregatableReport>,
CreateFromRequestAndPublicKeys,
(const AggregatableReportRequest&, std::vector<PublicKey>),
(const, override));
@@ -123,12 +123,12 @@
EXPECT_CALL(*fetcher(), GetPublicKey(processing_urls[0], _))
.WillOnce(base::test::RunOnceCallback<1>(
- absl::nullopt, PublicKeyFetchStatus::kPublicKeyFetchFailed));
+ std::nullopt, PublicKeyFetchStatus::kPublicKeyFetchFailed));
EXPECT_CALL(*fetcher(), GetPublicKey(processing_urls[1], _))
.WillOnce(base::test::RunOnceCallback<1>(
- absl::nullopt, PublicKeyFetchStatus::kPublicKeyFetchFailed));
+ std::nullopt, PublicKeyFetchStatus::kPublicKeyFetchFailed));
EXPECT_CALL(callback(),
- Run(_, Eq(absl::nullopt), AssemblyStatus::kPublicKeyFetchFailed));
+ Run(_, Eq(std::nullopt), AssemblyStatus::kPublicKeyFetchFailed));
EXPECT_CALL(*report_provider(), CreateFromRequestAndPublicKeys(_, _))
.Times(0);
@@ -149,13 +149,13 @@
EXPECT_CALL(*fetcher(), GetPublicKey(processing_urls[0], _))
.WillOnce(base::test::RunOnceCallback<1>(
- absl::nullopt, PublicKeyFetchStatus::kPublicKeyFetchFailed));
+ std::nullopt, PublicKeyFetchStatus::kPublicKeyFetchFailed));
EXPECT_CALL(*fetcher(), GetPublicKey(processing_urls[1], _))
.WillOnce(base::test::RunOnceCallback<1>(
aggregation_service::TestHpkeKey().GetPublicKey(),
PublicKeyFetchStatus::kOk));
EXPECT_CALL(callback(),
- Run(_, Eq(absl::nullopt), AssemblyStatus::kPublicKeyFetchFailed));
+ Run(_, Eq(std::nullopt), AssemblyStatus::kPublicKeyFetchFailed));
EXPECT_CALL(*report_provider(), CreateFromRequestAndPublicKeys(_, _))
.Times(0);
@@ -180,9 +180,9 @@
PublicKeyFetchStatus::kOk));
EXPECT_CALL(*fetcher(), GetPublicKey(processing_urls[1], _))
.WillOnce(base::test::RunOnceCallback<1>(
- absl::nullopt, PublicKeyFetchStatus::kPublicKeyFetchFailed));
+ std::nullopt, PublicKeyFetchStatus::kPublicKeyFetchFailed));
EXPECT_CALL(callback(),
- Run(_, Eq(absl::nullopt), AssemblyStatus::kPublicKeyFetchFailed));
+ Run(_, Eq(std::nullopt), AssemblyStatus::kPublicKeyFetchFailed));
EXPECT_CALL(*report_provider(), CreateFromRequestAndPublicKeys(_, _))
.Times(0);
@@ -206,7 +206,7 @@
aggregation_service::TestHpkeKey("id123").GetPublicKey(),
aggregation_service::TestHpkeKey("456abc").GetPublicKey()};
- absl::optional<AggregatableReport> report =
+ std::optional<AggregatableReport> report =
AggregatableReport::Provider().CreateFromRequestAndPublicKeys(
request, public_keys);
ASSERT_TRUE(report.has_value());
@@ -219,7 +219,7 @@
PublicKeyFetchStatus::kOk));
EXPECT_CALL(callback(), Run(_, report, AssemblyStatus::kOk));
- absl::optional<AggregatableReportRequest> actual_request;
+ std::optional<AggregatableReportRequest> actual_request;
EXPECT_CALL(*report_provider(),
CreateFromRequestAndPublicKeys(_, public_keys))
.WillOnce(CloneRequestAndReturnReport(&actual_request,
@@ -246,7 +246,7 @@
PublicKey public_key =
aggregation_service::TestHpkeKey("id123").GetPublicKey();
- absl::optional<AggregatableReport> report =
+ std::optional<AggregatableReport> report =
AggregatableReport::Provider().CreateFromRequestAndPublicKeys(
request, {public_key});
ASSERT_TRUE(report.has_value());
@@ -256,7 +256,7 @@
PublicKeyFetchStatus::kOk));
EXPECT_CALL(callback(), Run(_, report, AssemblyStatus::kOk));
- absl::optional<AggregatableReportRequest> actual_request;
+ std::optional<AggregatableReportRequest> actual_request;
EXPECT_CALL(*report_provider(), CreateFromRequestAndPublicKeys(
_, std::vector<PublicKey>{public_key}))
.WillOnce(CloneRequestAndReturnReport(&actual_request,
@@ -281,9 +281,9 @@
EXPECT_CALL(*fetcher(), GetPublicKey)
.WillOnce(base::test::RunOnceCallback<1>(
- absl::nullopt, PublicKeyFetchStatus::kPublicKeyFetchFailed));
+ std::nullopt, PublicKeyFetchStatus::kPublicKeyFetchFailed));
EXPECT_CALL(callback(),
- Run(_, Eq(absl::nullopt), AssemblyStatus::kPublicKeyFetchFailed));
+ Run(_, Eq(std::nullopt), AssemblyStatus::kPublicKeyFetchFailed));
EXPECT_CALL(*report_provider(), CreateFromRequestAndPublicKeys(_, _))
.Times(0);
@@ -307,7 +307,7 @@
aggregation_service::TestHpkeKey("id123").GetPublicKey(),
aggregation_service::TestHpkeKey("456abc").GetPublicKey()};
- absl::optional<AggregatableReport> report =
+ std::optional<AggregatableReport> report =
AggregatableReport::Provider().CreateFromRequestAndPublicKeys(
request, public_keys);
ASSERT_TRUE(report.has_value());
@@ -319,7 +319,7 @@
.WillOnce(MoveArg<1>(&pending_callbacks.back()));
EXPECT_CALL(callback(), Run(_, report, AssemblyStatus::kOk));
- absl::optional<AggregatableReportRequest> actual_request;
+ std::optional<AggregatableReportRequest> actual_request;
EXPECT_CALL(*report_provider(),
CreateFromRequestAndPublicKeys(_, public_keys))
.WillOnce(CloneRequestAndReturnReport(&actual_request,
@@ -367,7 +367,7 @@
PublicKey public_key =
aggregation_service::TestHpkeKey("id123").GetPublicKey();
- absl::optional<AggregatableReport> report =
+ std::optional<AggregatableReport> report =
AggregatableReport::Provider().CreateFromRequestAndPublicKeys(
request, {public_key});
ASSERT_TRUE(report.has_value());
@@ -379,8 +379,8 @@
EXPECT_CALL(callback(), Run(_, report, AssemblyStatus::kOk)).Times(2);
- absl::optional<AggregatableReportRequest> first_request;
- absl::optional<AggregatableReportRequest> second_request;
+ std::optional<AggregatableReportRequest> first_request;
+ std::optional<AggregatableReportRequest> second_request;
EXPECT_CALL(*report_provider(), CreateFromRequestAndPublicKeys(
_, std::vector<PublicKey>{public_key}))
.WillOnce(CloneRequestAndReturnReport(&first_request, report.value()))
@@ -415,7 +415,7 @@
PublicKey public_key =
aggregation_service::TestHpkeKey("id123").GetPublicKey();
- absl::optional<AggregatableReport> report =
+ std::optional<AggregatableReport> report =
AggregatableReport::Provider().CreateFromRequestAndPublicKeys(
aggregation_service::CreateExampleRequest(), {std::move(public_key)});
ASSERT_TRUE(report.has_value());
@@ -439,7 +439,7 @@
EXPECT_CALL(checkpoint, Call(current_check++));
- EXPECT_CALL(callback(), Run(_, Eq(absl::nullopt),
+ EXPECT_CALL(callback(), Run(_, Eq(std::nullopt),
AssemblyStatus::kTooManySimultaneousRequests))
.Times(1);
diff --git a/content/browser/aggregation_service/aggregatable_report_scheduler.cc b/content/browser/aggregation_service/aggregatable_report_scheduler.cc
index d383dcbf..79f8357 100644
--- a/content/browser/aggregation_service/aggregatable_report_scheduler.cc
+++ b/content/browser/aggregation_service/aggregatable_report_scheduler.cc
@@ -6,6 +6,7 @@
#include <algorithm>
#include <memory>
+#include <optional>
#include <utility>
#include <vector>
@@ -25,7 +26,6 @@
#include "content/browser/aggregation_service/aggregation_service_storage.h"
#include "content/browser/aggregation_service/aggregation_service_storage_context.h"
#include "content/public/common/content_switches.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace content {
@@ -69,7 +69,7 @@
AggregationServiceStorage::RequestId request_id,
int previous_failed_attempts) {
DCHECK_GE(previous_failed_attempts, 0);
- absl::optional<base::TimeDelta> delay =
+ std::optional<base::TimeDelta> delay =
GetFailedReportDelay(previous_failed_attempts + 1);
if (delay.has_value()) {
@@ -93,12 +93,12 @@
return false;
}
-absl::optional<base::TimeDelta>
+std::optional<base::TimeDelta>
AggregatableReportScheduler::GetFailedReportDelay(int failed_send_attempts) {
DCHECK_GT(failed_send_attempts, 0);
if (failed_send_attempts > kMaxRetries)
- return absl::nullopt;
+ return std::nullopt;
return kInitialRetryDelay *
std::pow(kRetryDelayFactor, failed_send_attempts - 1);
@@ -120,7 +120,7 @@
AggregatableReportScheduler::TimerDelegate::~TimerDelegate() = default;
void AggregatableReportScheduler::TimerDelegate::GetNextReportTime(
- base::OnceCallback<void(absl::optional<base::Time>)> callback,
+ base::OnceCallback<void(std::optional<base::Time>)> callback,
base::Time now) {
storage_context_->GetStorage()
.AsyncCall(&AggregationServiceStorage::NextReportTimeAfter)
@@ -132,14 +132,14 @@
base::Time now) {
storage_context_->GetStorage()
.AsyncCall(&AggregationServiceStorage::GetRequestsReportingOnOrBefore)
- .WithArgs(now, /*limit=*/absl::nullopt)
+ .WithArgs(now, /*limit=*/std::nullopt)
.Then(base::BindOnce(&AggregatableReportScheduler::TimerDelegate::
OnRequestsReturnedFromStorage,
weak_ptr_factory_.GetWeakPtr()));
}
void AggregatableReportScheduler::TimerDelegate::AdjustOfflineReportTimes(
- base::OnceCallback<void(absl::optional<base::Time>)> maybe_set_timer_cb) {
+ base::OnceCallback<void(std::optional<base::Time>)> maybe_set_timer_cb) {
if (should_not_delay_reports_) {
// No need to adjust the report times, just set the timer as appropriate.
storage_context_->GetStorage()
diff --git a/content/browser/aggregation_service/aggregatable_report_scheduler.h b/content/browser/aggregation_service/aggregatable_report_scheduler.h
index fd6c0c4..2d370744 100644
--- a/content/browser/aggregation_service/aggregatable_report_scheduler.h
+++ b/content/browser/aggregation_service/aggregatable_report_scheduler.h
@@ -5,6 +5,7 @@
#ifndef CONTENT_BROWSER_AGGREGATION_SERVICE_AGGREGATABLE_REPORT_SCHEDULER_H_
#define CONTENT_BROWSER_AGGREGATION_SERVICE_AGGREGATABLE_REPORT_SCHEDULER_H_
+#include <optional>
#include <set>
#include <vector>
@@ -15,7 +16,6 @@
#include "content/browser/aggregation_service/aggregation_service_storage.h"
#include "content/browser/aggregation_service/report_scheduler_timer.h"
#include "content/common/content_export.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace base {
class Time;
@@ -110,11 +110,11 @@
private:
// ReportSchedulerTimer::Delegate:
- void GetNextReportTime(base::OnceCallback<void(absl::optional<base::Time>)>,
+ void GetNextReportTime(base::OnceCallback<void(std::optional<base::Time>)>,
base::Time now) override;
void OnReportingTimeReached(base::Time now) override;
void AdjustOfflineReportTimes(
- base::OnceCallback<void(absl::optional<base::Time>)>) override;
+ base::OnceCallback<void(std::optional<base::Time>)>) override;
void OnRequestsReturnedFromStorage(
std::vector<AggregationServiceStorage::RequestAndId> requests_and_ids);
@@ -146,10 +146,10 @@
// Returns how long to wait before attempting to send a report that has
// previously failed to be sent failed_send_attempts times. Returns
- // `absl::nullopt` to indicate that no more attempts should be made.
+ // `std::nullopt` to indicate that no more attempts should be made.
// Otherwise, the return value must be positive. `failed_send_attempts`
// must be positive.
- static absl::optional<base::TimeDelta> GetFailedReportDelay(
+ static std::optional<base::TimeDelta> GetFailedReportDelay(
int failed_send_attempts);
// Using a raw reference is safe because `storage_context_` is guaranteed to
diff --git a/content/browser/aggregation_service/aggregatable_report_scheduler_unittest.cc b/content/browser/aggregation_service/aggregatable_report_scheduler_unittest.cc
index d4a80a9..c89dd62 100644
--- a/content/browser/aggregation_service/aggregatable_report_scheduler_unittest.cc
+++ b/content/browser/aggregation_service/aggregatable_report_scheduler_unittest.cc
@@ -5,6 +5,7 @@
#include "content/browser/aggregation_service/aggregatable_report_scheduler.h"
#include <memory>
+#include <optional>
#include <utility>
#include <vector>
@@ -26,7 +27,6 @@
#include "services/network/test/test_network_connection_tracker.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace content {
@@ -86,7 +86,7 @@
storage_context_.GetStorage()
.AsyncCall(&AggregationServiceStorage::GetRequestsReportingOnOrBefore)
- .WithArgs(base::Time::Max(), /*limit=*/absl::nullopt)
+ .WithArgs(base::Time::Max(), /*limit=*/std::nullopt)
.Then(base::BindLambdaForTesting(
[&run_loop](std::vector<AggregationServiceStorage::RequestAndId>
requests_and_ids) {
@@ -122,7 +122,7 @@
storage_context_.GetStorage()
.AsyncCall(&AggregationServiceStorage::GetRequestsReportingOnOrBefore)
- .WithArgs(base::Time::Max(), /*limit=*/absl::nullopt)
+ .WithArgs(base::Time::Max(), /*limit=*/std::nullopt)
.Then(base::BindLambdaForTesting(
[&run_loop](std::vector<AggregationServiceStorage::RequestAndId>
requests_and_ids) {
@@ -142,7 +142,7 @@
storage_context_.GetStorage()
.AsyncCall(&AggregationServiceStorage::GetRequestsReportingOnOrBefore)
- .WithArgs(base::Time::Max(), /*limit=*/absl::nullopt)
+ .WithArgs(base::Time::Max(), /*limit=*/std::nullopt)
.Then(base::BindLambdaForTesting(
[&run_loop](std::vector<AggregationServiceStorage::RequestAndId>
requests_and_ids) {
@@ -183,7 +183,7 @@
storage_context_.GetStorage()
.AsyncCall(&AggregationServiceStorage::GetRequestsReportingOnOrBefore)
- .WithArgs(base::Time::Max(), /*limit=*/absl::nullopt)
+ .WithArgs(base::Time::Max(), /*limit=*/std::nullopt)
.Then(base::BindLambdaForTesting(
[&run_loop](std::vector<AggregationServiceStorage::RequestAndId>
requests_and_ids) {
@@ -202,7 +202,7 @@
storage_context_.GetStorage()
.AsyncCall(&AggregationServiceStorage::GetRequestsReportingOnOrBefore)
- .WithArgs(base::Time::Max(), /*limit=*/absl::nullopt)
+ .WithArgs(base::Time::Max(), /*limit=*/std::nullopt)
.Then(base::BindLambdaForTesting(
[&run_loop](std::vector<AggregationServiceStorage::RequestAndId>
requests_and_ids) {
@@ -239,7 +239,7 @@
storage_context_.GetStorage()
.AsyncCall(&AggregationServiceStorage::GetRequestsReportingOnOrBefore)
- .WithArgs(base::Time::Max(), /*limit=*/absl::nullopt)
+ .WithArgs(base::Time::Max(), /*limit=*/std::nullopt)
.Then(base::BindLambdaForTesting(
[&run_loop](std::vector<AggregationServiceStorage::RequestAndId>
requests_and_ids) {
@@ -260,7 +260,7 @@
storage_context_.GetStorage()
.AsyncCall(&AggregationServiceStorage::GetRequestsReportingOnOrBefore)
- .WithArgs(base::Time::Max(), /*limit=*/absl::nullopt)
+ .WithArgs(base::Time::Max(), /*limit=*/std::nullopt)
.Then(base::BindLambdaForTesting(
[&run_loop](std::vector<AggregationServiceStorage::RequestAndId>
requests_and_ids) {
@@ -332,7 +332,7 @@
storage_context_.GetStorage()
.AsyncCall(&AggregationServiceStorage::GetRequestsReportingOnOrBefore)
- .WithArgs(base::Time::Max(), /*limit=*/absl::nullopt)
+ .WithArgs(base::Time::Max(), /*limit=*/std::nullopt)
.Then(base::BindLambdaForTesting(
[&run_loop](std::vector<AggregationServiceStorage::RequestAndId>
requests_and_ids) {
@@ -417,7 +417,7 @@
storage_context_.GetStorage()
.AsyncCall(&AggregationServiceStorage::GetRequestsReportingOnOrBefore)
- .WithArgs(base::Time::Max(), /*limit=*/absl::nullopt)
+ .WithArgs(base::Time::Max(), /*limit=*/std::nullopt)
.Then(base::BindLambdaForTesting(
[&run_loop](std::vector<AggregationServiceStorage::RequestAndId>
requests_and_ids) {
diff --git a/content/browser/aggregation_service/aggregatable_report_sender.cc b/content/browser/aggregation_service/aggregatable_report_sender.cc
index 9a5cee2..f616ae3 100644
--- a/content/browser/aggregation_service/aggregatable_report_sender.cc
+++ b/content/browser/aggregation_service/aggregatable_report_sender.cc
@@ -5,6 +5,7 @@
#include "content/browser/aggregation_service/aggregatable_report_sender.h"
#include <memory>
+#include <optional>
#include <string>
#include <utility>
@@ -29,7 +30,6 @@
#include "services/network/public/cpp/resource_request.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
#include "services/network/public/cpp/simple_url_loader.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
#include "url/gurl.h"
namespace content {
@@ -151,7 +151,7 @@
scoped_refptr<net::HttpResponseHeaders> headers) {
RequestStatus status;
- absl::optional<int> http_response_code;
+ std::optional<int> http_response_code;
if (headers)
http_response_code = headers->response_code();
diff --git a/content/browser/aggregation_service/aggregatable_report_unittest.cc b/content/browser/aggregation_service/aggregatable_report_unittest.cc
index 87ee2cb..da513ce 100644
--- a/content/browser/aggregation_service/aggregatable_report_unittest.cc
+++ b/content/browser/aggregation_service/aggregatable_report_unittest.cc
@@ -8,6 +8,7 @@
#include <stdint.h>
#include <limits>
+#include <optional>
#include <string>
#include <utility>
#include <vector>
@@ -28,7 +29,6 @@
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/abseil-cpp/absl/numeric/int128.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
#include "third_party/blink/public/mojom/private_aggregation/aggregatable_report.mojom.h"
#include "third_party/boringssl/src/include/openssl/hpke.h"
#include "url/gurl.h"
@@ -74,11 +74,11 @@
// `expected_payload_contents` is not expected to have its contributions already
// padded.
void VerifyReport(
- const absl::optional<AggregatableReport>& report,
+ const std::optional<AggregatableReport>& report,
const AggregationServicePayloadContents& expected_payload_contents,
const AggregatableReportSharedInfo& expected_shared_info,
size_t expected_num_processing_urls,
- const absl::optional<uint64_t>& expected_debug_key,
+ const std::optional<uint64_t>& expected_debug_key,
const base::flat_map<std::string, std::string>& expected_additional_fields,
const std::vector<aggregation_service::TestHpkeKey>& encryption_keys,
bool should_pad_contributions) {
@@ -123,7 +123,7 @@
EXPECT_FALSE(payloads[i].debug_cleartext_payload.has_value());
}
- absl::optional<cbor::Value> deserialized_payload =
+ std::optional<cbor::Value> deserialized_payload =
cbor::Reader::Read(decrypted_payload);
ASSERT_TRUE(deserialized_payload.has_value());
ASSERT_TRUE(deserialized_payload->is_map());
@@ -234,7 +234,7 @@
hpke_keys.emplace_back("id123");
hpke_keys.emplace_back("456abc");
- absl::optional<AggregatableReport> report =
+ std::optional<AggregatableReport> report =
AggregatableReport::Provider().CreateFromRequestAndPublicKeys(
std::move(request),
{hpke_keys[0].GetPublicKey(), hpke_keys[1].GetPublicKey()});
@@ -242,7 +242,7 @@
ASSERT_NO_FATAL_FAILURE(
VerifyReport(report, expected_payload_contents, expected_shared_info,
expected_num_processing_urls,
- /*expected_debug_key=*/absl::nullopt,
+ /*expected_debug_key=*/std::nullopt,
/*expected_additional_fields=*/{}, std::move(hpke_keys),
/*should_pad_contributions=*/GetParam()));
}
@@ -260,14 +260,14 @@
std::vector<aggregation_service::TestHpkeKey> hpke_keys;
hpke_keys.emplace_back("id123");
- absl::optional<AggregatableReport> report =
+ std::optional<AggregatableReport> report =
AggregatableReport::Provider().CreateFromRequestAndPublicKeys(
std::move(request), {hpke_keys[0].GetPublicKey()});
ASSERT_NO_FATAL_FAILURE(
VerifyReport(report, expected_payload_contents, expected_shared_info,
expected_num_processing_urls,
- /*expected_debug_key=*/absl::nullopt,
+ /*expected_debug_key=*/std::nullopt,
/*expected_additional_fields=*/{}, std::move(hpke_keys),
/*should_pad_contributions=*/GetParam()));
}
@@ -288,7 +288,7 @@
/*bucket=*/7890,
/*value=*/1234)};
- absl::optional<AggregatableReportRequest> request =
+ std::optional<AggregatableReportRequest> request =
AggregatableReportRequest::Create(expected_payload_contents,
example_request.shared_info().Clone());
ASSERT_TRUE(request.has_value());
@@ -300,14 +300,14 @@
std::vector<aggregation_service::TestHpkeKey> hpke_keys;
hpke_keys.emplace_back("id123");
- absl::optional<AggregatableReport> report =
+ std::optional<AggregatableReport> report =
AggregatableReport::Provider().CreateFromRequestAndPublicKeys(
std::move(*request), {hpke_keys[0].GetPublicKey()});
ASSERT_NO_FATAL_FAILURE(
VerifyReport(report, expected_payload_contents, expected_shared_info,
expected_num_processing_urls,
- /*expected_debug_key=*/absl::nullopt,
+ /*expected_debug_key=*/std::nullopt,
/*expected_additional_fields=*/{}, std::move(hpke_keys),
/*should_pad_contributions=*/GetParam()));
}
@@ -332,7 +332,7 @@
/*value=*/0)};
}
- absl::optional<AggregatableReportRequest> request =
+ std::optional<AggregatableReportRequest> request =
AggregatableReportRequest::Create(payload_contents,
example_request.shared_info().Clone());
ASSERT_TRUE(request.has_value());
@@ -344,14 +344,14 @@
std::vector<aggregation_service::TestHpkeKey> hpke_keys;
hpke_keys.emplace_back("id123");
- absl::optional<AggregatableReport> report =
+ std::optional<AggregatableReport> report =
AggregatableReport::Provider().CreateFromRequestAndPublicKeys(
std::move(*request), {hpke_keys[0].GetPublicKey()});
ASSERT_NO_FATAL_FAILURE(
VerifyReport(report, expected_payload_contents, expected_shared_info,
expected_num_processing_urls,
- /*expected_debug_key=*/absl::nullopt,
+ /*expected_debug_key=*/std::nullopt,
/*expected_additional_fields=*/{}, std::move(hpke_keys),
/*should_pad_contributions=*/GetParam()));
}
@@ -364,7 +364,7 @@
example_request.shared_info().Clone();
expected_shared_info.debug_mode =
AggregatableReportSharedInfo::DebugMode::kEnabled;
- absl::optional<AggregatableReportRequest> request =
+ std::optional<AggregatableReportRequest> request =
AggregatableReportRequest::Create(example_request.payload_contents(),
expected_shared_info.Clone());
ASSERT_TRUE(request.has_value());
@@ -376,14 +376,14 @@
std::vector<aggregation_service::TestHpkeKey> hpke_keys;
hpke_keys.emplace_back("id123");
- absl::optional<AggregatableReport> report =
+ std::optional<AggregatableReport> report =
AggregatableReport::Provider().CreateFromRequestAndPublicKeys(
std::move(request.value()), {hpke_keys[0].GetPublicKey()});
ASSERT_NO_FATAL_FAILURE(
VerifyReport(report, expected_payload_contents, expected_shared_info,
expected_num_processing_urls,
- /*expected_debug_key=*/absl::nullopt,
+ /*expected_debug_key=*/std::nullopt,
/*expected_additional_fields=*/{}, std::move(hpke_keys),
/*should_pad_contributions=*/GetParam()));
}
@@ -399,7 +399,7 @@
// Use a large value to check that higher order bits are serialized too.
uint64_t expected_debug_key = std::numeric_limits<uint64_t>::max() - 1;
- absl::optional<AggregatableReportRequest> request =
+ std::optional<AggregatableReportRequest> request =
AggregatableReportRequest::Create(
example_request.payload_contents(), expected_shared_info.Clone(),
/*reporting_path=*/std::string(), expected_debug_key);
@@ -412,7 +412,7 @@
std::vector<aggregation_service::TestHpkeKey> hpke_keys;
hpke_keys.emplace_back("id123");
- absl::optional<AggregatableReport> report =
+ std::optional<AggregatableReport> report =
AggregatableReport::Provider().CreateFromRequestAndPublicKeys(
std::move(request.value()), {hpke_keys[0].GetPublicKey()});
@@ -429,11 +429,11 @@
base::flat_map<std::string, std::string> expected_additional_fields = {
{"additional_key", "example_value"}, {"second", "field"}, {"", ""}};
- absl::optional<AggregatableReportRequest> request =
+ std::optional<AggregatableReportRequest> request =
AggregatableReportRequest::Create(example_request.payload_contents(),
example_request.shared_info().Clone(),
/*reporting_path=*/std::string(),
- /*debug_key=*/absl::nullopt,
+ /*debug_key=*/std::nullopt,
expected_additional_fields);
ASSERT_TRUE(request.has_value());
@@ -444,13 +444,13 @@
std::vector<aggregation_service::TestHpkeKey> hpke_keys;
hpke_keys.emplace_back("id123");
- absl::optional<AggregatableReport> report =
+ std::optional<AggregatableReport> report =
AggregatableReport::Provider().CreateFromRequestAndPublicKeys(
std::move(request.value()), {hpke_keys[0].GetPublicKey()});
ASSERT_NO_FATAL_FAILURE(VerifyReport(
report, expected_payload_contents, example_request.shared_info(),
- expected_num_processing_urls, /*expected_debug_key=*/absl::nullopt,
+ expected_num_processing_urls, /*expected_debug_key=*/std::nullopt,
expected_additional_fields, std::move(hpke_keys),
/*should_pad_contributions=*/GetParam()));
}
@@ -467,7 +467,7 @@
AggregationServicePayloadContents zero_value_payload_contents =
payload_contents;
zero_value_payload_contents.contributions[0].value = 0;
- absl::optional<AggregatableReportRequest> zero_value_request =
+ std::optional<AggregatableReportRequest> zero_value_request =
AggregatableReportRequest::Create(zero_value_payload_contents,
shared_info.Clone());
EXPECT_TRUE(zero_value_request.has_value());
@@ -475,7 +475,7 @@
AggregationServicePayloadContents negative_value_payload_contents =
payload_contents;
negative_value_payload_contents.contributions[0].value = -1;
- absl::optional<AggregatableReportRequest> negative_value_request =
+ std::optional<AggregatableReportRequest> negative_value_request =
AggregatableReportRequest::Create(negative_value_payload_contents,
shared_info.Clone());
EXPECT_FALSE(negative_value_request.has_value());
@@ -488,7 +488,7 @@
example_request.shared_info().Clone();
shared_info.report_id = base::Uuid();
- absl::optional<AggregatableReportRequest> request =
+ std::optional<AggregatableReportRequest> request =
AggregatableReportRequest::Create(example_request.payload_contents(),
std::move(shared_info));
@@ -504,7 +504,7 @@
example_request.payload_contents();
payload_contents.contributions.clear();
- absl::optional<AggregatableReportRequest> request =
+ std::optional<AggregatableReportRequest> request =
AggregatableReportRequest::Create(payload_contents,
example_request.shared_info().Clone());
EXPECT_TRUE(request.has_value());
@@ -520,7 +520,7 @@
example_request.payload_contents();
payload_contents.contributions.clear();
- absl::optional<AggregatableReportRequest> request =
+ std::optional<AggregatableReportRequest> request =
AggregatableReportRequest::Create(payload_contents,
example_request.shared_info().Clone());
EXPECT_FALSE(request.has_value());
@@ -541,7 +541,7 @@
/*bucket=*/7890,
/*value=*/1234)};
- absl::optional<AggregatableReportRequest> request =
+ std::optional<AggregatableReportRequest> request =
AggregatableReportRequest::Create(payload_contents,
example_request.shared_info().Clone());
ASSERT_FALSE(request.has_value());
@@ -552,7 +552,7 @@
AggregatableReportRequest example_request =
aggregation_service::CreateExampleRequest();
- absl::optional<AggregatableReportRequest> request =
+ std::optional<AggregatableReportRequest> request =
AggregatableReportRequest::Create(example_request.payload_contents(),
example_request.shared_info().Clone(),
/*reporting_path=*/std::string(),
@@ -565,12 +565,12 @@
std::vector<AggregatableReport::AggregationServicePayload> payloads;
payloads.emplace_back(/*payload=*/kABCD1234AsBytes,
/*key_id=*/"key_1",
- /*debug_cleartext_payload=*/absl::nullopt);
+ /*debug_cleartext_payload=*/std::nullopt);
AggregatableReport report(std::move(payloads), "example_shared_info",
- /*debug_key=*/absl::nullopt,
+ /*debug_key=*/std::nullopt,
/*additional_fields=*/{},
- /*aggregation_coordinator_origin=*/absl::nullopt);
+ /*aggregation_coordinator_origin=*/std::nullopt);
std::string report_json_string;
base::JSONWriter::Write(base::Value(report.GetAsJson()), &report_json_string);
@@ -590,15 +590,15 @@
std::vector<AggregatableReport::AggregationServicePayload> payloads;
payloads.emplace_back(/*payload=*/kABCD1234AsBytes,
/*key_id=*/"key_1",
- /*debug_cleartext_payload=*/absl::nullopt);
+ /*debug_cleartext_payload=*/std::nullopt);
payloads.emplace_back(/*payload=*/kEFGH5678AsBytes,
/*key_id=*/"key_2",
- /*debug_cleartext_payload=*/absl::nullopt);
+ /*debug_cleartext_payload=*/std::nullopt);
AggregatableReport report(std::move(payloads), "example_shared_info",
- /*debug_key=*/absl::nullopt,
+ /*debug_key=*/std::nullopt,
/*additional_fields=*/{},
- /*aggregation_coordinator_origin=*/absl::nullopt);
+ /*aggregation_coordinator_origin=*/std::nullopt);
std::string report_json_string;
base::JSONWriter::Write(base::Value(report.GetAsJson()), &report_json_string);
@@ -623,9 +623,9 @@
/*debug_cleartext_payload=*/kEFGH5678AsBytes);
AggregatableReport report(std::move(payloads), "example_shared_info",
- /*debug_key=*/absl::nullopt,
+ /*debug_key=*/std::nullopt,
/*additional_fields=*/{},
- /*aggregation_coordinator_origin=*/absl::nullopt);
+ /*aggregation_coordinator_origin=*/std::nullopt);
std::string report_json_string;
base::JSONWriter::Write(base::Value(report.GetAsJson()), &report_json_string);
@@ -651,7 +651,7 @@
AggregatableReport report(std::move(payloads), "example_shared_info",
/*debug_key=*/1234, /*additional_fields=*/{},
- /*aggregation_coordinator_origin=*/absl::nullopt);
+ /*aggregation_coordinator_origin=*/std::nullopt);
std::string report_json_string;
base::JSONWriter::Write(base::Value(report.GetAsJson()), &report_json_string);
@@ -674,13 +674,13 @@
std::vector<AggregatableReport::AggregationServicePayload> payloads;
payloads.emplace_back(/*payload=*/kABCD1234AsBytes,
/*key_id=*/"key_1",
- /*debug_cleartext_payload=*/absl::nullopt);
+ /*debug_cleartext_payload=*/std::nullopt);
AggregatableReport report(
std::move(payloads), "example_shared_info",
- /*debug_key=*/absl::nullopt, /*additional_fields=*/
+ /*debug_key=*/std::nullopt, /*additional_fields=*/
{{"additional_key", "example_value"}, {"second", "field"}, {"", ""}},
- /*aggregation_coordinator_origin=*/absl::nullopt);
+ /*aggregation_coordinator_origin=*/std::nullopt);
std::string report_json_string;
base::JSONWriter::Write(base::Value(report.GetAsJson()), &report_json_string);
@@ -785,7 +785,7 @@
std::string reporting_path = "/example-path";
- absl::optional<AggregatableReportRequest> request =
+ std::optional<AggregatableReportRequest> request =
AggregatableReportRequest::Create(example_request.payload_contents(),
example_request.shared_info().Clone(),
reporting_path);
@@ -802,10 +802,10 @@
AggregatableReportSharedInfo shared_info =
example_request.shared_info().Clone();
- absl::optional<AggregatableReportRequest> request =
+ std::optional<AggregatableReportRequest> request =
AggregatableReportRequest::Create(
example_request.payload_contents(), std::move(shared_info),
- /*reporting_path=*/"", /*debug_key=*/absl::nullopt,
+ /*reporting_path=*/"", /*debug_key=*/std::nullopt,
/*additional_fields=*/{},
/*failed_send_attempts=*/-1);
@@ -822,7 +822,7 @@
payload_contents.max_contributions_allowed = -1;
- absl::optional<AggregatableReportRequest> negative_request =
+ std::optional<AggregatableReportRequest> negative_request =
AggregatableReportRequest::Create(payload_contents,
example_request.shared_info().Clone());
EXPECT_FALSE(negative_request.has_value());
@@ -831,7 +831,7 @@
/*value=*/78);
payload_contents.max_contributions_allowed = 1;
- absl::optional<AggregatableReportRequest> too_small_max_request =
+ std::optional<AggregatableReportRequest> too_small_max_request =
AggregatableReportRequest::Create(payload_contents,
example_request.shared_info().Clone());
EXPECT_FALSE(too_small_max_request.has_value());
@@ -839,7 +839,7 @@
payload_contents.contributions = {};
payload_contents.max_contributions_allowed = 0;
- absl::optional<AggregatableReportRequest> empty_zero_request =
+ std::optional<AggregatableReportRequest> empty_zero_request =
AggregatableReportRequest::Create(payload_contents,
example_request.shared_info().Clone());
EXPECT_TRUE(empty_zero_request.has_value());
@@ -859,7 +859,7 @@
// The failed attempts are correctly serialized & deserialized
std::vector<uint8_t> proto = example_request_with_failed_attempts.Serialize();
- absl::optional<AggregatableReportRequest> parsed_request =
+ std::optional<AggregatableReportRequest> parsed_request =
AggregatableReportRequest::Deserialize(proto);
EXPECT_EQ(parsed_request.value().failed_send_attempts(), 2);
}
@@ -879,7 +879,7 @@
// The max contributions allowed is correctly serialized and deserialized
std::vector<uint8_t> proto = request.Serialize();
- absl::optional<AggregatableReportRequest> parsed_request =
+ std::optional<AggregatableReportRequest> parsed_request =
AggregatableReportRequest::Deserialize(proto);
EXPECT_EQ(parsed_request.value().payload_contents().max_contributions_allowed,
20);
@@ -887,11 +887,11 @@
TEST_P(AggregatableReportTest, AggregationCoordinatorOrigin) {
const struct {
- absl::optional<url::Origin> aggregation_coordinator_origin;
+ std::optional<url::Origin> aggregation_coordinator_origin;
bool creation_should_succeed;
const char* description;
} kTestCases[] = {
- {absl::nullopt, true, "default coordinator"},
+ {std::nullopt, true, "default coordinator"},
{url::Origin::Create(GURL("https://aws.example.test")), true,
"valid coordinator"},
{url::Origin::Create(GURL("https://a.test")), false,
@@ -908,7 +908,7 @@
payload_contents.aggregation_coordinator_origin =
test_case.aggregation_coordinator_origin;
- absl::optional<AggregatableReportRequest> request =
+ std::optional<AggregatableReportRequest> request =
AggregatableReportRequest::Create(
payload_contents, example_request.shared_info().Clone());
@@ -920,7 +920,7 @@
// The coordinator origin is correctly serialized and deserialized
std::vector<uint8_t> proto = request->Serialize();
- absl::optional<AggregatableReportRequest> parsed_request =
+ std::optional<AggregatableReportRequest> parsed_request =
AggregatableReportRequest::Deserialize(proto);
EXPECT_EQ(parsed_request.value()
.payload_contents()
@@ -959,7 +959,7 @@
{"gcp_cloud", "https://gcp2.example.test"}});
// Expect the report to fail to be recreated.
- absl::optional<AggregatableReportRequest> parsed_request =
+ std::optional<AggregatableReportRequest> parsed_request =
AggregatableReportRequest::Deserialize(proto);
EXPECT_FALSE(parsed_request.has_value());
}
@@ -969,7 +969,7 @@
aggregation_service::CreateExampleRequest(
blink::mojom::AggregationServiceMode::kExperimentalPoplar);
- absl::optional<AggregatableReportRequest> request =
+ std::optional<AggregatableReportRequest> request =
AggregatableReportRequest::Create(example_request.payload_contents(),
example_request.shared_info().Clone());
ASSERT_TRUE(request.has_value());
@@ -981,9 +981,9 @@
TEST_P(AggregatableReportTest, EmptyPayloads) {
AggregatableReport report(/*payloads=*/{}, "example_shared_info",
- /*debug_key=*/absl::nullopt,
+ /*debug_key=*/std::nullopt,
/*additional_fields=*/{},
- /*aggregation_coordinator_origin=*/absl::nullopt);
+ /*aggregation_coordinator_origin=*/std::nullopt);
std::string report_json_string;
base::JSONWriter::Write(base::Value(report.GetAsJson()), &report_json_string);
@@ -1009,7 +1009,7 @@
std::vector<uint8_t> old_proto;
EXPECT_TRUE(base::HexStringToBytes(kHexEncodedOldProto, &old_proto));
- absl::optional<AggregatableReportRequest> deserialized_request =
+ std::optional<AggregatableReportRequest> deserialized_request =
AggregatableReportRequest::Deserialize(old_proto);
ASSERT_TRUE(deserialized_request.has_value());
@@ -1020,7 +1020,7 @@
{blink::mojom::AggregatableReportHistogramContribution(
/*bucket=*/123, /*value=*/456)},
blink::mojom::AggregationServiceMode::kDefault,
- /*aggregation_coordinator_origin=*/absl::nullopt,
+ /*aggregation_coordinator_origin=*/std::nullopt,
/*max_contributions_allowed=*/1),
AggregatableReportSharedInfo(
base::Time::FromMillisecondsSinceUnixEpoch(1652984901234),
@@ -1032,7 +1032,7 @@
/*additional_fields=*/base::Value::Dict(),
/*api_version=*/"example-version",
/*api_identifier=*/"example-api"),
- /*reporting_path=*/"example-path", /*debug_key=*/absl::nullopt,
+ /*reporting_path=*/"example-path", /*debug_key=*/std::nullopt,
/*additional_fields=*/{},
/*failed_send_attempts=*/0)
.value();
@@ -1054,7 +1054,7 @@
std::vector<uint8_t> old_proto;
EXPECT_TRUE(base::HexStringToBytes(kHexEncodedOldProto, &old_proto));
- absl::optional<AggregatableReportRequest> deserialized_request =
+ std::optional<AggregatableReportRequest> deserialized_request =
AggregatableReportRequest::Deserialize(old_proto);
ASSERT_TRUE(deserialized_request.has_value());
@@ -1065,7 +1065,7 @@
{blink::mojom::AggregatableReportHistogramContribution(
/*bucket=*/123, /*value=*/456)},
blink::mojom::AggregationServiceMode::kDefault,
- /*aggregation_coordinator_origin=*/absl::nullopt,
+ /*aggregation_coordinator_origin=*/std::nullopt,
/*max_contributions_allowed=*/1),
AggregatableReportSharedInfo(
base::Time::FromMillisecondsSinceUnixEpoch(1652984901234),
@@ -1098,7 +1098,7 @@
std::vector<uint8_t> old_proto;
EXPECT_TRUE(base::HexStringToBytes(kHexEncodedOldProto, &old_proto));
- absl::optional<AggregatableReportRequest> deserialized_request =
+ std::optional<AggregatableReportRequest> deserialized_request =
AggregatableReportRequest::Deserialize(old_proto);
ASSERT_TRUE(deserialized_request.has_value());
@@ -1109,7 +1109,7 @@
{blink::mojom::AggregatableReportHistogramContribution(
/*bucket=*/123, /*value=*/456)},
blink::mojom::AggregationServiceMode::kDefault,
- /*aggregation_coordinator_origin=*/absl::nullopt,
+ /*aggregation_coordinator_origin=*/std::nullopt,
/*max_contributions_allowed=*/1),
AggregatableReportSharedInfo(
base::Time::FromMillisecondsSinceUnixEpoch(1652984901234),
@@ -1121,7 +1121,7 @@
/*additional_fields=*/base::Value::Dict(),
/*api_version=*/"example-version",
/*api_identifier=*/"example-api"),
- /*reporting_path=*/"example-path", /*debug_key=*/absl::nullopt,
+ /*reporting_path=*/"example-path", /*debug_key=*/std::nullopt,
/*additional_fields=*/{},
/*failed_send_attempts=*/0)
.value();
@@ -1143,11 +1143,11 @@
TEST_P(AggregatableReportTest, AggregationCoordinator_ProcessingUrlSet) {
const struct {
- absl::optional<url::Origin> aggregation_coordinator_origin;
+ std::optional<url::Origin> aggregation_coordinator_origin;
std::vector<GURL> expected_urls;
} kTestCases[] = {
{
- absl::nullopt,
+ std::nullopt,
{GURL("https://aws.example.test/.well-known/aggregation-service/v1/"
"public-keys")},
},
@@ -1168,7 +1168,7 @@
};
for (const auto& test_case : kTestCases) {
- absl::optional<AggregatableReportRequest> request =
+ std::optional<AggregatableReportRequest> request =
AggregatableReportRequest::Create(
AggregationServicePayloadContents(
AggregationServicePayloadContents::Operation::kHistogram,
@@ -1188,7 +1188,7 @@
/*api_version=*/"",
/*api_identifier=*/"example-api"),
/*reporting_path=*/"example-path",
- /*debug_key=*/absl::nullopt, /*additional_fields=*/{},
+ /*debug_key=*/std::nullopt, /*additional_fields=*/{},
/*failed_send_attempts=*/0);
if (test_case.expected_urls.empty()) {
@@ -1208,12 +1208,12 @@
std::vector<AggregatableReport::AggregationServicePayload> payloads;
payloads.emplace_back(/*payload=*/kABCD1234AsBytes,
/*key_id=*/"key_1",
- /*debug_cleartext_payload=*/absl::nullopt);
+ /*debug_cleartext_payload=*/std::nullopt);
AggregatableReport report(std::move(payloads), "example_shared_info",
- /*debug_key=*/absl::nullopt,
+ /*debug_key=*/std::nullopt,
/*additional_fields=*/{},
- /*aggregation_coordinator_origin=*/absl::nullopt);
+ /*aggregation_coordinator_origin=*/std::nullopt);
std::string report_json_string;
base::JSONWriter::Write(base::Value(report.GetAsJson()), &report_json_string);
diff --git a/content/browser/aggregation_service/aggregation_service.h b/content/browser/aggregation_service/aggregation_service.h
index 3d8edde81..53a713a33 100644
--- a/content/browser/aggregation_service/aggregation_service.h
+++ b/content/browser/aggregation_service/aggregation_service.h
@@ -56,7 +56,7 @@
// Constructs an AggregatableReport from the information in `report_request`.
// `callback` will be run once completed which returns the assembled report
- // if successful, otherwise `absl::nullopt` will be returned.
+ // if successful, otherwise `std::nullopt` will be returned.
virtual void AssembleReport(AggregatableReportRequest report_request,
AssemblyCallback callback) = 0;
diff --git a/content/browser/aggregation_service/aggregation_service_impl.cc b/content/browser/aggregation_service/aggregation_service_impl.cc
index cedbff0..32c71fc 100644
--- a/content/browser/aggregation_service/aggregation_service_impl.cc
+++ b/content/browser/aggregation_service/aggregation_service_impl.cc
@@ -7,6 +7,7 @@
#include <stdint.h>
#include <memory>
+#include <optional>
#include <set>
#include <utility>
#include <vector>
@@ -38,7 +39,6 @@
#include "content/browser/aggregation_service/public_key.h"
#include "content/browser/storage_partition_impl.h"
#include "content/public/browser/storage_partition.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
#include "url/gurl.h"
#include "url/origin.h"
@@ -184,13 +184,14 @@
void AggregationServiceImpl::AssembleAndSendReport(
AggregatableReportRequest report_request) {
- AssembleAndSendReportImpl(std::move(report_request), /*id=*/absl::nullopt,
+ AssembleAndSendReportImpl(std::move(report_request),
+ /*request_id=*/std::nullopt,
/*done=*/base::DoNothing());
}
void AggregationServiceImpl::AssembleAndSendReportImpl(
AggregatableReportRequest report_request,
- absl::optional<AggregationServiceStorage::RequestId> request_id,
+ std::optional<AggregationServiceStorage::RequestId> request_id,
base::OnceClosure done) {
GURL reporting_url = report_request.GetReportingUrl();
AssembleReport(
@@ -210,10 +211,10 @@
void AggregationServiceImpl::OnReportAssemblyComplete(
base::OnceClosure done,
- absl::optional<AggregationServiceStorage::RequestId> request_id,
+ std::optional<AggregationServiceStorage::RequestId> request_id,
GURL reporting_url,
AggregatableReportRequest report_request,
- absl::optional<AggregatableReport> report,
+ std::optional<AggregatableReport> report,
AggregatableReportAssembler::AssemblyStatus status) {
DCHECK_EQ(report.has_value(),
status == AggregatableReportAssembler::AssemblyStatus::kOk);
@@ -227,7 +228,7 @@
if (!will_retry) {
NotifyReportHandled(
std::move(report_request), request_id,
- /*report=*/absl::nullopt,
+ /*report=*/std::nullopt,
AggregationServiceObserver::ReportStatus::kFailedToAssemble);
}
if (request_id.has_value()) {
@@ -252,7 +253,7 @@
void AggregationServiceImpl::OnReportSendingComplete(
base::OnceClosure done,
AggregatableReportRequest report_request,
- absl::optional<AggregationServiceStorage::RequestId> request_id,
+ std::optional<AggregationServiceStorage::RequestId> request_id,
AggregatableReport report,
AggregatableReportSender::RequestStatus status) {
std::move(done).Run();
@@ -354,8 +355,8 @@
void AggregationServiceImpl::NotifyReportHandled(
const AggregatableReportRequest& request,
- absl::optional<AggregationServiceStorage::RequestId> request_id,
- const absl::optional<AggregatableReport>& report,
+ std::optional<AggregationServiceStorage::RequestId> request_id,
+ const std::optional<AggregatableReport>& report,
AggregationServiceObserver::ReportStatus status) {
bool is_scheduled_request = request_id.has_value();
bool did_request_succeed =
diff --git a/content/browser/aggregation_service/aggregation_service_impl.h b/content/browser/aggregation_service/aggregation_service_impl.h
index 10cc9d0f..8a488d18 100644
--- a/content/browser/aggregation_service/aggregation_service_impl.h
+++ b/content/browser/aggregation_service/aggregation_service_impl.h
@@ -8,6 +8,7 @@
#include <stdint.h>
#include <memory>
+#include <optional>
#include <set>
#include <vector>
@@ -26,7 +27,6 @@
#include "content/browser/aggregation_service/aggregation_service_storage_context.h"
#include "content/common/content_export.h"
#include "content/public/browser/storage_partition.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
class GURL;
@@ -125,23 +125,23 @@
std::vector<AggregationServiceStorage::RequestAndId> requests_and_ids,
base::RepeatingClosure done);
- // `request_id` is `absl::nullopt` iff `report_request` was not
+ // `request_id` is `std::nullopt` iff `report_request` was not
// stored/scheduled.
void AssembleAndSendReportImpl(
AggregatableReportRequest report_request,
- absl::optional<AggregationServiceStorage::RequestId> request_id,
+ std::optional<AggregationServiceStorage::RequestId> request_id,
base::OnceClosure done);
void OnReportAssemblyComplete(
base::OnceClosure done,
- absl::optional<AggregationServiceStorage::RequestId> request_id,
+ std::optional<AggregationServiceStorage::RequestId> request_id,
GURL reporting_url,
AggregatableReportRequest report_request,
- absl::optional<AggregatableReport> report,
+ std::optional<AggregatableReport> report,
AggregatableReportAssembler::AssemblyStatus status);
void OnReportSendingComplete(
base::OnceClosure done,
AggregatableReportRequest report_request,
- absl::optional<AggregationServiceStorage::RequestId> request_id,
+ std::optional<AggregationServiceStorage::RequestId> request_id,
AggregatableReport report,
AggregatableReportSender::RequestStatus status);
void OnUserVisibleTaskStarted();
@@ -154,8 +154,8 @@
void NotifyReportHandled(
const AggregatableReportRequest& request,
- absl::optional<AggregationServiceStorage::RequestId> request_id,
- const absl::optional<AggregatableReport>& report,
+ std::optional<AggregationServiceStorage::RequestId> request_id,
+ const std::optional<AggregatableReport>& report,
AggregationServiceObserver::ReportStatus status);
void NotifyRequestStorageModified();
diff --git a/content/browser/aggregation_service/aggregation_service_impl_unittest.cc b/content/browser/aggregation_service/aggregation_service_impl_unittest.cc
index 1d099732..950ad23 100644
--- a/content/browser/aggregation_service/aggregation_service_impl_unittest.cc
+++ b/content/browser/aggregation_service/aggregation_service_impl_unittest.cc
@@ -5,6 +5,7 @@
#include "content/browser/aggregation_service/aggregation_service_impl.h"
#include <memory>
+#include <optional>
#include <utility>
#include <vector>
@@ -31,7 +32,6 @@
#include "services/network/test/test_url_loader_factory.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
#include "url/gurl.h"
namespace content {
@@ -46,7 +46,7 @@
using ::testing::SizeIs;
using ::testing::StrictMock;
-auto InvokeCallback(absl::optional<AggregatableReport> report,
+auto InvokeCallback(std::optional<AggregatableReport> report,
AggregationService::AssemblyStatus status) {
return [report = std::move(report), status = status](
AggregatableReportRequest report_request,
@@ -60,11 +60,11 @@
std::vector<AggregatableReport::AggregationServicePayload> payloads;
payloads.emplace_back(/*payload=*/kABCD1234AsBytes,
/*key_id=*/"key_1",
- /*debug_cleartext_payload=*/absl::nullopt);
+ /*debug_cleartext_payload=*/std::nullopt);
return AggregatableReport(std::move(payloads), "example_shared_info",
- /*debug_key=*/absl::nullopt,
+ /*debug_key=*/std::nullopt,
/*additional_fields=*/{},
- /*aggregation_coordinator_origin=*/absl::nullopt);
+ /*aggregation_coordinator_origin=*/std::nullopt);
}
} // namespace
@@ -133,8 +133,8 @@
MOCK_METHOD(void,
OnReportHandled,
(const AggregatableReportRequest& request,
- absl::optional<AggregationServiceStorage::RequestId> id,
- const absl::optional<AggregatableReport>& report,
+ std::optional<AggregationServiceStorage::RequestId> id,
+ const std::optional<AggregatableReport>& report,
base::Time report_handle_time,
ReportStatus status),
(override));
@@ -236,7 +236,7 @@
aggregation_service::CreateExampleRequest(),
base::BindLambdaForTesting(
[&](AggregatableReportRequest request,
- absl::optional<AggregatableReport> report,
+ std::optional<AggregatableReport> report,
AggregationService::AssemblyStatus status) {
EXPECT_TRUE(report.has_value());
EXPECT_EQ(status, AggregationService::AssemblyStatus::kOk);
@@ -251,7 +251,7 @@
TEST_F(AggregationServiceImplTest, AssembleReport_Fail) {
EXPECT_CALL(*test_assembler_, AssembleReport)
.WillOnce(InvokeCallback(
- /*report=*/absl::nullopt,
+ /*report=*/std::nullopt,
AggregatableReportAssembler::AssemblyStatus::kPublicKeyFetchFailed));
base::RunLoop run_loop;
@@ -259,7 +259,7 @@
aggregation_service::CreateExampleRequest(),
base::BindLambdaForTesting(
[&](AggregatableReportRequest request,
- absl::optional<AggregatableReport> report,
+ std::optional<AggregatableReport> report,
AggregationService::AssemblyStatus status) {
EXPECT_FALSE(report.has_value());
EXPECT_EQ(
@@ -349,7 +349,7 @@
EXPECT_CALL(*test_assembler_, AssembleReport)
.WillOnce(InvokeCallback(
- /*report=*/absl::nullopt,
+ /*report=*/std::nullopt,
AggregatableReportAssembler::AssemblyStatus::kAssemblyFailed));
EXPECT_CALL(*test_scheduler_,
NotifyInProgressRequestFailed(
@@ -494,7 +494,7 @@
observation.Observe(service_impl_.get());
EXPECT_CALL(observer,
- OnReportHandled(_, Eq(absl::nullopt), _, _,
+ OnReportHandled(_, Eq(std::nullopt), _, _,
AggregationServiceObserver::ReportStatus::kSent));
// The scheduler should not have been interacted with.
@@ -511,7 +511,7 @@
TEST_F(AggregationServiceImplTest, AssembleAndSendReport_FailedAssembly) {
EXPECT_CALL(*test_assembler_, AssembleReport)
.WillOnce(InvokeCallback(
- /*report=*/absl::nullopt,
+ /*report=*/std::nullopt,
AggregatableReportAssembler::AssemblyStatus::kAssemblyFailed));
StrictMock<MockAggregationServiceObserver> observer;
@@ -521,7 +521,7 @@
EXPECT_CALL(observer,
OnReportHandled(
- _, Eq(absl::nullopt), _, _,
+ _, Eq(std::nullopt), _, _,
AggregationServiceObserver::ReportStatus::kFailedToAssemble));
// The scheduler should not have been interacted with.
@@ -552,7 +552,7 @@
EXPECT_CALL(
observer,
- OnReportHandled(_, Eq(absl::nullopt), _, _,
+ OnReportHandled(_, Eq(std::nullopt), _, _,
AggregationServiceObserver::ReportStatus::kFailedToSend));
// The scheduler should not have been interacted with.
diff --git a/content/browser/aggregation_service/aggregation_service_key_fetcher.cc b/content/browser/aggregation_service/aggregation_service_key_fetcher.cc
index e2e33ac..bf31a8d9 100644
--- a/content/browser/aggregation_service/aggregation_service_key_fetcher.cc
+++ b/content/browser/aggregation_service/aggregation_service_key_fetcher.cc
@@ -5,6 +5,7 @@
#include "content/browser/aggregation_service/aggregation_service_key_fetcher.h"
#include <memory>
+#include <optional>
#include <utility>
#include <vector>
@@ -15,7 +16,6 @@
#include "content/browser/aggregation_service/aggregation_service_storage.h"
#include "content/browser/aggregation_service/aggregation_service_storage_context.h"
#include "services/network/public/cpp/is_potentially_trustworthy.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
#include "url/gurl.h"
namespace content {
@@ -80,9 +80,9 @@
void AggregationServiceKeyFetcher::OnPublicKeysReceivedFromNetwork(
const GURL& url,
- absl::optional<PublicKeyset> keyset) {
+ std::optional<PublicKeyset> keyset) {
if (!keyset.has_value() || keyset->expiry_time.is_null()) {
- // `keyset` will be absl::nullopt if an error occurred and `expiry_time`
+ // `keyset` will be std::nullopt if an error occurred and `expiry_time`
// will be null if the freshness lifetime was zero. In these cases, we will
// still update the keys for `url`, i,e. clear them.
storage_context_->GetStorage()
@@ -115,7 +115,7 @@
if (keys.empty()) {
// Return error, don't refetch to avoid infinite loop.
for (auto& callback : pending_callbacks) {
- std::move(callback).Run(absl::nullopt,
+ std::move(callback).Run(std::nullopt,
PublicKeyFetchStatus::kPublicKeyFetchFailed);
}
} else {
diff --git a/content/browser/aggregation_service/aggregation_service_key_fetcher.h b/content/browser/aggregation_service/aggregation_service_key_fetcher.h
index 803e0ed..1950f961 100644
--- a/content/browser/aggregation_service/aggregation_service_key_fetcher.h
+++ b/content/browser/aggregation_service/aggregation_service_key_fetcher.h
@@ -6,6 +6,7 @@
#define CONTENT_BROWSER_AGGREGATION_SERVICE_AGGREGATION_SERVICE_KEY_FETCHER_H_
#include <memory>
+#include <optional>
#include <vector>
#include "base/containers/circular_deque.h"
@@ -15,7 +16,6 @@
#include "base/memory/weak_ptr.h"
#include "content/browser/aggregation_service/public_key.h"
#include "content/common/content_export.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
class GURL;
@@ -34,10 +34,10 @@
virtual ~NetworkFetcher() = default;
using NetworkFetchCallback =
- base::OnceCallback<void(absl::optional<PublicKeyset>)>;
+ base::OnceCallback<void(std::optional<PublicKeyset>)>;
// Fetch public keys from the helper server endpoint `url`. Returns
- // absl::nullopt in case of network or parsing error.
+ // std::nullopt in case of network or parsing error.
virtual void FetchPublicKeys(const GURL& url,
NetworkFetchCallback callback) = 0;
};
@@ -50,7 +50,7 @@
};
using FetchCallback =
- base::OnceCallback<void(absl::optional<PublicKey>, PublicKeyFetchStatus)>;
+ base::OnceCallback<void(std::optional<PublicKey>, PublicKeyFetchStatus)>;
AggregationServiceKeyFetcher(
AggregationServiceStorageContext* storage_context,
@@ -87,7 +87,7 @@
// Called when public keys are received from the network fetcher.
void OnPublicKeysReceivedFromNetwork(const GURL& url,
- absl::optional<PublicKeyset> keyset);
+ std::optional<PublicKeyset> keyset);
// Runs callbacks for pending requests for `url` with the public keys
// received from the network or storage. Any keys specified must be currently
diff --git a/content/browser/aggregation_service/aggregation_service_key_fetcher_unittest.cc b/content/browser/aggregation_service/aggregation_service_key_fetcher_unittest.cc
index 607e20e..556a643 100644
--- a/content/browser/aggregation_service/aggregation_service_key_fetcher_unittest.cc
+++ b/content/browser/aggregation_service/aggregation_service_key_fetcher_unittest.cc
@@ -5,6 +5,7 @@
#include "content/browser/aggregation_service/aggregation_service_key_fetcher.h"
#include <memory>
+#include <optional>
#include <tuple>
#include <utility>
#include <vector>
@@ -22,7 +23,6 @@
#include "content/browser/aggregation_service/public_key.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
#include "url/gurl.h"
namespace content {
@@ -108,7 +108,7 @@
base::RunLoop run_loop;
EXPECT_CALL(callback_,
- Run(absl::optional<PublicKey>(std::move(expected_key)),
+ Run(std::optional<PublicKey>(std::move(expected_key)),
AggregationServiceKeyFetcher::PublicKeyFetchStatus::kOk))
.WillOnce(base::test::RunOnceClosure(run_loop.QuitClosure()));
fetcher_->GetPublicKey(url, callback_.Get());
@@ -122,8 +122,8 @@
EXPECT_CALL(*network_fetcher_, FetchPublicKeys(url, _))
.WillOnce(
testing::DoAll(base::test::RunOnceClosure(run_loop.QuitClosure()),
- base::test::RunOnceCallback<1>(absl::nullopt)));
- EXPECT_CALL(callback_, Run(absl::optional<PublicKey>(absl::nullopt),
+ base::test::RunOnceCallback<1>(std::nullopt)));
+ EXPECT_CALL(callback_, Run(std::optional<PublicKey>(std::nullopt),
AggregationServiceKeyFetcher::
PublicKeyFetchStatus::kPublicKeyFetchFailed));
@@ -143,7 +143,7 @@
/*keys=*/{expected_key}, /*fetch_time=*/clock().Now(),
/*expiry_time=*/base::Time::Max()))));
EXPECT_CALL(callback_,
- Run(absl::optional<PublicKey>(expected_key),
+ Run(std::optional<PublicKey>(expected_key),
AggregationServiceKeyFetcher::PublicKeyFetchStatus::kOk));
fetcher_->GetPublicKey(url, callback_.Get());
@@ -167,7 +167,7 @@
/*fetch_time=*/clock().Now(),
/*expiry_time=*/base::Time()))));
EXPECT_CALL(callback_,
- Run(absl::optional<PublicKey>(std::move(expected_key)),
+ Run(std::optional<PublicKey>(std::move(expected_key)),
AggregationServiceKeyFetcher::PublicKeyFetchStatus::kOk));
fetcher_->GetPublicKey(url, callback_.Get());
@@ -193,8 +193,8 @@
EXPECT_CALL(*network_fetcher_, FetchPublicKeys(url, _))
.WillOnce(
testing::DoAll(base::test::RunOnceClosure(run_loop.QuitClosure()),
- base::test::RunOnceCallback<1>(absl::nullopt)));
- EXPECT_CALL(callback_, Run(absl::optional<PublicKey>(absl::nullopt),
+ base::test::RunOnceCallback<1>(std::nullopt)));
+ EXPECT_CALL(callback_, Run(std::optional<PublicKey>(std::nullopt),
AggregationServiceKeyFetcher::
PublicKeyFetchStatus::kPublicKeyFetchFailed));
@@ -219,7 +219,7 @@
/*fetch_time=*/clock().Now(),
/*expiry_time=*/base::Time::Max()))));
EXPECT_CALL(callback_,
- Run(absl::optional<PublicKey>(std::move(expected_key)),
+ Run(std::optional<PublicKey>(std::move(expected_key)),
AggregationServiceKeyFetcher::PublicKeyFetchStatus::kOk))
.Times(10);
@@ -237,8 +237,8 @@
EXPECT_CALL(*network_fetcher_, FetchPublicKeys(url, _))
.WillOnce(
testing::DoAll(base::test::RunOnceClosure(run_loop.QuitClosure()),
- base::test::RunOnceCallback<1>(absl::nullopt)));
- EXPECT_CALL(callback_, Run(absl::optional<PublicKey>(absl::nullopt),
+ base::test::RunOnceCallback<1>(std::nullopt)));
+ EXPECT_CALL(callback_, Run(std::optional<PublicKey>(std::nullopt),
AggregationServiceKeyFetcher::
PublicKeyFetchStatus::kPublicKeyFetchFailed))
.Times(10);
diff --git a/content/browser/aggregation_service/aggregation_service_network_fetcher_impl.cc b/content/browser/aggregation_service/aggregation_service_network_fetcher_impl.cc
index e4756be..e1d6281 100644
--- a/content/browser/aggregation_service/aggregation_service_network_fetcher_impl.cc
+++ b/content/browser/aggregation_service/aggregation_service_network_fetcher_impl.cc
@@ -5,6 +5,7 @@
#include "content/browser/aggregation_service/aggregation_service_network_fetcher_impl.h"
#include <memory>
+#include <optional>
#include <utility>
#include <vector>
@@ -26,7 +27,6 @@
#include "services/network/public/cpp/shared_url_loader_factory.h"
#include "services/network/public/cpp/simple_url_loader.h"
#include "services/network/public/mojom/url_response_head.mojom.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
#include "url/gurl.h"
namespace content {
@@ -152,7 +152,7 @@
std::unique_ptr<network::SimpleURLLoader> loader = std::move(*it);
loaders_in_progress_.erase(it);
- absl::optional<int> http_response_code;
+ std::optional<int> http_response_code;
if (loader->ResponseInfo() && loader->ResponseInfo()->headers)
http_response_code = loader->ResponseInfo()->headers->response_code();
@@ -260,7 +260,7 @@
LOG(ERROR) << error_msg;
}
- std::move(callback).Run(absl::nullopt);
+ std::move(callback).Run(std::nullopt);
}
void AggregationServiceNetworkFetcherImpl::RecordFetchStatus(
diff --git a/content/browser/aggregation_service/aggregation_service_network_fetcher_impl_unittest.cc b/content/browser/aggregation_service/aggregation_service_network_fetcher_impl_unittest.cc
index de0ed139..5cdaeeb 100644
--- a/content/browser/aggregation_service/aggregation_service_network_fetcher_impl_unittest.cc
+++ b/content/browser/aggregation_service/aggregation_service_network_fetcher_impl_unittest.cc
@@ -105,7 +105,7 @@
auto quit_closure = task_environment_.QuitClosure();
network_fetcher_->FetchPublicKeys(
GURL(kExampleUrl),
- base::BindLambdaForTesting([&](absl::optional<PublicKeyset> keyset) {
+ base::BindLambdaForTesting([&](std::optional<PublicKeyset> keyset) {
EXPECT_TRUE(keyset.has_value());
EXPECT_TRUE(aggregation_service::PublicKeysEqual(kExamplePublicKeys,
keyset->keys));
@@ -130,7 +130,7 @@
auto quit_closure = task_environment_.QuitClosure();
network_fetcher_->FetchPublicKeys(
GURL(kExampleUrl),
- base::BindLambdaForTesting([&](absl::optional<PublicKeyset> keyset) {
+ base::BindLambdaForTesting([&](std::optional<PublicKeyset> keyset) {
EXPECT_FALSE(keyset.has_value());
quit_closure.Run();
}));
@@ -151,7 +151,7 @@
auto quit_closure = task_environment_.QuitClosure();
network_fetcher_->FetchPublicKeys(
GURL(kExampleUrl),
- base::BindLambdaForTesting([&](absl::optional<PublicKeyset> keyset) {
+ base::BindLambdaForTesting([&](std::optional<PublicKeyset> keyset) {
EXPECT_FALSE(keyset.has_value());
quit_closure.Run();
}));
@@ -171,7 +171,7 @@
auto quit_closure = task_environment_.QuitClosure();
network_fetcher_->FetchPublicKeys(
GURL(kExampleUrl),
- base::BindLambdaForTesting([&](absl::optional<PublicKeyset> keyset) {
+ base::BindLambdaForTesting([&](std::optional<PublicKeyset> keyset) {
EXPECT_FALSE(keyset.has_value());
quit_closure.Run();
}));
@@ -205,7 +205,7 @@
auto quit_closure = task_environment_.QuitClosure();
network_fetcher_->FetchPublicKeys(
GURL(kExampleUrl),
- base::BindLambdaForTesting([&](absl::optional<PublicKeyset> keyset) {
+ base::BindLambdaForTesting([&](std::optional<PublicKeyset> keyset) {
EXPECT_FALSE(keyset.has_value());
quit_closure.Run();
}));
@@ -235,7 +235,7 @@
auto quit_closure = task_environment_.QuitClosure();
network_fetcher_->FetchPublicKeys(
GURL(kExampleUrl),
- base::BindLambdaForTesting([&](absl::optional<PublicKeyset> keyset) {
+ base::BindLambdaForTesting([&](std::optional<PublicKeyset> keyset) {
EXPECT_FALSE(keyset.has_value());
quit_closure.Run();
}));
@@ -274,7 +274,7 @@
auto quit_closure = task_environment_.QuitClosure();
network_fetcher_->FetchPublicKeys(
GURL(kExampleUrl),
- base::BindLambdaForTesting([&](absl::optional<PublicKeyset> keyset) {
+ base::BindLambdaForTesting([&](std::optional<PublicKeyset> keyset) {
EXPECT_TRUE(keyset.has_value());
EXPECT_TRUE(aggregation_service::PublicKeysEqual(kExamplePublicKeys,
keyset->keys));
@@ -309,7 +309,7 @@
GURL url(kExampleUrl);
auto quit_closure = task_environment_.QuitClosure();
network_fetcher_->FetchPublicKeys(
- url, base::BindLambdaForTesting([&](absl::optional<PublicKeyset> keyset) {
+ url, base::BindLambdaForTesting([&](std::optional<PublicKeyset> keyset) {
quit_closure.Run();
}));
@@ -335,7 +335,7 @@
for (int i = 0; i < 10; i++) {
network_fetcher_->FetchPublicKeys(
url,
- base::BindLambdaForTesting([&](absl::optional<PublicKeyset> keyset) {
+ base::BindLambdaForTesting([&](std::optional<PublicKeyset> keyset) {
barrier_closure.Run();
}));
}
@@ -365,7 +365,7 @@
auto quit_closure = task_environment_.QuitClosure();
network_fetcher_->FetchPublicKeys(
GURL(kExampleUrl),
- base::BindLambdaForTesting([&](absl::optional<PublicKeyset> keyset) {
+ base::BindLambdaForTesting([&](std::optional<PublicKeyset> keyset) {
EXPECT_TRUE(keyset.has_value());
EXPECT_TRUE(aggregation_service::PublicKeysEqual(kExamplePublicKeys,
keyset->keys));
@@ -404,7 +404,7 @@
auto quit_closure = task_environment_.QuitClosure();
network_fetcher_->FetchPublicKeys(
GURL(kExampleUrl),
- base::BindLambdaForTesting([&](absl::optional<PublicKeyset> keyset) {
+ base::BindLambdaForTesting([&](std::optional<PublicKeyset> keyset) {
EXPECT_FALSE(keyset.has_value());
quit_closure.Run();
}));
diff --git a/content/browser/aggregation_service/aggregation_service_observer.h b/content/browser/aggregation_service/aggregation_service_observer.h
index b64cfd1..6ab55d7 100644
--- a/content/browser/aggregation_service/aggregation_service_observer.h
+++ b/content/browser/aggregation_service/aggregation_service_observer.h
@@ -5,9 +5,10 @@
#ifndef CONTENT_BROWSER_AGGREGATION_SERVICE_AGGREGATION_SERVICE_OBSERVER_H_
#define CONTENT_BROWSER_AGGREGATION_SERVICE_AGGREGATION_SERVICE_OBSERVER_H_
+#include <optional>
+
#include "base/observer_list_types.h"
#include "content/browser/aggregation_service/aggregation_service_storage.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace base {
class Time;
@@ -38,12 +39,12 @@
// Called when a report has been handled, i.e. attempted to be assembled and
// sent, regardless of success. `report_handled_time` indicates when the
- // report has been handled. `id` should be `absl::nullopt` iff the request was
+ // report has been handled. `id` should be `std::nullopt` iff the request was
// not stored/scheduled.
virtual void OnReportHandled(
const AggregatableReportRequest& request,
- absl::optional<AggregationServiceStorage::RequestId> id,
- const absl::optional<AggregatableReport>& report,
+ std::optional<AggregationServiceStorage::RequestId> id,
+ const std::optional<AggregatableReport>& report,
base::Time report_handled_time,
ReportStatus status) {}
};
diff --git a/content/browser/aggregation_service/aggregation_service_storage.h b/content/browser/aggregation_service/aggregation_service_storage.h
index 13a4f95..4a1e747 100644
--- a/content/browser/aggregation_service/aggregation_service_storage.h
+++ b/content/browser/aggregation_service/aggregation_service_storage.h
@@ -7,13 +7,13 @@
#include <stdint.h>
+#include <optional>
#include <set>
#include <vector>
#include "content/browser/aggregation_service/aggregatable_report.h"
#include "content/browser/aggregation_service/aggregatable_report_request_storage_id.h"
#include "content/public/browser/storage_partition.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
class GURL;
@@ -77,19 +77,19 @@
// Returns the earliest report time for a stored pending request strictly
// after `strictly_after_time`. If there are no such requests stored, returns
- // `absl::nullopt`.
- virtual absl::optional<base::Time> NextReportTimeAfter(
+ // `std::nullopt`.
+ virtual std::optional<base::Time> NextReportTimeAfter(
base::Time strictly_after_time) = 0;
// Returns requests with report times on or before `not_after_time`. The
// returned requests are ordered by report time. `limit` limits the number of
// requests to return and cannot have a non-positive value; use
- // `absl::nullopt` for no limit.
+ // `std::nullopt` for no limit.
// TODO(crbug.com/1340046): Limit the number of in-progress reports kept in
// memory at the same time.
virtual std::vector<RequestAndId> GetRequestsReportingOnOrBefore(
base::Time not_after_time,
- absl::optional<int> limit = absl::nullopt) = 0;
+ std::optional<int> limit = std::nullopt) = 0;
// Returns the requests with the given IDs. Empty vector is returned if `ids`
// is empty.
@@ -101,7 +101,7 @@
// each report is picked independently from a uniform distribution between
// `min_delay` and `max_delay`, both inclusive. Returns the new first report
// time in storage, if any.
- virtual absl::optional<base::Time> AdjustOfflineReportTimes(
+ virtual std::optional<base::Time> AdjustOfflineReportTimes(
base::Time now,
base::TimeDelta min_delay,
base::TimeDelta max_delay) = 0;
diff --git a/content/browser/aggregation_service/aggregation_service_storage_sql.cc b/content/browser/aggregation_service/aggregation_service_storage_sql.cc
index 472a372..7ee2f64 100644
--- a/content/browser/aggregation_service/aggregation_service_storage_sql.cc
+++ b/content/browser/aggregation_service/aggregation_service_storage_sql.cc
@@ -7,6 +7,7 @@
#include <stddef.h>
#include <stdint.h>
+#include <optional>
#include <set>
#include <string>
#include <utility>
@@ -37,7 +38,6 @@
#include "sql/statement_id.h"
#include "sql/transaction.h"
#include "third_party/abseil-cpp/absl/numeric/int128.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
#include "third_party/blink/public/common/storage_key/storage_key.h"
#include "url/gurl.h"
#include "url/origin.h"
@@ -565,18 +565,17 @@
return delete_request_statement.Run();
}
-absl::optional<base::Time> AggregationServiceStorageSql::NextReportTimeAfter(
+std::optional<base::Time> AggregationServiceStorageSql::NextReportTimeAfter(
base::Time strictly_after_time) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
if (!EnsureDatabaseOpen(DbCreationPolicy::kFailIfAbsent))
- return absl::nullopt;
+ return std::nullopt;
return NextReportTimeAfterImpl(strictly_after_time);
}
-absl::optional<base::Time>
-AggregationServiceStorageSql::NextReportTimeAfterImpl(
+std::optional<base::Time> AggregationServiceStorageSql::NextReportTimeAfterImpl(
base::Time strictly_after_time) {
static constexpr char kGetRequestsSql[] =
"SELECT MIN(report_time) FROM report_requests WHERE report_time>?";
@@ -590,13 +589,13 @@
get_requests_statement.GetColumnType(0) != sql::ColumnType::kNull) {
return get_requests_statement.ColumnTime(0);
}
- return absl::nullopt;
+ return std::nullopt;
}
std::vector<AggregationServiceStorage::RequestAndId>
AggregationServiceStorageSql::GetRequestsReportingOnOrBefore(
base::Time not_after_time,
- absl::optional<int> limit) {
+ std::optional<int> limit) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK(!limit.has_value() || limit.value() > 0);
@@ -626,7 +625,7 @@
while (get_requests_statement.Step()) {
AggregationServiceStorage::RequestId request_id{
get_requests_statement.ColumnInt64(0)};
- absl::optional<AggregatableReportRequest> parsed_request =
+ std::optional<AggregatableReportRequest> parsed_request =
AggregatableReportRequest::Deserialize(
get_requests_statement.ColumnBlob(2));
if (!parsed_request) {
@@ -677,7 +676,7 @@
statement.BindInt64(0, *id);
if (!statement.Step())
continue;
- absl::optional<AggregatableReportRequest> parsed_request =
+ std::optional<AggregatableReportRequest> parsed_request =
AggregatableReportRequest::Deserialize(statement.ColumnBlob(1));
if (!parsed_request)
continue;
@@ -689,7 +688,7 @@
return result;
}
-absl::optional<base::Time>
+std::optional<base::Time>
AggregationServiceStorageSql::AdjustOfflineReportTimes(
base::Time now,
base::TimeDelta min_delay,
@@ -701,7 +700,7 @@
DCHECK_LE(min_delay, max_delay);
if (!EnsureDatabaseOpen(DbCreationPolicy::kFailIfAbsent))
- return absl::nullopt;
+ return std::nullopt;
// Set the report time for all reports that should have been sent before `now`
// to `now` + a random number of microseconds between `min_delay` and
diff --git a/content/browser/aggregation_service/aggregation_service_storage_sql.h b/content/browser/aggregation_service/aggregation_service_storage_sql.h
index 1534776..7ff9222 100644
--- a/content/browser/aggregation_service/aggregation_service_storage_sql.h
+++ b/content/browser/aggregation_service/aggregation_service_storage_sql.h
@@ -7,6 +7,7 @@
#include <stdint.h>
+#include <optional>
#include <set>
#include <vector>
@@ -22,7 +23,6 @@
#include "content/public/browser/storage_partition.h"
#include "sql/database.h"
#include "sql/meta_table.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
class GURL;
@@ -80,15 +80,15 @@
void UpdateReportForSendFailure(
AggregationServiceStorage::RequestId request_id,
base::Time new_report_time) override;
- absl::optional<base::Time> NextReportTimeAfter(
+ std::optional<base::Time> NextReportTimeAfter(
base::Time strictly_after_time) override;
std::vector<AggregationServiceStorage::RequestAndId>
GetRequestsReportingOnOrBefore(
base::Time not_after_time,
- absl::optional<int> limit = absl::nullopt) override;
+ std::optional<int> limit = std::nullopt) override;
std::vector<AggregationServiceStorage::RequestAndId> GetRequests(
const std::vector<AggregationServiceStorage::RequestId>& ids) override;
- absl::optional<base::Time> AdjustOfflineReportTimes(
+ std::optional<base::Time> AdjustOfflineReportTimes(
base::Time now,
base::TimeDelta min_delay,
base::TimeDelta max_delay) override;
@@ -160,7 +160,7 @@
bool DeleteRequestImpl(RequestId request_id)
VALID_CONTEXT_REQUIRED(sequence_checker_);
- absl::optional<base::Time> NextReportTimeAfterImpl(
+ std::optional<base::Time> NextReportTimeAfterImpl(
base::Time strictly_after_time) VALID_CONTEXT_REQUIRED(sequence_checker_);
// Clears the report requests that were stored between `delete_begin` and
@@ -216,8 +216,7 @@
// at for lazy initialization, and used as a signal for if the database is
// closed. This is initialized in the first call to EnsureDatabaseOpen() to
// avoid doing additional work in the constructor.
- absl::optional<DbStatus> db_init_status_
- GUARDED_BY_CONTEXT(sequence_checker_);
+ std::optional<DbStatus> db_init_status_ GUARDED_BY_CONTEXT(sequence_checker_);
sql::Database db_ GUARDED_BY_CONTEXT(sequence_checker_);
diff --git a/content/browser/aggregation_service/aggregation_service_storage_sql_unittest.cc b/content/browser/aggregation_service/aggregation_service_storage_sql_unittest.cc
index ea79f30..65377d1 100644
--- a/content/browser/aggregation_service/aggregation_service_storage_sql_unittest.cc
+++ b/content/browser/aggregation_service/aggregation_service_storage_sql_unittest.cc
@@ -5,6 +5,7 @@
#include "content/browser/aggregation_service/aggregation_service_storage_sql.h"
#include <memory>
+#include <optional>
#include <string>
#include <utility>
#include <vector>
@@ -36,7 +37,6 @@
#include "sql/test/test_helpers.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
#include "third_party/blink/public/common/storage_key/storage_key.h"
#include "url/gurl.h"
#include "url/origin.h"
@@ -76,8 +76,8 @@
// Use the default limit unless specified.
void OpenDatabase(
- absl::optional<int> max_stored_requests_per_reporting_origin =
- absl::nullopt) {
+ std::optional<int> max_stored_requests_per_reporting_origin =
+ std::nullopt) {
if (max_stored_requests_per_reporting_origin.has_value()) {
storage_ = std::make_unique<AggregationServiceStorageSql>(
/*run_in_memory=*/false, temp_directory_.GetPath(), &clock_,
@@ -674,13 +674,13 @@
const struct {
base::Time strictly_after_time;
- absl::optional<base::Time> expected_return_value;
+ std::optional<base::Time> expected_return_value;
} kTestCases[] = {
{base::Time::Min(), report_time},
{report_time - base::Seconds(1), report_time},
- {report_time, absl::nullopt},
- {report_time + base::Seconds(1), absl::nullopt},
- {base::Time::Max(), absl::nullopt},
+ {report_time, std::nullopt},
+ {report_time + base::Seconds(1), std::nullopt},
+ {base::Time::Max(), std::nullopt},
};
@@ -708,7 +708,7 @@
example_request.shared_info().Clone();
shared_info.scheduled_report_time = scheduled_report_time;
- absl::optional<AggregatableReportRequest> request =
+ std::optional<AggregatableReportRequest> request =
AggregatableReportRequest::Create(example_request.payload_contents(),
std::move(shared_info));
ASSERT_TRUE(request.has_value());
@@ -906,7 +906,7 @@
{
// The report time is now considered in the past so it is adjusted.
- absl::optional<base::Time> new_report_time =
+ std::optional<base::Time> new_report_time =
storage_->AdjustOfflineReportTimes(
/*now=*/original_report_time + base::Minutes(1),
/*min_delay=*/base::Minutes(1),
@@ -934,7 +934,7 @@
{
// The delay can be constant (i.e. min delay can be equal to max delay)
- absl::optional<base::Time> new_report_time =
+ std::optional<base::Time> new_report_time =
storage_->AdjustOfflineReportTimes(
/*now=*/original_report_time + base::Minutes(1),
/*min_delay=*/base::Minutes(1),
@@ -948,7 +948,7 @@
{
// The min delay can be zero
- absl::optional<base::Time> new_report_time =
+ std::optional<base::Time> new_report_time =
storage_->AdjustOfflineReportTimes(
/*now=*/original_report_time + base::Minutes(5),
/*min_delay=*/base::Minutes(0),
@@ -979,7 +979,7 @@
example_request.shared_info().Clone();
shared_info.scheduled_report_time = scheduled_report_time;
- absl::optional<AggregatableReportRequest> request =
+ std::optional<AggregatableReportRequest> request =
AggregatableReportRequest::Create(example_request.payload_contents(),
std::move(shared_info));
ASSERT_TRUE(request.has_value());
@@ -1152,7 +1152,7 @@
example_request.payload_contents(),
example_request.shared_info().Clone(),
/*reporting_path=*/std::string(),
- /*debug_key=*/absl::nullopt,
+ /*debug_key=*/std::nullopt,
/*additional_fields=*/{{"additional_key", "example_value"}})
.value();
@@ -1191,7 +1191,7 @@
AggregatableReportRequest::Create(payload_contents,
example_request.shared_info().Clone(),
/*reporting_path=*/std::string(),
- /*debug_key=*/absl::nullopt,
+ /*debug_key=*/std::nullopt,
/*additional_fields=*/{})
.value();
diff --git a/content/browser/aggregation_service/aggregation_service_test_utils.cc b/content/browser/aggregation_service/aggregation_service_test_utils.cc
index 6637af6..2a75f320 100644
--- a/content/browser/aggregation_service/aggregation_service_test_utils.cc
+++ b/content/browser/aggregation_service/aggregation_service_test_utils.cc
@@ -7,6 +7,7 @@
#include <stddef.h>
#include <stdint.h>
+#include <optional>
#include <ostream>
#include <string>
#include <tuple>
@@ -33,7 +34,6 @@
#include "content/browser/aggregation_service/public_key.h"
#include "content/browser/aggregation_service/public_key_parsing_utils.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
#include "third_party/blink/public/mojom/private_aggregation/aggregatable_report.mojom.h"
#include "third_party/boringssl/src/include/openssl/hpke.h"
#include "url/gurl.h"
@@ -237,7 +237,7 @@
AggregatableReportRequest CreateExampleRequest(
blink::mojom::AggregationServiceMode aggregation_mode,
int failed_send_attempts,
- absl::optional<url::Origin> aggregation_coordinator_origin) {
+ std::optional<url::Origin> aggregation_coordinator_origin) {
return CreateExampleRequestWithReportTime(
/*report_time=*/base::Time::Now(), aggregation_mode, failed_send_attempts,
std::move(aggregation_coordinator_origin));
@@ -247,7 +247,7 @@
base::Time report_time,
blink::mojom::AggregationServiceMode aggregation_mode,
int failed_send_attempts,
- absl::optional<url::Origin> aggregation_coordinator_origin) {
+ std::optional<url::Origin> aggregation_coordinator_origin) {
return AggregatableReportRequest::Create(
AggregationServicePayloadContents(
AggregationServicePayloadContents::Operation::kHistogram,
@@ -266,7 +266,7 @@
/*api_version=*/"",
/*api_identifier=*/"example-api"),
/*reporting_path=*/"example-path",
- /*debug_key=*/absl::nullopt, /*additional_fields=*/{},
+ /*debug_key=*/std::nullopt, /*additional_fields=*/{},
failed_send_attempts)
.value();
}
@@ -429,8 +429,8 @@
void MockAggregationService::NotifyReportHandled(
const AggregatableReportRequest& request,
- absl::optional<AggregationServiceStorage::RequestId> id,
- absl::optional<AggregatableReport> report,
+ std::optional<AggregationServiceStorage::RequestId> id,
+ std::optional<AggregatableReport> report,
base::Time report_handled_time,
AggregationServiceObserver::ReportStatus status) {
for (auto& observer : observers_)
diff --git a/content/browser/aggregation_service/aggregation_service_test_utils.h b/content/browser/aggregation_service/aggregation_service_test_utils.h
index cf20100..32acd0a 100644
--- a/content/browser/aggregation_service/aggregation_service_test_utils.h
+++ b/content/browser/aggregation_service/aggregation_service_test_utils.h
@@ -7,6 +7,7 @@
#include <stdint.h>
+#include <optional>
#include <ostream>
#include <set>
#include <string>
@@ -25,7 +26,6 @@
#include "content/browser/aggregation_service/public_key.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
#include "third_party/blink/public/mojom/private_aggregation/aggregatable_report.mojom.h"
#include "third_party/boringssl/src/include/openssl/hpke.h"
@@ -90,14 +90,14 @@
blink::mojom::AggregationServiceMode aggregation_mode =
blink::mojom::AggregationServiceMode::kDefault,
int failed_send_attempts = 0,
- absl::optional<url::Origin> aggregation_coordinator_origin = absl::nullopt);
+ std::optional<url::Origin> aggregation_coordinator_origin = std::nullopt);
AggregatableReportRequest CreateExampleRequestWithReportTime(
base::Time report_time,
blink::mojom::AggregationServiceMode aggregation_mode =
blink::mojom::AggregationServiceMode::kDefault,
int failed_send_attempts = 0,
- absl::optional<url::Origin> aggregation_coordinator_origin = absl::nullopt);
+ std::optional<url::Origin> aggregation_coordinator_origin = std::nullopt);
AggregatableReportRequest CloneReportRequest(
const AggregatableReportRequest& request);
@@ -213,8 +213,8 @@
// `report_handled_time` indicates when the report has been handled.
void NotifyReportHandled(
const AggregatableReportRequest& request,
- absl::optional<AggregationServiceStorage::RequestId> id,
- absl::optional<AggregatableReport> report,
+ std::optional<AggregationServiceStorage::RequestId> id,
+ std::optional<AggregatableReport> report,
base::Time report_handled_time,
AggregationServiceObserver::ReportStatus status);
diff --git a/content/browser/aggregation_service/public_key_parsing_utils.cc b/content/browser/aggregation_service/public_key_parsing_utils.cc
index 3ed920a..73b33087 100644
--- a/content/browser/aggregation_service/public_key_parsing_utils.cc
+++ b/content/browser/aggregation_service/public_key_parsing_utils.cc
@@ -6,6 +6,7 @@
#include <stdint.h>
+#include <optional>
#include <string>
#include <vector>
@@ -13,40 +14,39 @@
#include "base/containers/flat_set.h"
#include "base/values.h"
#include "content/browser/aggregation_service/public_key.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace content {
namespace {
// Constructs a public key from a single JSON key definition. Returns
-// `absl::nullopt`in case of an error or invalid JSON.
-absl::optional<PublicKey> GetPublicKey(base::Value& value) {
+// `std::nullopt`in case of an error or invalid JSON.
+std::optional<PublicKey> GetPublicKey(base::Value& value) {
if (!value.is_dict())
- return absl::nullopt;
+ return std::nullopt;
base::Value::Dict& dict = value.GetDict();
std::string* key_id = dict.FindString("id");
if (!key_id) {
- return absl::nullopt;
+ return std::nullopt;
}
if (key_id->size() > PublicKey::kMaxIdSize) {
- return absl::nullopt;
+ return std::nullopt;
}
std::string* key = dict.FindString("key");
if (!key) {
- return absl::nullopt;
+ return std::nullopt;
}
std::string key_string;
if (!base::Base64Decode(*key, &key_string)) {
- return absl::nullopt;
+ return std::nullopt;
}
if (key_string.size() != PublicKey::kKeyByteLength)
- return absl::nullopt;
+ return std::nullopt;
return PublicKey(std::move(*key_id),
std::vector<uint8_t>(key_string.begin(), key_string.end()));
@@ -74,7 +74,7 @@
if (public_keys.size() == PublicKeyset::kMaxNumberKeys)
return {};
- absl::optional<PublicKey> key = GetPublicKey(key_json);
+ std::optional<PublicKey> key = GetPublicKey(key_json);
// Return error (i.e. empty vector) if any of the keys are invalid.
if (!key.has_value())
diff --git a/content/browser/aggregation_service/public_key_parsing_utils_unittest.cc b/content/browser/aggregation_service/public_key_parsing_utils_unittest.cc
index 366b638..6da0e60d7 100644
--- a/content/browser/aggregation_service/public_key_parsing_utils_unittest.cc
+++ b/content/browser/aggregation_service/public_key_parsing_utils_unittest.cc
@@ -29,7 +29,7 @@
})",
{generated_key.GetPublicKeyBase64()}, /*offsets=*/nullptr);
- absl::optional<base::Value> json_object = base::JSONReader::Read(json_string);
+ std::optional<base::Value> json_object = base::JSONReader::Read(json_string);
ASSERT_TRUE(json_object) << "Incorrectly formatted JSON string.";
std::vector<PublicKey> keys =
@@ -59,7 +59,7 @@
generated_key_2.GetPublicKeyBase64()},
/*offsets=*/nullptr);
- absl::optional<base::Value> json_object = base::JSONReader::Read(json_string);
+ std::optional<base::Value> json_object = base::JSONReader::Read(json_string);
ASSERT_TRUE(json_object) << "Incorrectly formatted JSON string.";
std::vector<PublicKey> keys =
@@ -80,7 +80,7 @@
{aggregation_service::TestHpkeKey().GetPublicKeyBase64()},
/*offsets=*/nullptr);
- absl::optional<base::Value> json_object = base::JSONReader::Read(json_string);
+ std::optional<base::Value> json_object = base::JSONReader::Read(json_string);
ASSERT_TRUE(json_object) << "Incorrectly formatted JSON string.";
std::vector<PublicKey> keys =
@@ -99,7 +99,7 @@
}
)";
- absl::optional<base::Value> json_object = base::JSONReader::Read(json_string);
+ std::optional<base::Value> json_object = base::JSONReader::Read(json_string);
ASSERT_TRUE(json_object) << "Incorrectly formatted JSON string.";
std::vector<PublicKey> keys =
@@ -124,7 +124,7 @@
})",
{invalid_base64}, /*offsets=*/nullptr);
- absl::optional<base::Value> json_object = base::JSONReader::Read(json_string);
+ std::optional<base::Value> json_object = base::JSONReader::Read(json_string);
ASSERT_TRUE(json_object) << "Incorrectly formatted JSON string.";
std::vector<PublicKey> keys =
@@ -148,7 +148,7 @@
})",
{wrong_length_key}, /*offsets=*/nullptr);
- absl::optional<base::Value> json_object = base::JSONReader::Read(json_string);
+ std::optional<base::Value> json_object = base::JSONReader::Read(json_string);
ASSERT_TRUE(json_object) << "Incorrectly formatted JSON string.";
std::vector<PublicKey> keys =
@@ -173,7 +173,7 @@
{aggregation_service::TestHpkeKey().GetPublicKeyBase64()},
/*offsets=*/nullptr);
- absl::optional<base::Value> json_object = base::JSONReader::Read(json_string);
+ std::optional<base::Value> json_object = base::JSONReader::Read(json_string);
ASSERT_TRUE(json_object) << "Incorrectly formatted JSON string.";
std::vector<PublicKey> keys =
@@ -200,7 +200,7 @@
.GetPublicKeyBase64()},
/*offsets=*/nullptr);
- absl::optional<base::Value> json_object = base::JSONReader::Read(json_string);
+ std::optional<base::Value> json_object = base::JSONReader::Read(json_string);
ASSERT_TRUE(json_object) << "Incorrectly formatted JSON string.";
std::vector<PublicKey> keys =
@@ -223,7 +223,7 @@
})",
{generated_key.GetPublicKeyBase64()}, /*offsets=*/nullptr);
- absl::optional<base::Value> json_object = base::JSONReader::Read(json_string);
+ std::optional<base::Value> json_object = base::JSONReader::Read(json_string);
ASSERT_TRUE(json_object) << "Incorrectly formatted JSON string.";
std::vector<PublicKey> keys =
@@ -247,7 +247,7 @@
})",
{generated_key.GetPublicKeyBase64()}, /*offsets=*/nullptr);
- absl::optional<base::Value> json_object = base::JSONReader::Read(json_string);
+ std::optional<base::Value> json_object = base::JSONReader::Read(json_string);
ASSERT_TRUE(json_object) << "Incorrectly formatted JSON string.";
std::vector<PublicKey> keys =
diff --git a/content/browser/aggregation_service/report_scheduler_timer.cc b/content/browser/aggregation_service/report_scheduler_timer.cc
index 5488f55..37cb813 100644
--- a/content/browser/aggregation_service/report_scheduler_timer.cc
+++ b/content/browser/aggregation_service/report_scheduler_timer.cc
@@ -5,6 +5,7 @@
#include "content/browser/aggregation_service/report_scheduler_timer.h"
#include <memory>
+#include <optional>
#include <utility>
#include "base/check.h"
@@ -16,7 +17,6 @@
#include "base/timer/wall_clock_timer.h"
#include "content/public/browser/network_service_instance.h"
#include "services/network/public/mojom/network_change_manager.mojom.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace content {
@@ -46,7 +46,7 @@
return connection_type_;
}
-void ReportSchedulerTimer::MaybeSet(absl::optional<base::Time> reporting_time) {
+void ReportSchedulerTimer::MaybeSet(std::optional<base::Time> reporting_time) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
if (!reporting_time.has_value() || IsOffline()) {
diff --git a/content/browser/aggregation_service/report_scheduler_timer.h b/content/browser/aggregation_service/report_scheduler_timer.h
index 640d863..2e8fd720 100644
--- a/content/browser/aggregation_service/report_scheduler_timer.h
+++ b/content/browser/aggregation_service/report_scheduler_timer.h
@@ -6,6 +6,7 @@
#define CONTENT_BROWSER_AGGREGATION_SERVICE_REPORT_SCHEDULER_TIMER_H_
#include <memory>
+#include <optional>
#include "base/functional/callback_forward.h"
#include "base/memory/weak_ptr.h"
@@ -16,7 +17,6 @@
#include "content/common/content_export.h"
#include "services/network/public/cpp/network_connection_tracker.h"
#include "services/network/public/mojom/network_change_manager.mojom.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace base {
class Time;
@@ -39,9 +39,9 @@
// Should be overridden with a method that gets the next report time that
// the timer should fire at and returns it via the callback. If there is no
- // next report time, `absl::nullopt` should be returned instead.
+ // next report time, `std::nullopt` should be returned instead.
virtual void GetNextReportTime(
- base::OnceCallback<void(absl::optional<base::Time>)>,
+ base::OnceCallback<void(std::optional<base::Time>)>,
base::Time now) = 0;
// Called when the timer is fired, with the current time `now`. `Refresh()`
@@ -61,7 +61,7 @@
// the given argument; this may be necessary after the report times were
// adjusted.
virtual void AdjustOfflineReportTimes(
- base::OnceCallback<void(absl::optional<base::Time>)>) = 0;
+ base::OnceCallback<void(std::optional<base::Time>)>) = 0;
};
explicit ReportSchedulerTimer(std::unique_ptr<Delegate> delegate);
@@ -77,7 +77,7 @@
// Schedules `reporting_time_reached_timer_` to fire at that time, unless the
// timer is already set to fire earlier.
- void MaybeSet(absl::optional<base::Time> reporting_time);
+ void MaybeSet(std::optional<base::Time> reporting_time);
private:
void OnTimerFired();
diff --git a/content/browser/aggregation_service/report_scheduler_timer_unittest.cc b/content/browser/aggregation_service/report_scheduler_timer_unittest.cc
index 8473c7f..32bdf01 100644
--- a/content/browser/aggregation_service/report_scheduler_timer_unittest.cc
+++ b/content/browser/aggregation_service/report_scheduler_timer_unittest.cc
@@ -5,6 +5,7 @@
#include "content/browser/aggregation_service/report_scheduler_timer.h"
#include <memory>
+#include <optional>
#include <utility>
#include "base/functional/callback.h"
@@ -17,7 +18,6 @@
#include "services/network/test/test_network_connection_tracker.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace content {
@@ -36,14 +36,13 @@
public:
MOCK_METHOD(void,
GetNextReportTime,
- (base::OnceCallback<void(absl::optional<base::Time>)>,
- base::Time),
+ (base::OnceCallback<void(std::optional<base::Time>)>, base::Time),
(override));
MOCK_METHOD(void, OnReportingTimeReached, (base::Time), (override));
MOCK_METHOD(void,
AdjustOfflineReportTimes,
- (base::OnceCallback<void(absl::optional<base::Time>)>),
+ (base::OnceCallback<void(std::optional<base::Time>)>),
(override));
MOCK_METHOD(void, OnReportingPaused, (), (override));
@@ -92,8 +91,8 @@
TEST_F(ReportSchedulerTimerTest, MultipleSetTimers_FiredAtAppropriateTime) {
Checkpoint checkpoint;
- base::OnceCallback<void(absl::optional<base::Time>)> saved_cb_1;
- base::OnceCallback<void(absl::optional<base::Time>)> saved_cb_2;
+ base::OnceCallback<void(std::optional<base::Time>)> saved_cb_1;
+ base::OnceCallback<void(std::optional<base::Time>)> saved_cb_2;
{
InSequence seq;
@@ -141,7 +140,7 @@
checkpoint.Call(4);
// Nothing should happen if no reports are left.
- std::move(saved_cb_2).Run(absl::nullopt);
+ std::move(saved_cb_2).Run(std::nullopt);
}
TEST_F(ReportSchedulerTimerTest, NetworkChange) {