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
content / browser / attribution_reporting / aggregatable_debug_report.h [blame]
// 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.
#ifndef CONTENT_BROWSER_ATTRIBUTION_REPORTING_AGGREGATABLE_DEBUG_REPORT_H_
#define CONTENT_BROWSER_ATTRIBUTION_REPORTING_AGGREGATABLE_DEBUG_REPORT_H_
#include <optional>
#include <utility>
#include <vector>
#include "base/functional/function_ref.h"
#include "base/gtest_prod_util.h"
#include "base/time/time.h"
#include "base/uuid.h"
#include "components/attribution_reporting/suitable_origin.h"
#include "content/browser/attribution_reporting/process_aggregatable_debug_report_result.mojom-forward.h"
#include "content/common/content_export.h"
#include "net/base/schemeful_site.h"
#include "third_party/abseil-cpp/absl/types/variant.h"
#include "third_party/blink/public/mojom/aggregation_service/aggregatable_report.mojom-forward.h"
class GURL;
namespace content {
class AggregatableReportRequest;
class CreateReportResult;
class StoreSourceResult;
class CONTENT_EXPORT AggregatableDebugReport {
public:
// Returns `std::nullopt` if operation is not allowed, or the source
// registration occurs within a fenced frame, or aggregatable debug
// reporting is not enabled. A report may be created with no contributions if
// there is no debug data registered for the corresponding debug type.
static std::optional<AggregatableDebugReport> Create(
base::FunctionRef<bool()> is_operation_allowed,
const StoreSourceResult&);
// Returns `std::nullopt` if operation is not allowed, or the trigger
// registration occurs within a fenced frame, or aggregatable debug
// reporting is not enabled. A report may be created with no contributions if
// there is no debug data registered for the corresponding debug type.
static std::optional<AggregatableDebugReport> Create(
base::FunctionRef<bool()> is_operation_allowed,
const CreateReportResult&);
static AggregatableDebugReport CreateForTesting(
std::vector<blink::mojom::AggregatableReportHistogramContribution>,
net::SchemefulSite context_site,
attribution_reporting::SuitableOrigin reporting_origin,
net::SchemefulSite effective_destination,
std::optional<attribution_reporting::SuitableOrigin>
aggregation_coordinator_origin,
base::Time scheduled_report_time);
AggregatableDebugReport(const AggregatableDebugReport&) = delete;
AggregatableDebugReport& operator=(const AggregatableDebugReport&) = delete;
AggregatableDebugReport(AggregatableDebugReport&&);
AggregatableDebugReport& operator=(AggregatableDebugReport&&);
~AggregatableDebugReport();
const std::vector<blink::mojom::AggregatableReportHistogramContribution>&
contributions() const {
return contributions_;
}
const attribution_reporting::SuitableOrigin& reporting_origin() const {
return reporting_origin_;
}
const net::SchemefulSite& context_site() const { return context_site_; }
base::Time scheduled_report_time() const { return scheduled_report_time_; }
void set_report_id(base::Uuid report_id) {
report_id_ = std::move(report_id);
}
int BudgetRequired() const;
net::SchemefulSite ReportingSite() const;
void ToNull();
GURL ReportUrl() const;
std::optional<AggregatableReportRequest> CreateAggregatableReportRequest()
const;
private:
FRIEND_TEST_ALL_PREFIXES(AggregatableDebugReportTest, SourceDebugReport_Data);
FRIEND_TEST_ALL_PREFIXES(AggregatableDebugReportTest,
TriggerDebugReport_Data);
AggregatableDebugReport(
std::vector<blink::mojom::AggregatableReportHistogramContribution>,
net::SchemefulSite context_site,
attribution_reporting::SuitableOrigin reporting_origin,
net::SchemefulSite effective_destination,
std::optional<attribution_reporting::SuitableOrigin>
aggregation_coordinator_origin,
base::Time scheduled_report_time);
std::vector<blink::mojom::AggregatableReportHistogramContribution>
contributions_;
net::SchemefulSite context_site_;
attribution_reporting::SuitableOrigin reporting_origin_;
net::SchemefulSite effective_destination_;
std::optional<attribution_reporting::SuitableOrigin>
aggregation_coordinator_origin_;
base::Time scheduled_report_time_;
base::Uuid report_id_;
};
struct ProcessAggregatableDebugReportResult {
AggregatableDebugReport report;
attribution_reporting::mojom::ProcessAggregatableDebugReportResult result;
};
struct SendAggregatableDebugReportResult {
struct Sent {
// If `status` is positive, it is the HTTP response code. Otherwise, it is
// the network error.
int status;
explicit Sent(int status) : status(status) {}
};
struct AssemblyFailed {};
using Result = absl::variant<Sent, AssemblyFailed>;
Result result;
};
} // namespace content
#endif // CONTENT_BROWSER_ATTRIBUTION_REPORTING_AGGREGATABLE_DEBUG_REPORT_H_