OLD | NEW |
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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_BIND_TO_CURRENT_LOOP_H_ | 5 #ifndef MEDIA_BASE_BIND_TO_CURRENT_LOOP_H_ |
6 #define MEDIA_BASE_BIND_TO_CURRENT_LOOP_H_ | 6 #define MEDIA_BASE_BIND_TO_CURRENT_LOOP_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/location.h" | 11 #include "base/location.h" |
12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
| 13 #include "base/sequenced_task_runner.h" |
13 #include "base/single_thread_task_runner.h" | 14 #include "base/single_thread_task_runner.h" |
14 #include "base/threading/thread_task_runner_handle.h" | 15 #include "base/threading/thread_task_runner_handle.h" |
15 | 16 |
16 // This is a helper utility for base::Bind()ing callbacks to the current | 17 // This is a helper utility for base::Bind()ing callbacks to the current |
17 // MessageLoop. The typical use is when |a| (of class |A|) wants to hand a | 18 // MessageLoop. The typical use is when |a| (of class |A|) wants to hand a |
18 // callback such as base::Bind(&A::AMethod, a) to |b|, but needs to ensure that | 19 // callback such as base::Bind(&A::AMethod, a) to |b|, but needs to ensure that |
19 // when |b| executes the callback, it does so on |a|'s current MessageLoop. | 20 // when |b| executes the callback, it does so on |a|'s current MessageLoop. |
20 // | 21 // |
21 // Typical usage: request to be called back on the current thread: | 22 // Typical usage: request to be called back on the current thread: |
22 // other->StartAsyncProcessAndCallMeBack( | 23 // other->StartAsyncProcessAndCallMeBack( |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 RunnerType run = &Helper::Run; | 111 RunnerType run = &Helper::Run; |
111 // TODO(tzik): Propagate FROM_HERE from the caller. | 112 // TODO(tzik): Propagate FROM_HERE from the caller. |
112 return base::BindOnce( | 113 return base::BindOnce( |
113 run, base::MakeUnique<Helper>( | 114 run, base::MakeUnique<Helper>( |
114 FROM_HERE, base::ThreadTaskRunnerHandle::Get(), std::move(cb))); | 115 FROM_HERE, base::ThreadTaskRunnerHandle::Get(), std::move(cb))); |
115 } | 116 } |
116 | 117 |
117 } // namespace media | 118 } // namespace media |
118 | 119 |
119 #endif // MEDIA_BASE_BIND_TO_CURRENT_LOOP_H_ | 120 #endif // MEDIA_BASE_BIND_TO_CURRENT_LOOP_H_ |
OLD | NEW |