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.
5 #ifndef CC_BENCHMARKS_MICRO_BENCHMARK_CONTROLLER_H_
6 #define CC_BENCHMARKS_MICRO_BENCHMARK_CONTROLLER_H_
12 #include "base/functional/callback.h"
13 #include "base/memory/raw_ptr.h"
14 #include "cc/benchmarks/micro_benchmark.h"
17 class SingleThreadTaskRunner;
25 class CC_EXPORT MicroBenchmarkController {
27 explicit MicroBenchmarkController(LayerTreeHost* host);
28 MicroBenchmarkController(const MicroBenchmarkController&) = delete;
29 ~MicroBenchmarkController();
31 MicroBenchmarkController& operator=(const MicroBenchmarkController&) = delete;
33 void DidUpdateLayers();
35 // Returns the id of the benchmark on success, 0 otherwise.
36 int ScheduleRun(const std::string& micro_benchmark_name,
37 base::Value::Dict settings,
38 MicroBenchmark::DoneCallback callback);
40 // Returns true if the message was successfully delivered and handled.
41 bool SendMessage(int id, base::Value::Dict message);
43 std::vector<std::unique_ptr<MicroBenchmarkImpl>> CreateImplBenchmarks() const;
46 void CleanUpFinishedBenchmarks();
47 int GetNextIdAndIncrement();
49 raw_ptr<LayerTreeHost> host_;
50 std::vector<std::unique_ptr<MicroBenchmark>> benchmarks_;
52 scoped_refptr<base::SingleThreadTaskRunner> main_controller_task_runner_;
57 #endif // CC_BENCHMARKS_MICRO_BENCHMARK_CONTROLLER_H_