[M73 Dev][EFL] Disable VizDisplayCompositor for EFL port
[platform/framework/web/chromium-efl.git] / components / scheduling_metrics / thread_metrics.h
1 // Copyright 2018 The Chromium Authors. All rights reserved.
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_SCHEDULING_METRICS_THREAD_METRICS_H_
6 #define COMPONENTS_SCHEDULING_METRICS_THREAD_METRICS_H_
7
8 #include "base/component_export.h"
9 #include "base/optional.h"
10 #include "base/task/sequence_manager/task_queue.h"
11 #include "base/time/time.h"
12 #include "components/scheduling_metrics/task_duration_metric_reporter.h"
13 #include "components/scheduling_metrics/thread_type.h"
14 #include "components/scheduling_metrics/total_duration_metric_reporter.h"
15
16 namespace scheduling_metrics {
17
18 // Helper class to take care of task metrics shared between different threads
19 // in Chrome, including but not limited to browser UI and IO threads, renderer
20 // main thread and blink worker threads.
21 //
22 class COMPONENT_EXPORT(SCHEDULING_METRICS) ThreadMetrics {
23  public:
24   ThreadMetrics(ThreadType thread_type, bool has_cpu_timing_for_each_task);
25   ~ThreadMetrics();
26
27   bool ShouldDiscardTask(
28       base::sequence_manager::TaskQueue* queue,
29       const base::sequence_manager::Task& task,
30       const base::sequence_manager::TaskQueue::TaskTiming& task_timing);
31
32   // Record task metrics which are shared between threads.
33   void RecordTaskMetrics(
34       base::sequence_manager::TaskQueue* queue,
35       const base::sequence_manager::Task& task,
36       const base::sequence_manager::TaskQueue::TaskTiming& task_timing);
37
38  protected:
39   const ThreadType thread_type_;
40   const bool has_cpu_timing_for_each_task_;
41
42  private:
43   base::ThreadTicks last_known_time_;
44
45   TaskDurationMetricReporter<ThreadType> thread_task_duration_reporter_;
46   TaskDurationMetricReporter<ThreadType> thread_task_cpu_duration_reporter_;
47   TaskDurationMetricReporter<ThreadType> tracked_cpu_duration_reporter_;
48   TaskDurationMetricReporter<ThreadType> non_tracked_cpu_duration_reporter_;
49
50   DISALLOW_COPY_AND_ASSIGN(ThreadMetrics);
51 };
52
53 }  // namespace scheduling_metrics
54
55 #endif  // COMPONENTS_SCHEDULING_METRICS_THREAD_METRICS_H_