Chromium Code Reviews| Index: media/audio/audio_device_thread.cc |
| diff --git a/media/audio/audio_device_thread.cc b/media/audio/audio_device_thread.cc |
| index 5d0767a3f087b58dd6a104eced9069de4ed41a34..ce3bd0bd6a04dafe1476b8770e5ad1bfeb54eeba 100644 |
| --- a/media/audio/audio_device_thread.cc |
| +++ b/media/audio/audio_device_thread.cc |
| @@ -9,13 +9,14 @@ |
| #include <algorithm> |
| #include <limits> |
| +#include <utility> |
| #include "base/bind.h" |
| #include "base/logging.h" |
| #include "base/macros.h" |
| #include "base/memory/aligned_memory.h" |
| -#include "base/message_loop/message_loop.h" |
| #include "base/numerics/safe_conversions.h" |
| +#include "base/single_thread_task_runner.h" |
| #include "base/threading/platform_thread.h" |
| #include "base/threading/thread_restrictions.h" |
| #include "media/base/audio_bus.h" |
| @@ -26,7 +27,7 @@ namespace media { |
| // The actual worker thread implementation. It's very bare bones and much |
| // simpler than SimpleThread (no synchronization in Start, etc) and supports |
| -// joining the thread handle asynchronously via a provided message loop even |
| +// joining the thread handle asynchronously via a provided task runner even |
| // after the Thread object itself has been deleted. |
| class AudioDeviceThread::Thread |
| : public PlatformThread::Delegate, |
| @@ -39,11 +40,11 @@ class AudioDeviceThread::Thread |
| void Start(); |
| - // Stops the thread. If |loop_for_join| is non-NULL, the function posts |
| - // a task to join (close) the thread handle later instead of waiting for |
| - // the thread. If loop_for_join is NULL, then the function waits |
| + // Stops the thread. If |task_runner_for_join| is non-NULL, the function |
| + // posts a task to join (close) the thread handle later instead of waiting for |
| + // the thread. If |task_runner_for_join| is NULL, then the function waits |
| // synchronously for the thread to terminate. |
| - void Stop(base::MessageLoop* loop_for_join); |
| + void Stop(scoped_refptr<base::SingleThreadTaskRunner> task_runner_for_join); |
|
chcunningham
2016/06/21 01:34:36
This file just underwent some significant cleanup
fdoray
2016/06/29 15:44:31
Done.
|
| private: |
| friend class base::RefCountedThreadSafe<AudioDeviceThread::Thread>; |
| @@ -84,10 +85,11 @@ void AudioDeviceThread::Start(AudioDeviceThread::Callback* callback, |
| thread_->Start(); |
| } |
| -void AudioDeviceThread::Stop(base::MessageLoop* loop_for_join) { |
| +void AudioDeviceThread::Stop( |
| + scoped_refptr<base::SingleThreadTaskRunner> task_runner_for_join) { |
| base::AutoLock auto_lock(thread_lock_); |
| if (thread_.get()) { |
| - thread_->Stop(loop_for_join); |
| + thread_->Stop(std::move(task_runner_for_join)); |
| thread_ = NULL; |
| } |
| } |
| @@ -124,7 +126,8 @@ void AudioDeviceThread::Thread::Start() { |
| CHECK(!thread_.is_null()); |
| } |
| -void AudioDeviceThread::Thread::Stop(base::MessageLoop* loop_for_join) { |
| +void AudioDeviceThread::Thread::Stop( |
| + scoped_refptr<base::SingleThreadTaskRunner> task_runner_for_join) { |
| socket_.Shutdown(); |
| base::PlatformThreadHandle thread = base::PlatformThreadHandle(); |
| @@ -136,9 +139,9 @@ void AudioDeviceThread::Thread::Stop(base::MessageLoop* loop_for_join) { |
| } |
| if (!thread.is_null()) { |
| - if (loop_for_join) { |
| - loop_for_join->PostTask(FROM_HERE, |
| - base::Bind(&base::PlatformThread::Join, thread)); |
| + if (task_runner_for_join) { |
| + task_runner_for_join->PostTask( |
| + FROM_HERE, base::Bind(&base::PlatformThread::Join, thread)); |
| } else { |
| base::PlatformThread::Join(thread); |
| } |