chromium/content/browser/attribution_reporting/attribution_resolver_impl.cc

// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "content/browser/attribution_reporting/attribution_resolver_impl.h"

#include <memory>
#include <optional>
#include <utility>

#include "base/check.h"
#include "base/check_op.h"
#include "base/containers/contains.h"
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/functional/overloaded.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/histogram_macros.h"
#include "base/ranges/algorithm.h"
#include "base/ranges/functional.h"
#include "base/time/time.h"
#include "base/types/expected.h"
#include "base/types/expected_macros.h"
#include "components/attribution_reporting/aggregatable_dedup_key.h"
#include "components/attribution_reporting/aggregatable_utils.h"
#include "components/attribution_reporting/aggregatable_values.h"
#include "components/attribution_reporting/event_report_windows.h"
#include "components/attribution_reporting/event_trigger_data.h"
#include "components/attribution_reporting/features.h"
#include "components/attribution_reporting/filters.h"
#include "components/attribution_reporting/source_registration.h"
#include "components/attribution_reporting/source_type.mojom.h"
#include "components/attribution_reporting/trigger_config.h"
#include "components/attribution_reporting/trigger_data_matching.mojom.h"
#include "content/browser/attribution_reporting/aggregatable_attribution_utils.h"
#include "content/browser/attribution_reporting/aggregatable_debug_rate_limit_table.h"
#include "content/browser/attribution_reporting/aggregatable_debug_report.h"
#include "content/browser/attribution_reporting/attribution_config.h"
#include "content/browser/attribution_reporting/attribution_info.h"
#include "content/browser/attribution_reporting/attribution_report.h"
#include "content/browser/attribution_reporting/attribution_resolver_delegate.h"
#include "content/browser/attribution_reporting/attribution_storage_sql.h"
#include "content/browser/attribution_reporting/create_report_result.h"
#include "content/browser/attribution_reporting/process_aggregatable_debug_report_result.mojom.h"
#include "content/browser/attribution_reporting/rate_limit_result.h"
#include "content/browser/attribution_reporting/storable_source.h"
#include "content/browser/attribution_reporting/store_source_result.h"
#include "content/browser/attribution_reporting/stored_source.h"
#include "third_party/blink/public/common/storage_key/storage_key.h"

