#include "content/browser/private_aggregation/private_aggregation_manager_impl.h"
#include <stddef.h>
#include <memory>
#include <numeric>
#include <optional>
#include <set>
#include <string>
#include <utility>
#include <vector>
#include "base/barrier_closure.h"
#include "base/check.h"
#include "base/feature_list.h"
#include "base/files/file_path.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/memory/scoped_refptr.h"
#include "base/memory/weak_ptr.h"
#include "base/metrics/histogram_functions.h"
#include "base/numerics/checked_math.h"
#include "base/task/task_traits.h"
#include "base/task/thread_pool.h"
#include "base/task/updateable_sequenced_task_runner.h"
#include "base/time/time.h"
#include "content/browser/aggregation_service/aggregatable_report.h"
#include "content/browser/aggregation_service/aggregation_service.h"
#include "content/browser/private_aggregation/private_aggregation_budget_key.h"
#include "content/browser/private_aggregation/private_aggregation_budgeter.h"
#include "content/browser/private_aggregation/private_aggregation_features.h"
#include "content/browser/private_aggregation/private_aggregation_host.h"
#include "content/browser/private_aggregation/private_aggregation_utils.h"
#include "content/browser/storage_partition_impl.h"
#include "content/public/browser/private_aggregation_data_model.h"
#include "content/public/browser/storage_partition.h"
#include "mojo/public/cpp/bindings/pending_receiver.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"
namespace content {
namespace {
void RecordBudgeterResultHistogram(
PrivateAggregationBudgeter::RequestResult request_result) { … }
void RecordManagerResultHistogram(
PrivateAggregationManagerImpl::RequestResult request_result) { … }
}
PrivateAggregationManagerImpl::PrivateAggregationManagerImpl(
bool exclusively_run_in_memory,
const base::FilePath& user_data_directory,
StoragePartitionImpl* storage_partition)
: … { … }
PrivateAggregationManagerImpl::PrivateAggregationManagerImpl(
std::unique_ptr<PrivateAggregationBudgeter> budgeter,
std::unique_ptr<PrivateAggregationHost> host,
StoragePartitionImpl* storage_partition)
: … { … }
PrivateAggregationManagerImpl::~PrivateAggregationManagerImpl() = default;
bool PrivateAggregationManagerImpl::BindNewReceiver(
url::Origin worklet_origin,
url::Origin top_frame_origin,
PrivateAggregationBudgetKey::Api api_for_budgeting,
std::optional<std::string> context_id,
std::optional<base::TimeDelta> timeout,
std::optional<url::Origin> aggregation_coordinator_origin,
size_t filtering_id_max_bytes,
mojo::PendingReceiver<blink::mojom::PrivateAggregationHost>
pending_receiver) { … }
void PrivateAggregationManagerImpl::ClearBudgetData(
base::Time delete_begin,
base::Time delete_end,
StoragePartition::StorageKeyMatcherFunction filter,
base::OnceClosure done) { … }
bool PrivateAggregationManagerImpl::IsDebugModeAllowed(
const url::Origin& top_frame_origin,
const url::Origin& reporting_origin) { … }
void PrivateAggregationManagerImpl::OnReportRequestDetailsReceivedFromHost(
PrivateAggregationHost::ReportRequestGenerator report_request_generator,
std::vector<blink::mojom::AggregatableReportHistogramContribution>
contributions,
PrivateAggregationBudgetKey budget_key,
PrivateAggregationBudgeter::BudgetDeniedBehavior budget_denied_behavior) { … }
AggregationService* PrivateAggregationManagerImpl::GetAggregationService() { … }
void PrivateAggregationManagerImpl::OnConsumeBudgetReturned(
PrivateAggregationHost::ReportRequestGenerator report_request_generator,
std::vector<blink::mojom::AggregatableReportHistogramContribution>
contributions,
PrivateAggregationBudgetKey::Api api_for_budgeting,
PrivateAggregationBudgeter::BudgetDeniedBehavior budget_denied_behavior,
PrivateAggregationBudgeter::RequestResult request_result) { … }
void PrivateAggregationManagerImpl::OnContributionsFinalized(
PrivateAggregationHost::ReportRequestGenerator report_request_generator,
std::vector<blink::mojom::AggregatableReportHistogramContribution>
contributions,
PrivateAggregationBudgetKey::Api api_for_budgeting) { … }
void PrivateAggregationManagerImpl::GetAllDataKeys(
base::OnceCallback<void(std::set<DataKey>)> callback) { … }
void PrivateAggregationManagerImpl::OnBudgeterGetAllDataKeysReturned(
base::OnceCallback<void(std::set<DataKey>)> callback,
std::set<DataKey> all_keys) { … }
void PrivateAggregationManagerImpl::RemovePendingDataKey(
const DataKey& data_key,
base::OnceClosure callback) { … }
}