Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 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_IPC_FACTORY_H_ | |
| 6 #define CONTENT_RENDERER_MEDIA_AUDIO_IPC_FACTORY_H_ | |
| 7 | |
| 8 #include <memory> | |
| 9 | |
| 10 #include "base/containers/flat_map.h" | |
| 11 #include "base/memory/ref_counted.h" | |
| 12 #include "content/common/media/renderer_audio_output_stream_factory.mojom.h" | |
| 13 | |
| 14 namespace base { | |
| 15 class SingleThreadTaskRunner; | |
| 16 } | |
| 17 | |
| 18 namespace media { | |
| 19 class AudioOutputIPC; | |
| 20 } | |
| 21 | |
| 22 namespace content { | |
| 23 | |
| 24 class AudioIPCFactory { | |
|
o1ka
2017/04/20 10:35:59
RendererAudioIPCFactory?
Max Morin
2017/05/05 13:10:58
Most stuff in renderer/ is not prefixed renderer.
| |
| 25 public: | |
| 26 AudioIPCFactory( | |
| 27 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner); | |
| 28 ~AudioIPCFactory(); | |
| 29 | |
| 30 // The following functions may be called on any thread: | |
| 31 | |
| 32 static AudioIPCFactory* get() { | |
|
o1ka
2017/04/20 10:35:59
Get(), and move implementation to .cc?
Max Morin
2017/05/05 13:10:58
I couldn't find the rule against this in the style
o1ka
2017/05/15 13:27:08
it has DCHECK, so technically it's not a "simple a
Max Morin
2017/05/16 15:51:35
It doesn't have the DCHECK in later patch sets (si
| |
| 33 DCHECK(instance_); | |
| 34 return instance_; | |
| 35 } | |
| 36 | |
| 37 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner() const { | |
| 38 return io_task_runner_; | |
| 39 } | |
| 40 | |
| 41 // Enables |this| to create AudioOutputIPCs for the specified frame. It is | |
|
o1ka
2017/04/20 10:35:59
Looking at CreateAudioOutputIPC() it's not clear h
Max Morin
2017/05/05 13:10:58
Does it matter?
| |
| 42 // automatically deregistered on frame destruction. | |
|
o1ka
2017/04/20 10:35:59
What does "automatically" mean here? Doesn't frame
Max Morin
2017/05/05 13:10:58
Right, I had to change this and didn't update the
| |
| 43 void RegisterRemoteFactory( | |
|
o1ka
2017/04/20 10:35:59
"RemoteFactory" sounds confusing, it's hard to ass
Max Morin
2017/05/05 13:10:58
A remote factory is a factory that is remote, in t
| |
| 44 int frame_id, | |
| 45 mojom::RendererAudioOutputStreamFactoryPtr factory_ptr); | |
| 46 | |
| 47 void DeregisterRemoteFactory(int frame_id); | |
| 48 | |
| 49 // The following functions shall only be called on the IO thread: | |
| 50 | |
| 51 std::unique_ptr<media::AudioOutputIPC> CreateAudioOutputIPC( | |
| 52 int frame_id) const; | |
| 53 | |
| 54 mojom::RendererAudioOutputStreamFactory* GetRemoteFactory(int frame_id); | |
|
o1ka
2017/04/20 10:35:59
It's used by MojoAudioOutputIPC only, right?
WDYT
Max Morin
2017/05/05 13:10:58
Done.
| |
| 55 | |
| 56 private: | |
| 57 using StreamFactoryMap = | |
| 58 base::flat_map<int, mojom::RendererAudioOutputStreamFactoryPtr>; | |
| 59 | |
| 60 void RegisterRemoteFactoryOnIOThread( | |
| 61 int frame_id, | |
| 62 mojom::RendererAudioOutputStreamFactoryPtrInfo factory_ptr_info); | |
| 63 | |
| 64 void DeregisterRemoteFactoryOnIOThread(int frame_id); | |
| 65 | |
| 66 // Maps frame id to the corresponding factory. | |
| 67 StreamFactoryMap factory_ptrs_; | |
| 68 | |
| 69 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; | |
| 70 | |
| 71 // Global instance, set in constructor and unset in destructor. | |
| 72 static AudioIPCFactory* instance_; | |
| 73 }; | |
| 74 | |
| 75 } // namespace content | |
| 76 | |
| 77 #endif // CONTENT_RENDERER_MEDIA_AUDIO_IPC_FACTORY_H_ | |
| OLD | NEW |