#include "content/browser/interest_group/interest_group_pa_report_util.h"
#include <stdint.h>
#include <cmath>
#include <map>
#include <optional>
#include <string>
#include <utility>
#include <vector>
#include "base/check.h"
#include "base/check_op.h"
#include "base/containers/flat_map.h"
#include "base/feature_list.h"
#include "base/notreached.h"
#include "base/numerics/clamped_math.h"
#include "components/aggregation_service/aggregation_coordinator_utils.h"
#include "content/browser/private_aggregation/private_aggregation_host.h"
#include "content/browser/private_aggregation/private_aggregation_manager.h"
#include "content/common/content_export.h"
#include "content/services/auction_worklet/public/mojom/private_aggregation_request.mojom.h"
#include "content/services/auction_worklet/public/mojom/seller_worklet.mojom.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "third_party/abseil-cpp/absl/numeric/int128.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/mojom/aggregation_service/aggregatable_report.mojom.h"
#include "third_party/blink/public/mojom/private_aggregation/private_aggregation_host.mojom.h"
#include "url/origin.h"
#include "url/url_constants.h"
namespace content {
namespace {
std::optional<double> GetBaseValue(
auction_worklet::mojom::BaseValue base_value,
double winning_bid,
double highest_scoring_other_bid,
const std::optional<auction_worklet::mojom::RejectReason> reject_reason,
const PrivateAggregationTimings& timings) { … }
std::optional<absl::uint128> CalculateBucket(
const auction_worklet::mojom::SignalBucketPtr& bucket_obj,
std::optional<double> base) { … }
std::optional<int32_t> CalculateValue(
const auction_worklet::mojom::SignalValuePtr& value_obj,
std::optional<double> base) { … }
blink::mojom::AggregatableReportHistogramContributionPtr
CalculateContributionBucketAndValue(
auction_worklet::mojom::AggregatableReportForEventContributionPtr
contribution,
double winning_bid,
double highest_scoring_other_bid,
const std::optional<auction_worklet::mojom::RejectReason> reject_reason,
const PrivateAggregationTimings& timings) { … }
}
PrivateAggregationKey::PrivateAggregationKey(
url::Origin reporting_origin,
std::optional<url::Origin> aggregation_coordinator_origin)
: … { … }
PrivateAggregationKey::PrivateAggregationKey(
const PrivateAggregationKey& other) = default;
PrivateAggregationKey& PrivateAggregationKey::operator=(
const PrivateAggregationKey& other) = default;
PrivateAggregationKey::PrivateAggregationKey(PrivateAggregationKey&& other) =
default;
PrivateAggregationKey& PrivateAggregationKey::operator=(
PrivateAggregationKey&& other) = default;
PrivateAggregationKey::~PrivateAggregationKey() = default;
PrivateAggregationPhaseKey::PrivateAggregationPhaseKey(
url::Origin reporting_origin,
PrivateAggregationPhase phase,
std::optional<url::Origin> aggregation_coordinator_origin)
: … { … }
PrivateAggregationPhaseKey::PrivateAggregationPhaseKey(
const PrivateAggregationPhaseKey&) = default;
PrivateAggregationPhaseKey& PrivateAggregationPhaseKey::operator=(
const PrivateAggregationPhaseKey&) = default;
PrivateAggregationPhaseKey::PrivateAggregationPhaseKey(
PrivateAggregationPhaseKey&&) = default;
PrivateAggregationPhaseKey& PrivateAggregationPhaseKey::operator=(
PrivateAggregationPhaseKey&&) = default;
PrivateAggregationPhaseKey::~PrivateAggregationPhaseKey() = default;
PrivateAggregationRequestWithEventType::PrivateAggregationRequestWithEventType(
auction_worklet::mojom::PrivateAggregationRequestPtr request,
std::optional<std::string> event_type)
: … { … }
PrivateAggregationRequestWithEventType::PrivateAggregationRequestWithEventType(
PrivateAggregationRequestWithEventType&&) = default;
bool PrivateAggregationRequestWithEventType::operator==(
const PrivateAggregationRequestWithEventType& rhs) const { … }
PrivateAggregationRequestWithEventType::
~PrivateAggregationRequestWithEventType() = default;
std::optional<PrivateAggregationRequestWithEventType>
FillInPrivateAggregationRequest(
auction_worklet::mojom::PrivateAggregationRequestPtr request,
double winning_bid,
double highest_scoring_other_bid,
const std::optional<auction_worklet::mojom::RejectReason> reject_reason,
const PrivateAggregationTimings& timings,
bool is_winner) { … }
void SplitContributionsIntoBatchesThenSendToHost(
std::vector<auction_worklet::mojom::PrivateAggregationRequestPtr> requests,
PrivateAggregationManager& pa_manager,
const url::Origin& reporting_origin,
std::optional<url::Origin> aggregation_coordinator_origin,
const url::Origin& main_frame_origin) { … }
bool HasValidFilteringId(
const auction_worklet::mojom::PrivateAggregationRequestPtr& request) { … }
bool IsValidFilteringId(std::optional<uint64_t> filtering_id) { … }
}