Roll src/third_party/WebKit d9c6159:8139f33 (svn 201974:201975)
[chromium-blink-merge.git] / cc / debug / micro_benchmark_controller.h
blob198e203fa2fa0d9ceb5b085654bfc41744d28683
1 // Copyright 2013 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.
5 #ifndef CC_DEBUG_MICRO_BENCHMARK_CONTROLLER_H_
6 #define CC_DEBUG_MICRO_BENCHMARK_CONTROLLER_H_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "base/callback.h"
12 #include "cc/base/scoped_ptr_vector.h"
13 #include "cc/debug/micro_benchmark.h"
15 namespace base {
16 class SingleThreadTaskRunner;
17 class Value;
18 } // namespace base
20 namespace cc {
22 class LayerTreeHost;
23 class LayerTreeHostImpl;
24 class CC_EXPORT MicroBenchmarkController {
25 public:
26 explicit MicroBenchmarkController(LayerTreeHost* host);
27 ~MicroBenchmarkController();
29 void DidUpdateLayers();
31 // Returns the id of the benchmark on success, 0 otherwise.
32 int ScheduleRun(const std::string& micro_benchmark_name,
33 scoped_ptr<base::Value> value,
34 const MicroBenchmark::DoneCallback& callback);
35 // Returns true if the message was successfully delivered and handled.
36 bool SendMessage(int id, scoped_ptr<base::Value> value);
38 void ScheduleImplBenchmarks(LayerTreeHostImpl* host_impl);
40 private:
41 void CleanUpFinishedBenchmarks();
42 int GetNextIdAndIncrement();
44 LayerTreeHost* host_;
45 ScopedPtrVector<MicroBenchmark> benchmarks_;
46 static int next_id_;
47 scoped_refptr<base::SingleThreadTaskRunner> main_controller_task_runner_;
49 DISALLOW_COPY_AND_ASSIGN(MicroBenchmarkController);
52 } // namespace cc
54 #endif // CC_DEBUG_MICRO_BENCHMARK_CONTROLLER_H_