#include "content/browser/attribution_reporting/sql_utils.h"
#include <stdint.h>
#include <iterator>
#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/containers/flat_set.h"
#include "base/containers/span.h"
#include "base/numerics/safe_conversions.h"
#include "base/time/time.h"
#include "base/types/expected.h"
#include "components/attribution_reporting/aggregatable_filtering_id_max_bytes.h"
#include "components/attribution_reporting/aggregatable_trigger_config.h"
#include "components/attribution_reporting/aggregation_keys.h"
#include "components/attribution_reporting/attribution_scopes_data.h"
#include "components/attribution_reporting/constants.h"
#include "components/attribution_reporting/event_report_windows.h"
#include "components/attribution_reporting/filters.h"
#include "components/attribution_reporting/max_event_level_reports.h"
#include "components/attribution_reporting/source_registration_time_config.mojom.h"
#include "components/attribution_reporting/source_type.mojom.h"
#include "components/attribution_reporting/suitable_origin.h"
#include "components/attribution_reporting/trigger_config.h"
#include "components/attribution_reporting/trigger_data_matching.mojom.h"
#include "content/browser/attribution_reporting/attribution_report.h"
#include "content/browser/attribution_reporting/attribution_reporting.pb.h"
#include "sql/statement.h"
#include "third_party/abseil-cpp/absl/numeric/int128.h"
#include "third_party/abseil-cpp/absl/types/variant.h"
#include "url/gurl.h"
#include "url/origin.h"
namespace content {
namespace {
AggregatableTriggerConfig;
EventReportWindows;
SuitableOrigin;
TriggerSpec;
TriggerSpecs;
SourceRegistrationTimeConfig;
SourceType;
TriggerDataMatching;
bool IsValid(const proto::AttributionAggregationKey& key) { … }
void SerializeCommonAggregatableData(
proto::AttributionCommonAggregatableMetadata& msg,
const std::optional<SuitableOrigin>& aggregation_coordinator_origin,
const AggregatableTriggerConfig& trigger_config) { … }
std::optional<AttributionReport::CommonAggregatableData>
DeserializeCommonAggregatableData(
const proto::AttributionCommonAggregatableMetadata& msg) { … }
}
url::Origin DeserializeOrigin(const std::string& origin) { … }
std::optional<SourceType> DeserializeSourceType(int val) { … }
void SetReadOnlySourceData(
const EventReportWindows* event_report_windows,
attribution_reporting::MaxEventLevelReports max_event_level_reports,
proto::AttributionReadOnlySourceData& msg) { … }
std::string SerializeReadOnlySourceData(
const attribution_reporting::TriggerSpecs& trigger_specs,
double randomized_response_rate,
TriggerDataMatching trigger_data_matching,
bool debug_cookie_set,
absl::uint128 aggregatable_debug_key_piece) { … }
std::optional<proto::AttributionReadOnlySourceData>
DeserializeReadOnlySourceDataAsProto(sql::Statement& stmt, int col) { … }
std::string SerializeFilterData(
const attribution_reporting::FilterData& filter_data) { … }
std::optional<attribution_reporting::FilterData> DeserializeFilterData(
sql::Statement& stmt,
int col) { … }
std::string SerializeAggregationKeys(
const attribution_reporting::AggregationKeys& keys) { … }
std::optional<attribution_reporting::AggregationKeys>
DeserializeAggregationKeys(sql::Statement& stmt, int col) { … }
std::string SerializeEventLevelReportMetadata(uint32_t trigger_data,
int64_t priority) { … }
std::optional<AttributionReport::EventLevelData>
DeserializeEventLevelReportMetadata(base::span<const uint8_t> blob,
const StoredSource& source) { … }
std::optional<int64_t> DeserializeEventLevelPriority(
base::span<const uint8_t> blob) { … }
std::string SerializeAggregatableReportMetadata(
const std::optional<SuitableOrigin>& aggregation_coordinator_origin,
const AggregatableTriggerConfig& trigger_config,
const std::vector<blink::mojom::AggregatableReportHistogramContribution>&
contributions) { … }
std::optional<AttributionReport::AggregatableAttributionData>
DeserializeAggregatableReportMetadata(base::span<const uint8_t> blob,
const StoredSource& source) { … }
std::string SerializeNullAggregatableReportMetadata(
const std::optional<SuitableOrigin>& aggregation_coordinator_origin,
const AggregatableTriggerConfig& trigger_config,
base::Time fake_source_time) { … }
std::optional<AttributionReport::NullAggregatableData>
DeserializeNullAggregatableReportMetadata(base::span<const uint8_t> blob) { … }
std::optional<TriggerSpecs> DeserializeTriggerSpecs(
const proto::AttributionReadOnlySourceData& msg,
SourceType source_type,
attribution_reporting::MaxEventLevelReports max_event_level_reports) { … }
std::string SerializeAttributionScopesData(
const attribution_reporting::AttributionScopesData& scopes_data) { … }
base::expected<std::optional<attribution_reporting::AttributionScopesData>,
absl::monostate>
DeserializeAttributionScopesData(sql::Statement& stmt, int col) { … }
}