[M120 Migration][VD] Enable direct rendering for TVPlus
[platform/framework/web/chromium-efl.git] / components / metrics / metrics_rotation_scheduler.h
1 // Copyright 2017 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_METRICS_ROTATION_SCHEDULER_H_
6 #define COMPONENTS_METRICS_METRICS_ROTATION_SCHEDULER_H_
7
8 #include "base/functional/callback.h"
9 #include "base/time/time.h"
10 #include "components/metrics/metrics_scheduler.h"
11
12 namespace metrics {
13
14 // Scheduler task to drive a MetricsService object's uploading.
15 class MetricsRotationScheduler : public MetricsScheduler {
16  public:
17   // Creates MetricsRotationScheduler object with the given |rotation_callback|
18   // callback to call when log rotation should happen and |interval_callback|
19   // to determine the interval between rotations in steady state.
20   // |rotation_callback| must arrange to call RotationFinished on completion.
21   MetricsRotationScheduler(
22       const base::RepeatingClosure& rotation_callback,
23       const base::RepeatingCallback<base::TimeDelta(void)>& interval_callback,
24       bool fast_startup_for_testing);
25
26   MetricsRotationScheduler(const MetricsRotationScheduler&) = delete;
27   MetricsRotationScheduler& operator=(const MetricsRotationScheduler&) = delete;
28
29   ~MetricsRotationScheduler() override;
30
31   // Callback from MetricsService when the startup init task has completed.
32   void InitTaskComplete();
33
34   // Callback from MetricsService when a triggered rotation finishes.
35   void RotationFinished();
36
37  protected:
38   enum InitSequence {
39     TIMER_FIRED_FIRST,
40     INIT_TASK_COMPLETED_FIRST,
41     INIT_SEQUENCE_ENUM_SIZE,
42   };
43
44  private:
45   // Record the init sequence order histogram.
46   virtual void LogMetricsInitSequence(InitSequence sequence);
47
48   // MetricsScheduler:
49   void TriggerTask() override;
50
51   // Whether the InitTaskComplete() callback has been called.
52   bool init_task_complete_;
53
54   // Whether the initial scheduled upload timer has fired before the init task
55   // has been completed.
56   bool waiting_for_init_task_complete_;
57
58   // Callback function used to get the standard upload time.
59   base::RepeatingCallback<base::TimeDelta(void)> upload_interval_callback_;
60 };
61
62 }  // namespace metrics
63
64 #endif  // COMPONENTS_METRICS_METRICS_ROTATION_SCHEDULER_H_