namespace content {

namespace {
ProcessAggregatableDebugReportStatus;
EventReportWindows;
SuitableOrigin;
SourceType;
TriggerDataMatching;

AggregatableResult;
EventLevelResult;
StoredSourceData;

constexpr int64_t kUnsetRecordId =;

// These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused.
//
// LINT.IfChange(DestinationLimitResult)
enum class DestinationLimitResult {};
// LINT.ThenChange(//tools/metrics/histograms/metadata/attribution_reporting/enums.xml:AttributionSourceDestinationLimitResult)

DestinationLimitResult GetDestinationLimitResult(
    const std::vector<StoredSource::Id>& sources_to_deactivate) {}

bool IsSuccessResult(std::optional<EventLevelResult> result) {}

bool IsSuccessResult(std::optional<AggregatableResult> result) {}

// These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused.
//
// LINT.IfChange(AttributionResult)
enum class AttributionResult {};
// LINT.ThenChange(//tools/metrics/histograms/metadata/attribution_reporting/enums.xml:ConversionAttributionResult)

void RecordAttributionResult(AttributionResult result) {}

void RecordAttributionResult(const bool has_event_level_report,
                             const bool has_aggregatable_report) {}

}  // namespace

AttributionResolverImpl::AttributionResolverImpl(
    const base::FilePath& user_data_directory,
    std::unique_ptr<AttributionResolverDelegate> delegate)
    :{}

AttributionResolverImpl::~AttributionResolverImpl() {}

StoreSourceResult AttributionResolverImpl::StoreSource(StorableSource source) {}

CreateReportResult AttributionResolverImpl::MaybeCreateAndStoreReport(
    AttributionTrigger trigger) {}

EventLevelResult AttributionResolverImpl::MaybeCreateEventLevelReport(
    const AttributionInfo& attribution_info,
    const StoredSource& source,
    const AttributionTrigger& trigger,
    std::optional<AttributionReport>& report,
    std::optional<uint64_t>& dedup_key) {}

AggregatableResult
AttributionResolverImpl::MaybeCreateAggregatableAttributionReport(
    const AttributionInfo& attribution_info,
    const StoredSource& source,
    const AttributionTrigger& trigger,
    std::optional<AttributionReport>& report,
    std::optional<uint64_t>& dedup_key,
    std::optional<int>& max_aggregatable_reports_per_destination,
    std::optional<int64_t>& rate_limits_max_attributions) {}

bool AttributionResolverImpl::GenerateNullAggregatableReportsAndStoreReports(
    const AttributionTrigger& trigger,
    const AttributionInfo& attribution_info,
    const StoredSource* source,
    std::optional<AttributionReport>& new_aggregatable_report,
    std::optional<base::Time>& min_null_aggregatable_report_time) {}

base::Time AttributionResolverImpl::GetAggregatableReportTime(
    const AttributionTrigger& trigger,
    base::Time trigger_time) const {}

std::vector<AttributionReport> AttributionResolverImpl::GetAttributionReports(
    base::Time max_report_time,
    int limit) {}

std::optional<base::Time> AttributionResolverImpl::GetNextReportTime(
    base::Time time) {}

std::optional<AttributionReport> AttributionResolverImpl::GetReport(
    AttributionReport::Id id) {}

std::vector<StoredSource> AttributionResolverImpl::GetActiveSources(int limit) {}

std::set<AttributionDataModel::DataKey>
AttributionResolverImpl::GetAllDataKeys() {}

void AttributionResolverImpl::DeleteByDataKey(
    const AttributionDataModel::DataKey& datakey) {}

bool AttributionResolverImpl::DeleteReport(AttributionReport::Id report_id) {}

bool AttributionResolverImpl::UpdateReportForSendFailure(
    AttributionReport::Id report_id,
    base::Time new_report_time) {}

std::optional<base::Time> AttributionResolverImpl::AdjustOfflineReportTimes() {}

void AttributionResolverImpl::ClearData(
    base::Time delete_begin,
    base::Time delete_end,
    StoragePartition::StorageKeyMatcherFunction filter,
    bool delete_rate_limit_data) {}

ProcessAggregatableDebugReportResult
AttributionResolverImpl::ProcessAggregatableDebugReport(
    AggregatableDebugReport report,
    std::optional<int> remaining_budget,
    std::optional<StoredSource::Id> source_id) {}

void AttributionResolverImpl::SetDelegate(
    std::unique_ptr<AttributionResolverDelegate> delegate) {}

// Checks whether a new report is allowed to be stored for the given source
// based on `GetDefaultAttributionsPerSource()`. If there's sufficient capacity,
// the new report should be stored. Otherwise, if all existing reports were from
// an earlier window, the corresponding source is deactivated and the new
// report should be dropped. Otherwise, If there's insufficient capacity, checks
// the new report's priority against all existing ones for the same source.
// If all existing ones have greater priority, the new report should be dropped;
// otherwise, the existing one with the lowest priority is deleted and the new
// one should be stored.
AttributionResolverImpl::ReplaceReportResult
AttributionResolverImpl::MaybeReplaceLowerPriorityEventLevelReport(
    const AttributionReport& report,
    const StoredSource& source,
    int num_attributions,
    std::optional<AttributionReport>& replaced_report) {}

EventLevelResult AttributionResolverImpl::MaybeStoreEventLevelReport(
    AttributionReport& report,
    const StoredSource& source,
    std::optional<uint64_t> dedup_key,
    int num_attributions,
    std::optional<AttributionReport>& replaced_report,
    std::optional<AttributionReport>& dropped_report,
    std::optional<int>& max_event_level_reports_per_destination,
    std::optional<int64_t>& rate_limits_max_attributions) {}

}  // namespace content