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
|
// 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 <string>
#include <utility>
#include <variant>
#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"
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 {};
struct InsufficientNamedBudget {
std::string name;
int budget;
InsufficientNamedBudget(std::string name, int64_t budget)
: name(std::move(name)), budget(budget) {}
};
using EventLevel = std::variant<EventLevelSuccess,
InternalError,
NoCapacityForConversionDestination,
NoMatchingImpressions,
Deduplicated,
ExcessiveAttributions,
PriorityTooLow,
NeverAttributedSource,
ExcessiveReportingOrigins,
NoMatchingSourceFilterData,
ProhibitedByBrowserPolicy,
NoMatchingConfigurations,
ExcessiveEventLevelReports,
FalselyAttributedSource,
ReportWindowPassed,
NotRegistered,
ReportWindowNotStarted,
NoMatchingTriggerData>;
using Aggregatable = std::variant<AggregatableSuccess,
InternalError,
NoCapacityForConversionDestination,
NoMatchingImpressions,
ExcessiveAttributions,
ExcessiveReportingOrigins,
NoHistograms,
InsufficientBudget,
InsufficientNamedBudget,
NoMatchingSourceFilterData,
NotRegistered,
ProhibitedByBrowserPolicy,
Deduplicated,
ReportWindowPassed,
ExcessiveAggregatableReports>;
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_
|