cc: Plumbing for impl thread micro benchmarks

This patch adds plumbing for running micro benchmarks on the impl
thread. The concept is as follows:

- Create a main thread benchmark via gpu benchmarking extension
- On commit complete, if the benchmark provides an impl thread
  benchmark, it is created and scheduled to be run on the impl thread
- Impl thread benchmarks are run after an appropriate callback
- Impl thread benchmarks post a done callback (with results) that is
  run on the main thread
- The main thread benchmark gets the callback and posts its own done
  callback (with aggregated results)
- This gets back to the gpu benchmarking extension which sends the
  response back to the caller

[email protected], [email protected]

Review URL: https://codereview.chromium.org/67563002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@235585 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/cc/debug/micro_benchmark_impl.cc b/cc/debug/micro_benchmark_impl.cc
new file mode 100644
index 0000000..7ec58c8
--- /dev/null
+++ b/cc/debug/micro_benchmark_impl.cc
@@ -0,0 +1,48 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "cc/debug/micro_benchmark_impl.h"
+
+#include "base/bind.h"
+#include "base/callback.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/message_loop/message_loop.h"
+#include "base/values.h"
+
+namespace cc {
+
+namespace {
+
+void RunCallback(const MicroBenchmarkImpl::DoneCallback& callback,
+                 scoped_ptr<base::Value> result) {
+  callback.Run(result.Pass());
+}
+
+}
+
+MicroBenchmarkImpl::MicroBenchmarkImpl(
+    const DoneCallback& callback,
+    scoped_refptr<base::MessageLoopProxy> origin_loop)
+    : callback_(callback), is_done_(false), origin_loop_(origin_loop) {}
+
+MicroBenchmarkImpl::~MicroBenchmarkImpl() {}
+
+bool MicroBenchmarkImpl::IsDone() const {
+  return is_done_;
+}
+
+void MicroBenchmarkImpl::DidCompleteCommit(LayerTreeHostImpl* host) {}
+
+void MicroBenchmarkImpl::NotifyDone(scoped_ptr<base::Value> result) {
+  origin_loop_->PostTask(
+    FROM_HERE,
+    base::Bind(RunCallback, callback_, base::Passed(&result)));
+  is_done_ = true;
+}
+
+void MicroBenchmarkImpl::RunOnLayer(LayerImpl* layer) {}
+
+void MicroBenchmarkImpl::RunOnLayer(PictureLayerImpl* layer) {}
+
+}  // namespace cc