1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
|
// Copyright 2021 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_BROWSER_ATTRIBUTION_REPORTING_SQL_UTILS_H_
#define CONTENT_BROWSER_ATTRIBUTION_REPORTING_SQL_UTILS_H_
#include <stdint.h>
#include <optional>
#include <string>
#include <string_view>
#include <variant>
#include <vector>
#include "base/containers/span.h"
#include "base/types/expected.h"
#include "components/attribution_reporting/source_type.mojom-forward.h"
#include "components/attribution_reporting/trigger_data_matching.mojom-forward.h"
#include "content/browser/attribution_reporting/attribution_report.h"
#include "content/browser/attribution_reporting/stored_source.h"
#include "content/common/content_export.h"
#include "third_party/abseil-cpp/absl/numeric/int128.h"
#include "third_party/blink/public/mojom/aggregation_service/aggregatable_report.mojom-forward.h"
namespace attribution_reporting {
class AggregatableTriggerConfig;
class AggregationKeys;
class AttributionScopesData;
class EventReportWindows;
class FilterData;
class MaxEventLevelReports;
class SuitableOrigin;
class TriggerDataSet;
} // namespace attribution_reporting
namespace base {
class Time;
} // namespace base
namespace sql {
class Statement;
} // namespace sql
namespace url {
class Origin;
} // namespace url
namespace content {
namespace proto {
class AttributionReadOnlySourceData;
} // namespace proto
class StoredSource;
url::Origin DeserializeOrigin(std::string_view origin);
std::optional<attribution_reporting::mojom::SourceType> DeserializeSourceType(
int val);
std::string SerializeReadOnlySourceData(
const attribution_reporting::TriggerDataSet&,
const attribution_reporting::EventReportWindows&,
attribution_reporting::MaxEventLevelReports,
double randomized_response_rate,
attribution_reporting::mojom::TriggerDataMatching,
bool cookie_based_debug_allowed,
absl::uint128 aggregatable_debug_key_piece);
CONTENT_EXPORT std::optional<proto::AttributionReadOnlySourceData>
DeserializeReadOnlySourceDataAsProto(sql::Statement&, int col);
std::string SerializeFilterData(const attribution_reporting::FilterData&);
std::optional<attribution_reporting::FilterData> DeserializeFilterData(
sql::Statement&,
int col);
std::optional<attribution_reporting::TriggerDataSet> DeserializeTriggerDataSet(
const proto::AttributionReadOnlySourceData&,
attribution_reporting::mojom::SourceType);
std::optional<attribution_reporting::EventReportWindows>
DeserializeEventReportWindows(const proto::AttributionReadOnlySourceData&);
std::string SerializeAggregationKeys(
const attribution_reporting::AggregationKeys&);
std::optional<attribution_reporting::AggregationKeys>
DeserializeAggregationKeys(sql::Statement&, int col);
CONTENT_EXPORT std::string SerializeEventLevelReportMetadata(
uint32_t trigger_data,
int64_t priority);
std::string SerializeAggregatableReportMetadata(
const std::optional<attribution_reporting::SuitableOrigin>&
aggregation_coordinator_origin,
const attribution_reporting::AggregatableTriggerConfig&,
const std::vector<blink::mojom::AggregatableReportHistogramContribution>&);
std::string SerializeNullAggregatableReportMetadata(
const std::optional<attribution_reporting::SuitableOrigin>&
aggregation_coordinator_origin,
const attribution_reporting::AggregatableTriggerConfig&,
base::Time fake_source_time);
std::optional<int64_t> DeserializeEventLevelPriority(base::span<const uint8_t>);
std::optional<AttributionReport::EventLevelData>
DeserializeEventLevelReportMetadata(base::span<const uint8_t>,
const StoredSource&);
std::optional<AttributionReport::AggregatableData>
DeserializeAggregatableReportMetadata(base::span<const uint8_t>,
const StoredSource&);
std::optional<AttributionReport::AggregatableData>
DeserializeNullAggregatableReportMetadata(base::span<const uint8_t>);
std::string SerializeAttributionScopesData(
const attribution_reporting::AttributionScopesData&);
base::expected<std::optional<attribution_reporting::AttributionScopesData>,
std::monostate>
DeserializeAttributionScopesData(sql::Statement&, int col);
std::string SerializeAggregatableNamedBudgets(
const StoredSource::AggregatableNamedBudgets&);
std::optional<StoredSource::AggregatableNamedBudgets>
DeserializeAggregatableNamedBudgets(sql::Statement& stmt, int col);
void DeduplicateSourceIds(std::vector<StoredSource::Id>&);
} // namespace content
#endif // CONTENT_BROWSER_ATTRIBUTION_REPORTING_SQL_UTILS_H_
|