Index: cc/debug/micro_benchmark_controller.cc |
diff --git a/cc/debug/micro_benchmark_controller.cc b/cc/debug/micro_benchmark_controller.cc |
index 7d9025c1c42103dc40f9499fc2b467ca8b827460..fbc0b1950033bdb085dd0ece3b71f07f747bb3c9 100644 |
--- a/cc/debug/micro_benchmark_controller.cc |
+++ b/cc/debug/micro_benchmark_controller.cc |
@@ -22,16 +22,17 @@ namespace { |
scoped_ptr<MicroBenchmark> CreateBenchmark( |
const std::string& name, |
scoped_ptr<base::Value> value, |
- const MicroBenchmark::DoneCallback& callback) { |
+ const MicroBenchmark::DoneCallback& callback, |
+ int id) { |
if (name == "picture_record_benchmark") { |
return scoped_ptr<MicroBenchmark>( |
- new PictureRecordBenchmark(value.Pass(), callback)); |
+ new PictureRecordBenchmark(value.Pass(), callback, id)); |
} else if (name == "rasterize_and_record_benchmark") { |
return scoped_ptr<MicroBenchmark>( |
- new RasterizeAndRecordBenchmark(value.Pass(), callback)); |
+ new RasterizeAndRecordBenchmark(value.Pass(), callback, id)); |
} else if (name == "unittest_only_benchmark") { |
return scoped_ptr<MicroBenchmark>( |
- new UnittestOnlyBenchmark(value.Pass(), callback)); |
+ new UnittestOnlyBenchmark(value.Pass(), callback, id)); |
} |
return scoped_ptr<MicroBenchmark>(); |
} |
@@ -50,22 +51,43 @@ class IsDonePredicate { |
MicroBenchmarkController::MicroBenchmarkController(LayerTreeHost* host) |
: host_(host), |
+ next_id_(1), |
main_controller_message_loop_(base::MessageLoopProxy::current().get()) { |
DCHECK(host_); |
} |
MicroBenchmarkController::~MicroBenchmarkController() {} |
-bool MicroBenchmarkController::ScheduleRun( |
+int MicroBenchmarkController::ScheduleRun( |
const std::string& micro_benchmark_name, |
scoped_ptr<base::Value> value, |
const MicroBenchmark::DoneCallback& callback) { |
+ int id = GetNextIdAndIncrement(); |
scoped_ptr<MicroBenchmark> benchmark = |
- CreateBenchmark(micro_benchmark_name, value.Pass(), callback); |
+ CreateBenchmark(micro_benchmark_name, value.Pass(), callback, id); |
if (benchmark.get()) { |
benchmarks_.push_back(benchmark.Pass()); |
host_->SetNeedsCommit(); |
- return true; |
+ return id; |
+ } |
+ return 0; |
+} |
+ |
+int MicroBenchmarkController::GetNextIdAndIncrement() { |
+ int id = next_id_++; |
+ // Wrap around to 1 if we overflow (very unlikely). |
+ if (next_id_ < 1) |
vmpstr
2014/05/28 21:16:25
signed int overflow is undefined... Maybe somethin
ernstm
2014/05/28 21:51:55
Done.
|
+ next_id_ = 1; |
+ return id; |
+} |
+ |
+bool MicroBenchmarkController::SendMessage(int id, |
vmpstr
2014/05/28 21:16:25
I'm sorry to go back on what I said earlier, but..
ernstm
2014/05/28 21:51:55
As discussed offline, renamed the function to Proc
|
+ scoped_ptr<base::Value> value) { |
+ for (ScopedPtrVector<MicroBenchmark>::iterator it = benchmarks_.begin(); |
+ it != benchmarks_.end(); |
+ ++it) { |
+ if ((*it)->id() == id) |
+ return (*it)->SendMessage(value.Pass()); |
} |
return false; |
} |