1 // Copyright 2023 The Chromium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef COMPONENTS_METRICS_STRUCTURED_STRUCTURED_METRICS_SCHEDULER_H_ 6 #define COMPONENTS_METRICS_STRUCTURED_STRUCTURED_METRICS_SCHEDULER_H_ 7 8 #include "base/time/time.h" 9 #include "components/metrics/metrics_rotation_scheduler.h" 10 11 namespace metrics::structured { 12 13 // Schedulers a periodic rotation of logs and initiates a log upload to the 14 // reporting service. 15 class StructuredMetricsScheduler : public metrics::MetricsRotationScheduler { 16 public: 17 // Creates StructuredMetricsScheduler object with the given 18 // |rotation_callback| callback to call when log rotation should happen and 19 // |interval_callback| to determine the interval between rotations in steady 20 // state. 21 StructuredMetricsScheduler( 22 const base::RepeatingClosure& rotation_callback, 23 const base::RepeatingCallback<base::TimeDelta(void)>& interval_callback, 24 bool fast_startup_for_testing); 25 26 StructuredMetricsScheduler(const StructuredMetricsScheduler&) = delete; 27 StructuredMetricsScheduler& operator=(const StructuredMetricsScheduler&) = 28 delete; 29 30 ~StructuredMetricsScheduler() override; 31 32 protected: 33 void LogMetricsInitSequence(InitSequence sequence) override; 34 }; 35 } // namespace metrics::structured 36 37 #endif // COMPONENTS_METRICS_STRUCTURED_STRUCTURED_METRICS_SCHEDULER_H_ 38