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
|
// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_ATTRIBUTION_REPORTING_AGGREGATABLE_TRIGGER_CONFIG_H_
#define COMPONENTS_ATTRIBUTION_REPORTING_AGGREGATABLE_TRIGGER_CONFIG_H_
#include <optional>
#include <string>
#include "base/component_export.h"
#include "base/types/expected.h"
#include "components/attribution_reporting/aggregatable_filtering_id_max_bytes.h"
#include "components/attribution_reporting/source_registration_time_config.mojom.h"
#include "components/attribution_reporting/trigger_registration_error.mojom-forward.h"
namespace base {
class DictValue;
} // namespace base
namespace attribution_reporting {
class COMPONENT_EXPORT(ATTRIBUTION_REPORTING) AggregatableTriggerConfig {
public:
static base::expected<AggregatableTriggerConfig,
mojom::TriggerRegistrationError>
Parse(base::DictValue&);
static std::optional<AggregatableTriggerConfig> Create(
mojom::SourceRegistrationTimeConfig,
std::optional<std::string> trigger_context_id,
AggregatableFilteringIdsMaxBytes);
AggregatableTriggerConfig();
AggregatableTriggerConfig(const AggregatableTriggerConfig&);
AggregatableTriggerConfig& operator=(const AggregatableTriggerConfig&);
AggregatableTriggerConfig(AggregatableTriggerConfig&&);
AggregatableTriggerConfig& operator=(AggregatableTriggerConfig&&);
~AggregatableTriggerConfig();
friend bool operator==(const AggregatableTriggerConfig&,
const AggregatableTriggerConfig&) = default;
void Serialize(base::DictValue&) const;
// Returns true when this config requires that a report be sent
// unconditionally, i.e., if there is no report created a null report should
// be sent.
// https://wicg.github.io/attribution-reporting-api/#should-send-a-report-unconditionally
bool ShouldCauseAReportToBeSentUnconditionally() const;
mojom::SourceRegistrationTimeConfig source_registration_time_config() const {
return source_registration_time_config_;
}
const std::optional<std::string>& trigger_context_id() const {
return trigger_context_id_;
}
AggregatableFilteringIdsMaxBytes aggregatable_filtering_id_max_bytes() const {
return aggregatable_filtering_id_max_bytes_;
}
private:
AggregatableTriggerConfig(mojom::SourceRegistrationTimeConfig,
std::optional<std::string> trigger_context_id,
AggregatableFilteringIdsMaxBytes);
mojom::SourceRegistrationTimeConfig source_registration_time_config_ =
mojom::SourceRegistrationTimeConfig::kExclude;
std::optional<std::string> trigger_context_id_;
AggregatableFilteringIdsMaxBytes aggregatable_filtering_id_max_bytes_;
};
} // namespace attribution_reporting
#endif // COMPONENTS_ATTRIBUTION_REPORTING_AGGREGATABLE_TRIGGER_CONFIG_H_
|