#include "components/attribution_reporting/event_report_windows.h"
#include <stddef.h>
#include <functional>
#include <iterator>
#include <optional>
#include <utility>
#include <vector>
#include "base/check.h"
#include "base/check_op.h"
#include "base/containers/flat_set.h"
#include "base/metrics/histogram_functions.h"
#include "base/ranges/algorithm.h"
#include "base/time/time.h"
#include "base/types/expected.h"
#include "base/types/expected_macros.h"
#include "base/values.h"
#include "components/attribution_reporting/constants.h"
#include "components/attribution_reporting/parsing_utils.h"
#include "components/attribution_reporting/source_registration_error.mojom-shared.h"
#include "components/attribution_reporting/source_type.mojom-shared.h"
namespace attribution_reporting {
namespace {
SourceRegistrationError;
SourceType;
bool IsValid(base::TimeDelta start_time,
const base::flat_set<base::TimeDelta>& end_times) { … }
bool IsReportWindowValid(base::TimeDelta report_window) { … }
bool IsStrictlyIncreasing(const std::vector<base::TimeDelta>& end_times) { … }
base::Time ReportTimeFromDeadline(base::Time source_time,
base::TimeDelta deadline) { … }
}
std::optional<EventReportWindows> EventReportWindows::FromDefaults(
base::TimeDelta report_window,
SourceType source_type) { … }
std::optional<EventReportWindows> EventReportWindows::Create(
base::TimeDelta start_time,
std::vector<base::TimeDelta> end_times) { … }
EventReportWindows::EventReportWindows(
base::TimeDelta start_time,
base::flat_set<base::TimeDelta> end_times)
: … { … }
EventReportWindows::EventReportWindows(base::TimeDelta report_window,
SourceType source_type) { … }
EventReportWindows::EventReportWindows()
: … { … }
EventReportWindows::~EventReportWindows() = default;
EventReportWindows::EventReportWindows(const EventReportWindows&) = default;
EventReportWindows& EventReportWindows::operator=(const EventReportWindows&) =
default;
EventReportWindows::EventReportWindows(EventReportWindows&&) = default;
EventReportWindows& EventReportWindows::operator=(EventReportWindows&&) =
default;
base::Time EventReportWindows::ComputeReportTime(
base::Time source_time,
base::Time trigger_time) const { … }
base::Time EventReportWindows::ReportTimeAtWindow(base::Time source_time,
int window_index) const { … }
base::Time EventReportWindows::StartTimeAtWindow(base::Time source_time,
int window_index) const { … }
EventReportWindows::WindowResult EventReportWindows::FallsWithin(
base::TimeDelta trigger_moment) const { … }
base::expected<EventReportWindows, SourceRegistrationError>
EventReportWindows::FromJSON(const base::Value::Dict& registration,
base::TimeDelta expiry,
SourceType source_type) { … }
base::expected<EventReportWindows, SourceRegistrationError>
EventReportWindows::ParseWindows(const base::Value::Dict& dict,
base::TimeDelta expiry,
const EventReportWindows& default_if_absent) { … }
base::expected<EventReportWindows, SourceRegistrationError>
EventReportWindows::ParseWindowsJSON(const base::Value& v,
base::TimeDelta expiry) { … }
void EventReportWindows::Serialize(base::Value::Dict& dict) const { … }
bool EventReportWindows::IsValidForExpiry(base::TimeDelta expiry) const { … }
}