Upload upstream chromium 114.0.5735.31
[platform/framework/web/chromium-efl.git] / cc / benchmarks / micro_benchmark.h
1 // Copyright 2013 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 CC_BENCHMARKS_MICRO_BENCHMARK_H_
6 #define CC_BENCHMARKS_MICRO_BENCHMARK_H_
7
8 #include <memory>
9
10 #include "base/functional/callback.h"
11 #include "base/values.h"
12 #include "cc/cc_export.h"
13
14 namespace base {
15 class SingleThreadTaskRunner;
16 }  // namespace base
17
18 namespace cc {
19 class LayerTreeHost;
20 class PictureLayer;
21 class MicroBenchmarkImpl;
22
23 class CC_EXPORT MicroBenchmark {
24  public:
25   using DoneCallback = base::OnceCallback<void(base::Value::Dict)>;
26
27   explicit MicroBenchmark(DoneCallback callback);
28   virtual ~MicroBenchmark();
29
30   bool IsDone() const;
31   virtual void DidUpdateLayers(LayerTreeHost* layer_tree_host);
32   int id() const { return id_; }
33   void set_id(int id) { id_ = id; }
34
35   virtual void RunOnLayer(PictureLayer* layer);
36
37   virtual bool ProcessMessage(base::Value::Dict message);
38
39   bool ProcessedForBenchmarkImpl() const;
40   std::unique_ptr<MicroBenchmarkImpl> GetBenchmarkImpl(
41       scoped_refptr<base::SingleThreadTaskRunner> origin_task_runner);
42
43  protected:
44   void NotifyDone(base::Value::Dict result);
45
46   virtual std::unique_ptr<MicroBenchmarkImpl> CreateBenchmarkImpl(
47       scoped_refptr<base::SingleThreadTaskRunner> origin_task_runner);
48
49  private:
50   DoneCallback callback_;
51   bool is_done_ = false;
52   bool processed_for_benchmark_impl_ = false;
53   int id_ = 0;
54 };
55
56 }  // namespace cc
57
58 #endif  // CC_BENCHMARKS_MICRO_BENCHMARK_H_