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_RENDERER_MEDIA_AUDIO_OUTPUT_IPC_FACTORY_H_ | |
6 #define CONTENT_RENDERER_MEDIA_AUDIO_OUTPUT_IPC_FACTORY_H_ | |
7 | |
8 #include <map> | |
9 #include <memory> | |
10 | |
11 #include "base/id_map.h" | |
12 #include "base/macros.h" | |
13 #include "base/memory/ref_counted.h" | |
14 #include "base/synchronization/lock.h" | |
15 #include "content/common/content_export.h" | |
16 #include "media/audio/audio_output_ipc.h" | |
17 #include "media/mojo/interfaces/audio_output.mojom.h" | |
18 | |
19 namespace base { | |
20 class SingleThreadTaskRunner; | |
21 } | |
22 | |
23 namespace media { | |
24 class AudioParameters; | |
25 } | |
26 | |
27 namespace shell { | |
28 class InterfaceProvider; | |
29 } | |
30 | |
31 namespace content { | |
32 | |
33 // AudioOutputIPCFactory creates AudioOutputIPC objects that proxy calls to | |
Henrik Grunell
2016/09/01 15:09:07
It seems like the main purpose for AudioOutputIPC
Max Morin
2016/09/02 10:27:07
I haven't looked into this class much yet. Hopeful
| |
34 // the corresponding AudioOutput mojo service. This class is intended to replace | |
35 // AudioMessageFilter. | |
36 class CONTENT_EXPORT AudioOutputIPCFactory | |
37 : public base::RefCountedThreadSafe<AudioOutputIPCFactory> { | |
38 public: | |
39 // All non-constructor, non-static calls must be made on the io thread. | |
40 explicit AudioOutputIPCFactory( | |
41 const scoped_refptr<base::SingleThreadTaskRunner> io_task_runner, | |
42 shell::InterfaceProvider* interface_provider); | |
43 | |
44 // AudioOutputIPCFactory is accessed from multiple threads, resulting in the | |
45 // need | |
46 // for this static getter. Threads that don't access AudioOutputIPCFactory on | |
47 // the | |
o1ka
2016/09/02 07:31:46
nit: please fix the formatting.
| |
48 // main render thread do not have access to the RenderThreadImpl getter. | |
49 static const scoped_refptr<AudioOutputIPCFactory> Get(); | |
50 | |
51 // Creates an AudioOutputStreamClient that will lazily bind itself to an | |
52 // AudioOutputStreamService when used. All calls must be made on the io | |
53 // thread provided by io_task_runner(); | |
54 std::unique_ptr<media::AudioOutputIPC> CreateAudioOutputIPC( | |
55 int render_frame_id); | |
56 | |
57 // The task runner associated with the AudioOutputIPCFactory. | |
58 base::SingleThreadTaskRunner* io_task_runner() const { | |
59 return io_task_runner_.get(); | |
60 } | |
61 | |
62 protected: | |
63 virtual ~AudioOutputIPCFactory(); | |
64 | |
65 private: | |
66 friend class base::RefCountedThreadSafe<AudioOutputIPCFactory>; | |
67 | |
68 // Implementation of media::AudioOutputIPC which directly communicates | |
69 // with an AudioOutputStreamService in the Browser process. | |
70 class MojoAudioOutputIPC; | |
71 | |
72 // Handles connection errors with the AudioOutputService. | |
73 void OnConnectionError(); | |
74 void NotifyConnectionClose(); | |
75 | |
76 const scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; | |
77 media::mojom::AudioOutputPtr output_service_; | |
78 | |
79 IDMap<media::AudioOutputIPCDelegate> delegates_; | |
80 static AudioOutputIPCFactory* g_audio_output_ipc_factory; | |
81 | |
82 DISALLOW_COPY_AND_ASSIGN(AudioOutputIPCFactory); | |
83 }; | |
84 | |
85 } // namespace content | |
86 | |
87 #endif // CONTENT_RENDERER_MEDIA_AUDIO_OUTPUT_IPC_FACTORY_H_ | |
OLD | NEW |