| 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 #ifndef MEDIA_BASE_SERIAL_RUNNER_H_ | 5 #ifndef MEDIA_BASE_SERIAL_RUNNER_H_ |
| 6 #define MEDIA_BASE_SERIAL_RUNNER_H_ | 6 #define MEDIA_BASE_SERIAL_RUNNER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <queue> | 9 #include <queue> |
| 10 | 10 |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/scoped_ptr.h" | |
| 15 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 16 #include "media/base/media_export.h" | 15 #include "media/base/media_export.h" |
| 17 #include "media/base/pipeline_status.h" | 16 #include "media/base/pipeline_status.h" |
| 18 | 17 |
| 19 namespace base { | 18 namespace base { |
| 20 class SingleThreadTaskRunner; | 19 class SingleThreadTaskRunner; |
| 21 } | 20 } |
| 22 | 21 |
| 23 namespace media { | 22 namespace media { |
| 24 | 23 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 // | 56 // |
| 58 // To eliminate an unnecessary posted task, the first function is executed | 57 // To eliminate an unnecessary posted task, the first function is executed |
| 59 // immediately on the caller's stack. It is *strongly advised* to ensure | 58 // immediately on the caller's stack. It is *strongly advised* to ensure |
| 60 // the calling code does no more work after the call to Run(). | 59 // the calling code does no more work after the call to Run(). |
| 61 // | 60 // |
| 62 // In all cases, |done_cb| is guaranteed to execute on a separate calling | 61 // In all cases, |done_cb| is guaranteed to execute on a separate calling |
| 63 // stack. | 62 // stack. |
| 64 // | 63 // |
| 65 // Deleting the object will prevent execution of any unstarted bound | 64 // Deleting the object will prevent execution of any unstarted bound |
| 66 // functions, including |done_cb|. | 65 // functions, including |done_cb|. |
| 67 static scoped_ptr<SerialRunner> Run( | 66 static std::unique_ptr<SerialRunner> Run(const Queue& bound_fns, |
| 68 const Queue& bound_fns, const PipelineStatusCB& done_cb); | 67 const PipelineStatusCB& done_cb); |
| 69 | 68 |
| 70 private: | 69 private: |
| 71 friend std::default_delete<SerialRunner>; | 70 friend std::default_delete<SerialRunner>; |
| 72 | 71 |
| 73 SerialRunner(const Queue& bound_fns, const PipelineStatusCB& done_cb); | 72 SerialRunner(const Queue& bound_fns, const PipelineStatusCB& done_cb); |
| 74 ~SerialRunner(); | 73 ~SerialRunner(); |
| 75 | 74 |
| 76 void RunNextInSeries(PipelineStatus last_status); | 75 void RunNextInSeries(PipelineStatus last_status); |
| 77 | 76 |
| 78 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 77 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| 79 Queue bound_fns_; | 78 Queue bound_fns_; |
| 80 PipelineStatusCB done_cb_; | 79 PipelineStatusCB done_cb_; |
| 81 | 80 |
| 82 // NOTE: Weak pointers must be invalidated before all other member variables. | 81 // NOTE: Weak pointers must be invalidated before all other member variables. |
| 83 base::WeakPtrFactory<SerialRunner> weak_factory_; | 82 base::WeakPtrFactory<SerialRunner> weak_factory_; |
| 84 | 83 |
| 85 DISALLOW_COPY_AND_ASSIGN(SerialRunner); | 84 DISALLOW_COPY_AND_ASSIGN(SerialRunner); |
| 86 }; | 85 }; |
| 87 | 86 |
| 88 } // namespace media | 87 } // namespace media |
| 89 | 88 |
| 90 #endif // MEDIA_BASE_SERIAL_RUNNER_H_ | 89 #endif // MEDIA_BASE_SERIAL_RUNNER_H_ |
| OLD | NEW |