Index: content/browser/renderer_host/media/renderer_audio_output_stream_factory_context_impl.cc |
diff --git a/content/browser/renderer_host/media/renderer_audio_output_stream_factory_context_impl.cc b/content/browser/renderer_host/media/renderer_audio_output_stream_factory_context_impl.cc |
index 076ce2da54d615cd5dfca835b8ccc60063b5b354..046b13a101168237f3f24c5f7a7d277fb5be40a1 100644 |
--- a/content/browser/renderer_host/media/renderer_audio_output_stream_factory_context_impl.cc |
+++ b/content/browser/renderer_host/media/renderer_audio_output_stream_factory_context_impl.cc |
@@ -13,12 +13,28 @@ |
#include "content/browser/renderer_host/media/media_stream_manager.h" |
#include "content/browser/renderer_host/media/render_frame_audio_output_stream_factory.h" |
#include "content/common/media/renderer_audio_output_stream_factory.mojom.h" |
-#include "content/public/browser/browser_thread.h" |
#include "content/public/browser/content_browser_client.h" |
#include "media/audio/audio_system.h" |
namespace content { |
+using FactoryHandle = |
+ RendererAudioOutputStreamFactoryContextImpl::FactoryHandle; |
+ |
+FactoryHandle::~FactoryHandle() { |
+ DCHECK_CURRENTLY_ON(BrowserThread::IO); |
+} |
+FactoryHandle::FactoryHandle( |
+ RendererAudioOutputStreamFactoryContextImpl* context, |
+ int frame_id) |
+ : impl_(frame_id, context), binding_(&impl_) {} |
+ |
+void FactoryHandle::Init( |
+ mojom::RendererAudioOutputStreamFactoryRequest request) { |
+ DCHECK_CURRENTLY_ON(BrowserThread::IO); |
+ binding_.Bind(std::move(request)); |
+} |
+ |
RendererAudioOutputStreamFactoryContextImpl:: |
RendererAudioOutputStreamFactoryContextImpl( |
int render_process_id, |
@@ -41,14 +57,20 @@ RendererAudioOutputStreamFactoryContextImpl:: |
DCHECK_CURRENTLY_ON(BrowserThread::IO); |
} |
-void RendererAudioOutputStreamFactoryContextImpl::CreateFactory( |
- int frame_host_id, |
+std::unique_ptr<FactoryHandle, BrowserThread::DeleteOnIOThread> |
+RendererAudioOutputStreamFactoryContextImpl::CreateFactory( |
+ int frame_id, |
mojo::InterfaceRequest<mojom::RendererAudioOutputStreamFactory> request) { |
- DCHECK_CURRENTLY_ON(BrowserThread::IO); |
+ DCHECK_CURRENTLY_ON(BrowserThread::UI); |
+ std::unique_ptr<FactoryHandle, BrowserThread::DeleteOnIOThread> factory( |
+ new FactoryHandle(this, frame_id)); |
+ // Unretained is safe since FactoryHandle is destroyed on the IO thread. |
+ BrowserThread::PostTask( |
+ BrowserThread::IO, FROM_HERE, |
+ base::BindOnce(&FactoryHandle::Init, base::Unretained(factory.get()), |
+ std::move(request))); |
- factories_.AddBinding(base::MakeUnique<RenderFrameAudioOutputStreamFactory>( |
- frame_host_id, this), |
- std::move(request)); |
+ return factory; |
} |
int RendererAudioOutputStreamFactoryContextImpl::GetRenderProcessId() const { |
@@ -98,4 +120,10 @@ RendererAudioOutputStreamFactoryContextImpl::CreateDelegate( |
render_frame_id, render_process_id_, params, unique_device_id); |
} |
+// static |
+bool RendererAudioOutputStreamFactoryContextImpl::UseMojoFactories() { |
+ // TODO(maxmorin): Introduce a feature for this. |
+ return false; |
+} |
+ |
} // namespace content |