#include "content/browser/aggregation_service/aggregatable_report_scheduler.h"
#include <memory>
#include <optional>
#include <utility>
#include <vector>
#include "base/check.h"
#include "base/check_op.h"
#include "base/command_line.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/memory/ptr_util.h"
#include "base/memory/weak_ptr.h"
#include "base/metrics/histogram_functions.h"
#include "base/threading/sequence_bound.h"
#include "base/time/time.h"
#include "base/timer/elapsed_timer.h"
#include "content/browser/aggregation_service/aggregatable_report.h"
#include "content/browser/aggregation_service/aggregation_service.h"
#include "content/browser/aggregation_service/aggregation_service_storage.h"
#include "content/browser/aggregation_service/aggregation_service_storage_context.h"
#include "content/public/common/content_switches.h"
namespace content {
AggregatableReportScheduler::AggregatableReportScheduler(
AggregationServiceStorageContext* storage_context,
base::RepeatingCallback<
void(std::vector<AggregationServiceStorage::RequestAndId>)>
on_scheduled_report_time_reached)
: … { … }
AggregatableReportScheduler::~AggregatableReportScheduler() { … }
void AggregatableReportScheduler::ScheduleRequest(
AggregatableReportRequest request) { … }
void AggregatableReportScheduler::NotifyInProgressRequestSucceeded(
AggregationServiceStorage::RequestId request_id) { … }
bool AggregatableReportScheduler::NotifyInProgressRequestFailed(
AggregationServiceStorage::RequestId request_id,
int previous_failed_attempts) { … }
std::optional<base::TimeDelta>
AggregatableReportScheduler::GetFailedReportDelay(int failed_send_attempts) { … }
AggregatableReportScheduler::TimerDelegate::TimerDelegate(
AggregationServiceStorageContext* storage_context,
base::RepeatingCallback<
void(std::vector<AggregationServiceStorage::RequestAndId>)>
on_scheduled_report_time_reached)
: … { … }
AggregatableReportScheduler::TimerDelegate::~TimerDelegate() = default;
void AggregatableReportScheduler::TimerDelegate::GetNextReportTime(
base::OnceCallback<void(std::optional<base::Time>)> callback,
base::Time now) { … }
void AggregatableReportScheduler::TimerDelegate::OnReportingTimeReached(
base::Time now,
base::Time timer_desired_run_time) { … }
void AggregatableReportScheduler::TimerDelegate::AdjustOfflineReportTimes(
base::OnceCallback<void(std::optional<base::Time>)> maybe_set_timer_cb) { … }
void AggregatableReportScheduler::TimerDelegate::NotifySendAttemptCompleted(
AggregationServiceStorage::RequestId request_id) { … }
void AggregatableReportScheduler::TimerDelegate::OnRequestsReturnedFromStorage(
base::ElapsedTimer task_timer,
std::vector<AggregationServiceStorage::RequestAndId> requests_and_ids) { … }
}