Index: media/base/callback_util.h |
diff --git a/media/base/callback_util.h b/media/base/callback_util.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..22b9253daadfdd86eeffe9038b32b9829a065660 |
--- /dev/null |
+++ b/media/base/callback_util.h |
@@ -0,0 +1,39 @@ |
+// Copyright (c) 2012 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. |
+ |
+#ifndef MEDIA_BASE_CALLBACK_UTIL_H_ |
+#define MEDIA_BASE_CALLBACK_UTIL_H_ |
+ |
+#include <queue> |
+ |
+#include "base/callback.h" |
+#include "base/memory/scoped_ptr.h" |
+ |
+namespace media { |
+ |
+typedef base::Callback<void(const base::Closure&)> ClosureCB; |
+ |
+// Executes the closures in FIFO order, executing |done_cb| when the last |
+// closure has completed running. |
+// |
+// |done_cb| will be executed on the same thread as the last completed closure |
+// or the current thread if |closures| is empty. |
+void RunInSeries(scoped_ptr<std::queue<ClosureCB> > closures, |
+ const base::Closure& done_cb); |
+ |
+// Executes the closures in parallel, executing |done_cb| when all closures have |
+// completed running. |
+// |
+// No attempt is made to parallelize execution of the closures. In other words, |
+// this method will run all closures in FIFO order if said closures execute |
+// synchronously on the same call stack. |
+// |
+// |done_cb| will be executed on the same thread as the last completed closure |
+// or the current thread if |closures| is empty. |
+void RunInParallel(scoped_ptr<std::queue<ClosureCB> > closures, |
+ const base::Closure& done_cb); |
+ |
+} // namespace media |
+ |
+#endif // MEDIA_BASE_CALLBACK_UTIL_H_ |