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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 | 84 |
85 RunNextInSeries(PIPELINE_OK); | 85 RunNextInSeries(PIPELINE_OK); |
86 } | 86 } |
87 | 87 |
88 SerialRunner::~SerialRunner() {} | 88 SerialRunner::~SerialRunner() {} |
89 | 89 |
90 scoped_ptr<SerialRunner> SerialRunner::Run( | 90 scoped_ptr<SerialRunner> SerialRunner::Run( |
91 const Queue& bound_fns, const PipelineStatusCB& done_cb) { | 91 const Queue& bound_fns, const PipelineStatusCB& done_cb) { |
92 scoped_ptr<SerialRunner> callback_series( | 92 scoped_ptr<SerialRunner> callback_series( |
93 new SerialRunner(bound_fns, done_cb)); | 93 new SerialRunner(bound_fns, done_cb)); |
94 return callback_series.Pass(); | 94 return callback_series; |
95 } | 95 } |
96 | 96 |
97 void SerialRunner::RunNextInSeries(PipelineStatus last_status) { | 97 void SerialRunner::RunNextInSeries(PipelineStatus last_status) { |
98 DCHECK(task_runner_->BelongsToCurrentThread()); | 98 DCHECK(task_runner_->BelongsToCurrentThread()); |
99 DCHECK(!done_cb_.is_null()); | 99 DCHECK(!done_cb_.is_null()); |
100 | 100 |
101 if (bound_fns_.empty() || last_status != PIPELINE_OK) { | 101 if (bound_fns_.empty() || last_status != PIPELINE_OK) { |
102 base::ResetAndReturn(&done_cb_).Run(last_status); | 102 base::ResetAndReturn(&done_cb_).Run(last_status); |
103 return; | 103 return; |
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 |