Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1058)

Unified Diff: cc/debug/micro_benchmark_controller.cc

Issue 300963004: cc: Add message passing mechanism to micro benchmarking. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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;
}

Powered by Google App Engine
This is Rietveld 408576698