| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "media/base/serial_runner.h" | 5 #include "media/base/serial_runner.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/message_loop/message_loop_proxy.h" | |
| 11 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| 11 #include "base/thread_task_runner_handle.h" |
| 12 | 12 |
| 13 namespace media { | 13 namespace media { |
| 14 | 14 |
| 15 // Converts a Closure into a bound function accepting a PipelineStatusCB. | 15 // Converts a Closure into a bound function accepting a PipelineStatusCB. |
| 16 static void RunClosure( | 16 static void RunClosure( |
| 17 const base::Closure& closure, | 17 const base::Closure& closure, |
| 18 const PipelineStatusCB& status_cb) { | 18 const PipelineStatusCB& status_cb) { |
| 19 closure.Run(); | 19 closure.Run(); |
| 20 status_cb.Run(PIPELINE_OK); | 20 status_cb.Run(PIPELINE_OK); |
| 21 } | 21 } |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 bound_fns_.pop(); | 61 bound_fns_.pop(); |
| 62 return bound_fn; | 62 return bound_fn; |
| 63 } | 63 } |
| 64 | 64 |
| 65 bool SerialRunner::Queue::empty() { | 65 bool SerialRunner::Queue::empty() { |
| 66 return bound_fns_.empty(); | 66 return bound_fns_.empty(); |
| 67 } | 67 } |
| 68 | 68 |
| 69 SerialRunner::SerialRunner(const Queue& bound_fns, | 69 SerialRunner::SerialRunner(const Queue& bound_fns, |
| 70 const PipelineStatusCB& done_cb) | 70 const PipelineStatusCB& done_cb) |
| 71 : task_runner_(base::MessageLoopProxy::current()), | 71 : task_runner_(base::ThreadTaskRunnerHandle::Get()), |
| 72 bound_fns_(bound_fns), | 72 bound_fns_(bound_fns), |
| 73 done_cb_(done_cb), | 73 done_cb_(done_cb), |
| 74 weak_factory_(this) { | 74 weak_factory_(this) { |
| 75 // Respect both cancellation and calling stack guarantees for |done_cb| | 75 // Respect both cancellation and calling stack guarantees for |done_cb| |
| 76 // when empty. | 76 // when empty. |
| 77 if (bound_fns_.empty()) { | 77 if (bound_fns_.empty()) { |
| 78 task_runner_->PostTask(FROM_HERE, | 78 task_runner_->PostTask(FROM_HERE, |
| 79 base::Bind(&SerialRunner::RunNextInSeries, | 79 base::Bind(&SerialRunner::RunNextInSeries, |
| 80 weak_factory_.GetWeakPtr(), | 80 weak_factory_.GetWeakPtr(), |
| 81 PIPELINE_OK)); | 81 PIPELINE_OK)); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 104 } | 104 } |
| 105 | 105 |
| 106 BoundPipelineStatusCB bound_fn = bound_fns_.Pop(); | 106 BoundPipelineStatusCB bound_fn = bound_fns_.Pop(); |
| 107 bound_fn.Run(base::Bind( | 107 bound_fn.Run(base::Bind( |
| 108 &RunOnTaskRunner, | 108 &RunOnTaskRunner, |
| 109 task_runner_, | 109 task_runner_, |
| 110 base::Bind(&SerialRunner::RunNextInSeries, weak_factory_.GetWeakPtr()))); | 110 base::Bind(&SerialRunner::RunNextInSeries, weak_factory_.GetWeakPtr()))); |
| 111 } | 111 } |
| 112 | 112 |
| 113 } // namespace media | 113 } // namespace media |
| OLD | NEW |