Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(123)

Side by Side Diff: content/browser/audio_device_thread.h

Issue 2558303004: Cleanup AudioDeviceThread to avoid accidental misuse. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 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 CONTENT_BROWSER_AUDIO_DEVICE_THREAD_H_ 5 #ifndef CONTENT_BROWSER_AUDIO_DEVICE_THREAD_H_
6 #define CONTENT_BROWSER_AUDIO_DEVICE_THREAD_H_ 6 #define CONTENT_BROWSER_AUDIO_DEVICE_THREAD_H_
7 7
8 #include "base/memory/ref_counted.h"
8 #include "base/threading/thread.h" 9 #include "base/threading/thread.h"
9 #include "content/common/content_export.h" 10 #include "content/common/content_export.h"
10 11
11 namespace content { 12 namespace content {
12 13
13 // This class encapulates the logic for the thread and task runners that the 14 // This class encapulates the logic for the thread and task runners that the
14 // AudioManager and related classes run on. audio_task_runner and 15 // AudioManager and related classes run on. audio_task_runner and
15 // worker_task_runner should be called on the same thread as the 16 // worker_task_runner should be called on the same thread as the
16 // AudioDeviceThread was constructed on. 17 // AudioDeviceThread was constructed on.
17 class CONTENT_EXPORT AudioDeviceThread { 18 class CONTENT_EXPORT AudioDeviceThread {
18 public: 19 public:
19 // Constructs and starts the thread. 20 // Constructs and starts a thread. On all platforms except for OSX, the
Avi (use Gerrit) 2016/12/13 01:36:11 "OSX" isn't really a thing any more. Say "the Mac"
DaleCurtis 2016/12/13 01:55:39 Done.
21 // started thread becomes the audio task runner. However, on OSX, 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).
20 AudioDeviceThread(); 25 AudioDeviceThread();
26 ~AudioDeviceThread();
21 27
22 scoped_refptr<base::SingleThreadTaskRunner> GetTaskRunner(); 28 scoped_refptr<base::SingleThreadTaskRunner> task_runner() const {
29 return task_runner_;
30 };
23 31
24 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner() { 32 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner() const {
25 return thread_.task_runner(); 33 return thread_.task_runner();
26 } 34 }
27 35
28 private: 36 private:
29 base::Thread thread_; 37 base::Thread thread_;
30 38
39 // Task runner to run audio control calls on.
40 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
41
31 DISALLOW_COPY_AND_ASSIGN(AudioDeviceThread); 42 DISALLOW_COPY_AND_ASSIGN(AudioDeviceThread);
32 }; 43 };
33 44
34 } // namespace content 45 } // namespace content
35 46
36 #endif // CONTENT_BROWSER_AUDIO_DEVICE_THREAD_H_ 47 #endif // CONTENT_BROWSER_AUDIO_DEVICE_THREAD_H_
OLDNEW
« no previous file with comments | « no previous file | content/browser/audio_device_thread.cc » ('j') | content/browser/audio_device_thread.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698