Index: content/renderer/media/audio_output_ipc_factory.h |
diff --git a/content/renderer/media/audio_output_ipc_factory.h b/content/renderer/media/audio_output_ipc_factory.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..cd69f4e0c8df2b4fe53c263d5550c96a5ca9d98a |
--- /dev/null |
+++ b/content/renderer/media/audio_output_ipc_factory.h |
@@ -0,0 +1,86 @@ |
+// Copyright 2016 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_OUTPUT_IPC_FACTORY_H_ |
+#define CONTENT_RENDERER_MEDIA_AUDIO_OUTPUT_IPC_FACTORY_H_ |
+ |
+#include <map> |
+#include <memory> |
+ |
+#include "base/id_map.h" |
+#include "base/macros.h" |
+#include "base/memory/ref_counted.h" |
+#include "base/synchronization/lock.h" |
+#include "content/common/content_export.h" |
+#include "media/audio/audio_output_ipc.h" |
+#include "media/mojo/interfaces/audio_output.mojom.h" |
+/* |
+namespace base { |
+class SingleThreadTaskRunner; |
+} |
+ |
+namespace media { |
+class AudioParameters; |
+} |
+ |
+namespace shell { |
+class InterfaceProvider; |
+} |
+ |
+namespace content { |
+ |
+// AudioOutputIPCFactory creates AudioOutputIPC objects that proxy calls to the |
+// corresponding AudioOutput mojo service. This class is intended to replace |
+// AudioMessageFilter. |
+class CONTENT_EXPORT AudioOutputIPCFactory |
+ : public base::RefCountedThreadSafe<AudioOutputIPCFactory> { |
+ public: |
+ // All non-constructor, non-static calls must be made on the io thread. |
+ explicit AudioOutputIPCFactory( |
+ const scoped_refptr<base::SingleThreadTaskRunner> io_task_runner, |
+ shell::InterfaceProvider* interface_provider); |
+ |
+ // AudioOutputIPCFactory is accessed from multiple threads, resulting in the |
+ // need for this static getter. Threads that don't access |
+ // AudioOutputIPCFactory on the main render thread do not have access to the |
+ // RenderThreadImpl getter. |
+ static const scoped_refptr<AudioOutputIPCFactory> Get(); |
+ |
+ // Creates an AudioOutputStreamClient that will lazily bind itself to an |
+ // AudioOutputStreamService when used. All calls must be made on the io thread |
+ // provided by io_task_runner(); |
+ std::unique_ptr<media::AudioOutputIPC> CreateAudioOutputIPC( |
+ int render_frame_id); |
+ |
+ // The task runner associated with the AudioOutputIPCFactory. |
+ base::SingleThreadTaskRunner* io_task_runner() const { |
+ return io_task_runner_.get(); |
+ } |
+ |
+ protected: |
+ virtual ~AudioOutputIPCFactory(); |
+ |
+ private: |
+ friend class base::RefCountedThreadSafe<AudioOutputIPCFactory>; |
+ |
+ // Implementation of media::AudioOutputIPC which directly communicates with an |
+ // AudioOutputStreamService in the Browser process. |
+ class MojoAudioOutputIPC; |
+ |
+ // Handles connection errors with the AudioOutputService. |
+ void OnConnectionError(); |
+ void NotifyConnectionClose(); |
+ |
+ const scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; |
+ media::mojom::AudioOutputPtr output_service_; |
+ |
+ IDMap<media::AudioOutputIPCDelegate> delegates_; |
+ static AudioOutputIPCFactory* g_audio_output_ipc_factory; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(AudioOutputIPCFactory); |
+}; |
+ |
+} // namespace content |
+*/ |
+#endif // CONTENT_RENDERER_MEDIA_AUDIO_OUTPUT_IPC_FACTORY_H_ |