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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
content / browser / attribution_reporting / create_report_result.h [blame]
// Copyright 2022 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_CREATE_REPORT_RESULT_H_
#define CONTENT_BROWSER_ATTRIBUTION_REPORTING_CREATE_REPORT_RESULT_H_
#include <stdint.h>
#include <optional>
#include "base/time/time.h"
#include "content/browser/attribution_reporting/attribution_report.h"
#include "content/browser/attribution_reporting/attribution_trigger.h"
#include "content/browser/attribution_reporting/stored_source.h"
#include "content/common/content_export.h"
#include "third_party/abseil-cpp/absl/types/variant.h"
namespace content {
class CONTENT_EXPORT CreateReportResult {
public:
struct CONTENT_EXPORT EventLevelSuccess {
AttributionReport new_report;
std::optional<AttributionReport> replaced_report;
EventLevelSuccess(AttributionReport new_report,
std::optional<AttributionReport> replaced_report);
~EventLevelSuccess();
EventLevelSuccess(const EventLevelSuccess&);
EventLevelSuccess& operator=(const EventLevelSuccess&);
EventLevelSuccess(EventLevelSuccess&&);
EventLevelSuccess& operator=(EventLevelSuccess&&);
};
struct InternalError {};
struct NoCapacityForConversionDestination {
int max;
explicit NoCapacityForConversionDestination(int max) : max(max) {}
};
struct NoMatchingImpressions {};
struct Deduplicated {};
struct ExcessiveAttributions {
int64_t max;
explicit ExcessiveAttributions(int64_t max) : max(max) {}
};
struct PriorityTooLow {
AttributionReport dropped_report;
};
struct NeverAttributedSource {};
struct ExcessiveReportingOrigins {
int64_t max;
explicit ExcessiveReportingOrigins(int64_t max) : max(max) {}
};
struct NoMatchingSourceFilterData {};
struct ProhibitedByBrowserPolicy {};
struct NoMatchingConfigurations {};
struct ExcessiveEventLevelReports {
AttributionReport dropped_report;
};
struct FalselyAttributedSource {};
struct ReportWindowPassed {};
struct NotRegistered {};
struct ReportWindowNotStarted {};
struct NoMatchingTriggerData {};
struct AggregatableSuccess {
AttributionReport new_report;
};
struct ExcessiveAggregatableReports {
int max;
explicit ExcessiveAggregatableReports(int max) : max(max) {}
};
struct NoHistograms {};
struct InsufficientBudget {};
using EventLevel = absl::variant<EventLevelSuccess,
InternalError,
NoCapacityForConversionDestination,
NoMatchingImpressions,
Deduplicated,
ExcessiveAttributions,
PriorityTooLow,
NeverAttributedSource,
ExcessiveReportingOrigins,
NoMatchingSourceFilterData,
ProhibitedByBrowserPolicy,
NoMatchingConfigurations,
ExcessiveEventLevelReports,
FalselyAttributedSource,
ReportWindowPassed,
NotRegistered,
ReportWindowNotStarted,
NoMatchingTriggerData>;
using Aggregatable = absl::variant<AggregatableSuccess,
InternalError,
NoCapacityForConversionDestination,
NoMatchingImpressions,
ExcessiveAttributions,
ExcessiveReportingOrigins,
NoHistograms,
InsufficientBudget,
NoMatchingSourceFilterData,
NotRegistered,
ProhibitedByBrowserPolicy,
Deduplicated,
ReportWindowPassed,
ExcessiveAggregatableReports>;
// TODO(apaseltiner): Remove this struct in favor of moving the individual
// fields into the variant structs.
struct Limits {
// `std::nullopt` unless `event_level_status_` or `aggregatable_status_` is
// `kExcessiveAttributions`.
std::optional<int64_t> rate_limits_max_attributions;
// `std::nullopt` unless `event_level_status_` or `aggregatable_status_` is
// `kExcessiveReportingOrigins`.
std::optional<int64_t> rate_limits_max_attribution_reporting_origins;
// `std::nullopt` unless `event_level_status_` is
// `kNoCapacityForConversionDestination`.
std::optional<int> max_event_level_reports_per_destination;
// `std::nullopt` unless `aggregatable_status_` is
// `kNoCapacityForConversionDestination`.
std::optional<int> max_aggregatable_reports_per_destination;
// `std::nullopt` unless `aggregatable_status_` is
// `kExcessiveReports`..
std::optional<int> max_aggregatable_reports_per_source;
};
// TODO(apaseltiner): Remove this constructor.
CreateReportResult(
base::Time trigger_time,
AttributionTrigger,
AttributionTrigger::EventLevelResult event_level_status,
AttributionTrigger::AggregatableResult aggregatable_status,
std::optional<AttributionReport> replaced_event_level_report =
std::nullopt,
std::optional<AttributionReport> new_event_level_report = std::nullopt,
std::optional<AttributionReport> new_aggregatable_report = std::nullopt,
std::optional<StoredSource> source = std::nullopt,
Limits limits = Limits(),
std::optional<AttributionReport> dropped_event_level_report =
std::nullopt,
std::optional<base::Time> min_null_aggregatable_report_time =
std::nullopt);
CreateReportResult(
base::Time trigger_time,
AttributionTrigger,
EventLevel,
Aggregatable,
std::optional<StoredSource> source,
std::optional<base::Time> min_null_aggregatable_report_time);
~CreateReportResult();
CreateReportResult(const CreateReportResult&);
CreateReportResult(CreateReportResult&&);
CreateReportResult& operator=(const CreateReportResult&);
CreateReportResult& operator=(CreateReportResult&&);
base::Time trigger_time() const { return trigger_time_; }
AttributionTrigger::EventLevelResult event_level_status() const;
const EventLevel& event_level_result() const { return event_level_result_; }
AttributionTrigger::AggregatableResult aggregatable_status() const;
const Aggregatable& aggregatable_result() const {
return aggregatable_result_;
}
const AttributionReport* replaced_event_level_report() const;
const AttributionReport* new_event_level_report() const;
AttributionReport* new_event_level_report();
const AttributionReport* new_aggregatable_report() const;
AttributionReport* new_aggregatable_report();
const std::optional<StoredSource>& source() const { return source_; }
const AttributionReport* dropped_event_level_report() const;
std::optional<base::Time> min_null_aggregatable_report_time() const {
return min_null_aggregatable_report_time_;
}
const AttributionTrigger& trigger() const { return trigger_; }
private:
base::Time trigger_time_;
// `std::nullopt` if there's no matching source.
// TODO(apaseltiner): Combine this field with the result fields below.
std::optional<StoredSource> source_;
std::optional<base::Time> min_null_aggregatable_report_time_;
EventLevel event_level_result_;
Aggregatable aggregatable_result_;
AttributionTrigger trigger_;
};
} // namespace content
#endif // CONTENT_BROWSER_ATTRIBUTION_REPORTING_CREATE_REPORT_RESULT_H_