Fix FullScreen crash in Webapp
[platform/framework/web/chromium-efl.git] / cc / benchmarks / micro_benchmark_controller.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_CONTROLLER_H_
6 #define CC_BENCHMARKS_MICRO_BENCHMARK_CONTROLLER_H_
7
8 #include <memory>
9 #include <string>
10 #include <vector>
11
12 #include "base/functional/callback.h"
13 #include "base/memory/raw_ptr.h"
14 #include "cc/benchmarks/micro_benchmark.h"
15
16 namespace base {
17 class SingleThreadTaskRunner;
18 class Value;
19 }  // namespace base
20
21 namespace cc {
22
23 class LayerTreeHost;
24
25 class CC_EXPORT MicroBenchmarkController {
26  public:
27   explicit MicroBenchmarkController(LayerTreeHost* host);
28   MicroBenchmarkController(const MicroBenchmarkController&) = delete;
29   ~MicroBenchmarkController();
30
31   MicroBenchmarkController& operator=(const MicroBenchmarkController&) = delete;
32
33   void DidUpdateLayers();
34
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);
39
40   // Returns true if the message was successfully delivered and handled.
41   bool SendMessage(int id, base::Value::Dict message);
42
43   std::vector<std::unique_ptr<MicroBenchmarkImpl>> CreateImplBenchmarks() const;
44
45  private:
46   void CleanUpFinishedBenchmarks();
47   int GetNextIdAndIncrement();
48
49   raw_ptr<LayerTreeHost> host_;
50   std::vector<std::unique_ptr<MicroBenchmark>> benchmarks_;
51   static int next_id_;
52   scoped_refptr<base::SingleThreadTaskRunner> main_controller_task_runner_;
53 };
54
55 }  // namespace cc
56
57 #endif  // CC_BENCHMARKS_MICRO_BENCHMARK_CONTROLLER_H_