Chromium Code Reviews| Index: content/renderer/media/audio_ipc_factory.h |
| diff --git a/content/renderer/media/audio_ipc_factory.h b/content/renderer/media/audio_ipc_factory.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..18249b414e091817b2bdd5fbac55b7cd6095717f |
| --- /dev/null |
| +++ b/content/renderer/media/audio_ipc_factory.h |
| @@ -0,0 +1,77 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CONTENT_RENDERER_MEDIA_AUDIO_IPC_FACTORY_H_ |
| +#define CONTENT_RENDERER_MEDIA_AUDIO_IPC_FACTORY_H_ |
| + |
| +#include <memory> |
| + |
| +#include "base/containers/flat_map.h" |
| +#include "base/memory/ref_counted.h" |
| +#include "content/common/media/renderer_audio_output_stream_factory.mojom.h" |
| + |
| +namespace base { |
| +class SingleThreadTaskRunner; |
| +} |
| + |
| +namespace media { |
| +class AudioOutputIPC; |
| +} |
| + |
| +namespace content { |
| + |
| +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.
|
| + public: |
| + AudioIPCFactory( |
| + const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner); |
| + ~AudioIPCFactory(); |
| + |
| + // The following functions may be called on any thread: |
| + |
| + 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
|
| + DCHECK(instance_); |
| + return instance_; |
| + } |
| + |
| + scoped_refptr<base::SingleThreadTaskRunner> io_task_runner() const { |
| + return io_task_runner_; |
| + } |
| + |
| + // 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?
|
| + // 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
|
| + 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
|
| + int frame_id, |
| + mojom::RendererAudioOutputStreamFactoryPtr factory_ptr); |
| + |
| + void DeregisterRemoteFactory(int frame_id); |
| + |
| + // The following functions shall only be called on the IO thread: |
| + |
| + std::unique_ptr<media::AudioOutputIPC> CreateAudioOutputIPC( |
| + int frame_id) const; |
| + |
| + 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.
|
| + |
| + private: |
| + using StreamFactoryMap = |
| + base::flat_map<int, mojom::RendererAudioOutputStreamFactoryPtr>; |
| + |
| + void RegisterRemoteFactoryOnIOThread( |
| + int frame_id, |
| + mojom::RendererAudioOutputStreamFactoryPtrInfo factory_ptr_info); |
| + |
| + void DeregisterRemoteFactoryOnIOThread(int frame_id); |
| + |
| + // Maps frame id to the corresponding factory. |
| + StreamFactoryMap factory_ptrs_; |
| + |
| + scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; |
| + |
| + // Global instance, set in constructor and unset in destructor. |
| + static AudioIPCFactory* instance_; |
| +}; |
| + |
| +} // namespace content |
| + |
| +#endif // CONTENT_RENDERER_MEDIA_AUDIO_IPC_FACTORY_H_ |