| 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/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 weak_factory_.GetWeakPtr(), | 81 weak_factory_.GetWeakPtr(), |
| 82 PIPELINE_OK)); | 82 PIPELINE_OK)); |
| 83 return; | 83 return; |
| 84 } | 84 } |
| 85 | 85 |
| 86 RunNextInSeries(PIPELINE_OK); | 86 RunNextInSeries(PIPELINE_OK); |
| 87 } | 87 } |
| 88 | 88 |
| 89 SerialRunner::~SerialRunner() {} | 89 SerialRunner::~SerialRunner() {} |
| 90 | 90 |
| 91 scoped_ptr<SerialRunner> SerialRunner::Run( | 91 std::unique_ptr<SerialRunner> SerialRunner::Run( |
| 92 const Queue& bound_fns, const PipelineStatusCB& done_cb) { | 92 const Queue& bound_fns, |
| 93 scoped_ptr<SerialRunner> callback_series( | 93 const PipelineStatusCB& done_cb) { |
| 94 std::unique_ptr<SerialRunner> callback_series( |
| 94 new SerialRunner(bound_fns, done_cb)); | 95 new SerialRunner(bound_fns, done_cb)); |
| 95 return callback_series; | 96 return callback_series; |
| 96 } | 97 } |
| 97 | 98 |
| 98 void SerialRunner::RunNextInSeries(PipelineStatus last_status) { | 99 void SerialRunner::RunNextInSeries(PipelineStatus last_status) { |
| 99 DCHECK(task_runner_->BelongsToCurrentThread()); | 100 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 100 DCHECK(!done_cb_.is_null()); | 101 DCHECK(!done_cb_.is_null()); |
| 101 | 102 |
| 102 if (bound_fns_.empty() || last_status != PIPELINE_OK) { | 103 if (bound_fns_.empty() || last_status != PIPELINE_OK) { |
| 103 base::ResetAndReturn(&done_cb_).Run(last_status); | 104 base::ResetAndReturn(&done_cb_).Run(last_status); |
| 104 return; | 105 return; |
| 105 } | 106 } |
| 106 | 107 |
| 107 BoundPipelineStatusCB bound_fn = bound_fns_.Pop(); | 108 BoundPipelineStatusCB bound_fn = bound_fns_.Pop(); |
| 108 bound_fn.Run(base::Bind( | 109 bound_fn.Run(base::Bind( |
| 109 &RunOnTaskRunner, | 110 &RunOnTaskRunner, |
| 110 task_runner_, | 111 task_runner_, |
| 111 base::Bind(&SerialRunner::RunNextInSeries, weak_factory_.GetWeakPtr()))); | 112 base::Bind(&SerialRunner::RunNextInSeries, weak_factory_.GetWeakPtr()))); |
| 112 } | 113 } |
| 113 | 114 |
| 114 } // namespace media | 115 } // namespace media |
| OLD | NEW |