OLD | NEW |
| (Empty) |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CONTENT_BROWSER_AUDIO_MANAGER_THREAD_H_ | |
6 #define CONTENT_BROWSER_AUDIO_MANAGER_THREAD_H_ | |
7 | |
8 #include "base/memory/ref_counted.h" | |
9 #include "base/threading/thread.h" | |
10 #include "content/common/content_export.h" | |
11 | |
12 namespace content { | |
13 | |
14 // This class encapulates the logic for the thread and task runners that the | |
15 // AudioManager and related classes run on. audio_task_runner and | |
16 // worker_task_runner should be called on the same thread as the | |
17 // AudioManagerThread was constructed on. | |
18 class CONTENT_EXPORT AudioManagerThread { | |
19 public: | |
20 // Constructs and starts a thread. On all platforms except for Mac, the | |
21 // started thread becomes the audio task runner. However, on Mac, the task | |
22 // runner this object is constructed on will become the audio thread and the | |
23 // thread is only used for high complexity tasks which can't be run on the | |
24 // main thread (typically the UI thread). | |
25 AudioManagerThread(); | |
26 ~AudioManagerThread(); | |
27 | |
28 scoped_refptr<base::SingleThreadTaskRunner> task_runner() const { | |
29 return task_runner_; | |
30 }; | |
31 | |
32 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner() const { | |
33 return thread_.task_runner(); | |
34 } | |
35 | |
36 private: | |
37 base::Thread thread_; | |
38 | |
39 // Task runner to run audio control calls on. | |
40 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | |
41 | |
42 DISALLOW_COPY_AND_ASSIGN(AudioManagerThread); | |
43 }; | |
44 | |
45 } // namespace content | |
46 | |
47 #endif // CONTENT_BROWSER_AUDIO_MANAGER_THREAD_H_ | |
OLD | NEW |