Index: media/base/callback_util.h |
diff --git a/media/base/callback_util.h b/media/base/callback_util.h |
index d831191c88b3ae162a6ddc5b7113fd41fe707ce2..42321eaf2674c6a58ae66c2344b66db948fe841a 100644 |
--- a/media/base/callback_util.h |
+++ b/media/base/callback_util.h |
@@ -8,45 +8,52 @@ |
#include <queue> |
#include "base/callback.h" |
+#include "base/memory/ref_counted.h" |
#include "base/memory/scoped_ptr.h" |
+#include "base/memory/weak_ptr.h" |
#include "media/base/pipeline_status.h" |
+namespace base { |
+class MessageLoopProxy; |
+} |
+ |
namespace media { |
-typedef base::Callback<void(const base::Closure&)> ClosureFunc; |
+// Why the odd looking typedef? SerialCallbackRunner requires callbacks to |
Ami GONE FROM CHROMIUM
2012/08/03 19:29:01
This comment doesn't explain *why* SCR would want
scherkus (not reviewing)
2012/08/03 20:19:04
Done although I'm sad at losing our funk
|
+// functions that accept a PipelineStatusCB, not PipelineStatusCBs themselves. |
typedef base::Callback<void(const PipelineStatusCB&)> PipelineStatusCBFunc; |
Ami GONE FROM CHROMIUM
2012/08/03 19:29:01
This typedef belongs at the top of the public: sec
scherkus (not reviewing)
2012/08/03 20:19:04
Done.
scherkus (not reviewing)
2012/08/03 20:19:04
Done.
|
-// Executes the closures in FIFO order, executing |done_cb| when the last |
-// closure has completed running. |
-// |
-// All closures (including |done_cb|) are executed on same thread as the |
-// calling thread. |
-void RunInSeries(scoped_ptr<std::queue<ClosureFunc> > closures, |
- const base::Closure& done_cb); |
- |
-// Executes the closures in FIFO order, executing |done_cb| when the last |
-// closure has completed running, reporting the final status code. |
-// |
-// Closures will stop being executed if a previous closure in the series |
-// returned an error status and |done_cb| will be executed prematurely. |
-// |
-// All closures (including |done_cb|) are executed on same thread as the |
-// calling thread. |
-void RunInSeriesWithStatus( |
- scoped_ptr<std::queue<PipelineStatusCBFunc> > status_cbs, |
- const PipelineStatusCB& 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. |
-// |
-// All closures (including |done_cb|) are executed on same thread as the |
-// calling thread. |
-void RunInParallel(scoped_ptr<std::queue<ClosureFunc> > closures, |
- const base::Closure& done_cb); |
+class SerialCallbackRunner { |
+ public: |
+ // Executes callbacks in |status_cbs| in series, executing |done_cb| when |
Ami GONE FROM CHROMIUM
2012/08/03 19:29:01
s/callbacks in/bound functions from/ ?
scherkus (not reviewing)
2012/08/03 20:19:04
Done.
|
+ // finished. |
+ // |
+ // All callbacks are executed on the thread that Run() is called on, including |
+ // |done_cb|. |
+ // |
+ // Deleting the object will prevent execution of any unstarted callbacks, |
+ // including |done_cb|. |
+ static scoped_ptr<SerialCallbackRunner> Run( |
+ scoped_ptr<std::queue<PipelineStatusCBFunc> > status_cbs, |
+ const PipelineStatusCB& done_cb); |
+ |
+ private: |
+ friend class scoped_ptr<SerialCallbackRunner>; |
+ |
+ SerialCallbackRunner( |
+ scoped_ptr<std::queue<PipelineStatusCBFunc> > status_cbs, |
+ const PipelineStatusCB& done_cb); |
+ ~SerialCallbackRunner(); |
+ |
+ void RunNextInSeries(PipelineStatus last_status); |
+ |
+ base::WeakPtrFactory<SerialCallbackRunner> weak_this_; |
+ scoped_refptr<base::MessageLoopProxy> message_loop_; |
+ scoped_ptr<std::queue<PipelineStatusCBFunc> > status_cbs_; |
+ PipelineStatusCB done_cb_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(SerialCallbackRunner); |
+}; |
} // namespace media |