Chromium Code Reviews| Index: content/browser/renderer_host/render_process_host_impl.cc |
| diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc |
| index d9e055cedf3ef99ec69e2ddf3e561c707dfe13fe..2707ec2519bafa2da1bbb3b9069c044ba377a9a6 100644 |
| --- a/content/browser/renderer_host/render_process_host_impl.cc |
| +++ b/content/browser/renderer_host/render_process_host_impl.cc |
| @@ -211,6 +211,12 @@ |
| #include "content/common/media/media_stream_messages.h" |
| #endif |
| +#if defined(OS_WIN) |
| +#define IntToStringType base::IntToString16 |
| +#else |
| +#define IntToStringType base::IntToString |
| +#endif |
| + |
| extern bool g_exited_main_message_loop; |
| namespace content { |
| @@ -218,6 +224,8 @@ namespace { |
| const char kSiteProcessMapKeyName[] = "content_site_process_map"; |
| +const char kAecDumpFileNameAddition[] = "aec_dump"; |
| + |
| void CacheShaderInfo(int32 id, base::FilePath path) { |
| ShaderCacheFactory::GetInstance()->SetCacheInfo(id, path); |
| } |
| @@ -791,14 +799,16 @@ void RenderProcessHostImpl::CreateMessageFilters() { |
| AddFilter(resource_message_filter); |
| MediaStreamManager* media_stream_manager = |
| BrowserMainLoop::GetInstance()->media_stream_manager(); |
| - AddFilter(new AudioInputRendererHost( |
| + // The AudioInputRendererHost and AudioRendererHost needs to be available for |
| + // lookup, so it's stashed in a member variable. |
| + audio_input_renderer_host_ = new AudioInputRendererHost( |
| GetID(), |
| + this, |
| audio_manager, |
| media_stream_manager, |
| AudioMirroringManager::GetInstance(), |
| - BrowserMainLoop::GetInstance()->user_input_monitor())); |
| - // The AudioRendererHost needs to be available for lookup, so it's |
| - // stashed in a member variable. |
| + BrowserMainLoop::GetInstance()->user_input_monitor()); |
| + AddFilter(audio_input_renderer_host_.get()); |
| audio_renderer_host_ = new AudioRendererHost( |
| GetID(), |
| audio_manager, |
| @@ -1759,17 +1769,28 @@ void RenderProcessHostImpl::FilterURL(bool empty_allowed, GURL* url) { |
| } |
| #if defined(ENABLE_WEBRTC) |
| -void RenderProcessHostImpl::EnableAecDump(const base::FilePath& file) { |
| +void RenderProcessHostImpl::EnableAudioDebugRecordings( |
| + const base::FilePath& file) { |
| DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| + |
| // Enable AEC dump for each registered consumer. |
| + base::FilePath file_with_extensions = GetAecDumpFilePathWithExtensions(file); |
| for (std::vector<int>::iterator it = aec_dump_consumers_.begin(); |
| it != aec_dump_consumers_.end(); ++it) { |
| - EnableAecDumpForId(file, *it); |
| + EnableAecDumpForId(file_with_extensions, *it); |
| } |
| + |
| + // Enable mic input recording. |
| + BrowserThread::PostTask( |
| + BrowserThread::IO, FROM_HERE, |
| + base::Bind(&AudioInputRendererHost::EnableDebugRecording, |
| + audio_input_renderer_host_, |
|
nasko
2015/08/19 22:04:15
How do we guarantee that audio_input_renderer_host
Henrik Grunell
2015/08/20 07:26:19
AudioInputRendererHost is reference counted. Added
|
| + file)); |
| } |
| -void RenderProcessHostImpl::DisableAecDump() { |
| +void RenderProcessHostImpl::DisableAudioDebugRecordings() { |
| DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| + |
| // Posting on the FILE thread and then replying back on the UI thread is only |
| // for avoiding races between enable and disable. Nothing is done on the FILE |
| // thread. |
| @@ -1778,6 +1799,11 @@ void RenderProcessHostImpl::DisableAecDump() { |
| base::Bind(&DisableAecDumpOnFileThread), |
| base::Bind(&RenderProcessHostImpl::SendDisableAecDumpToRenderer, |
| weak_factory_.GetWeakPtr())); |
| + BrowserThread::PostTask( |
| + BrowserThread::IO, FROM_HERE, |
| + base::Bind( |
| + &AudioInputRendererHost::DisableDebugRecording, |
| + audio_input_renderer_host_)); |
|
nasko
2015/08/19 22:04:15
Same as above, it isn't clear how we guarantee lif
Henrik Grunell
2015/08/20 07:26:19
Ditto.
|
| } |
| void RenderProcessHostImpl::SetWebRtcLogMessageCallback( |
| @@ -2381,8 +2407,10 @@ void RenderProcessHostImpl::OnProcessLaunched() { |
| tracked_objects::ScopedTracker tracking_profile7( |
| FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| "465841 RenderProcessHostImpl::OnProcessLaunched::EnableAec")); |
| - if (WebRTCInternals::GetInstance()->aec_dump_enabled()) |
| - EnableAecDump(WebRTCInternals::GetInstance()->aec_dump_file_path()); |
| + if (WebRTCInternals::GetInstance()->IsAudioDebugRecordingsEnabled()) { |
| + EnableAudioDebugRecordings( |
| + WebRTCInternals::GetInstance()->GetAudioDebugRecordingsFilePath()); |
| + } |
| #endif |
| } |
| @@ -2461,9 +2489,11 @@ void RenderProcessHostImpl::OnUnregisterAecDumpConsumer(int id) { |
| void RenderProcessHostImpl::RegisterAecDumpConsumerOnUIThread(int id) { |
| DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| aec_dump_consumers_.push_back(id); |
| - if (WebRTCInternals::GetInstance()->aec_dump_enabled()) { |
| - EnableAecDumpForId(WebRTCInternals::GetInstance()->aec_dump_file_path(), |
| - id); |
| + if (WebRTCInternals::GetInstance()->IsAudioDebugRecordingsEnabled()) { |
| + EnableAecDumpForId( |
| + GetAecDumpFilePathWithExtensions( |
| + WebRTCInternals::GetInstance()->GetAudioDebugRecordingsFilePath()), |
| + id); |
| } |
| } |
| @@ -2478,28 +2508,19 @@ void RenderProcessHostImpl::UnregisterAecDumpConsumerOnUIThread(int id) { |
| } |
| } |
| -#if defined(OS_WIN) |
| -#define IntToStringType base::IntToString16 |
| -#else |
| -#define IntToStringType base::IntToString |
| -#endif |
| - |
| void RenderProcessHostImpl::EnableAecDumpForId(const base::FilePath& file, |
| int id) { |
| DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| - base::FilePath unique_file = |
| - file.AddExtension(IntToStringType(base::GetProcId(GetHandle()))) |
| - .AddExtension(IntToStringType(id)); |
| BrowserThread::PostTaskAndReplyWithResult( |
| BrowserThread::FILE, FROM_HERE, |
| - base::Bind(&CreateAecDumpFileForProcess, unique_file, GetHandle()), |
| + base::Bind(&CreateAecDumpFileForProcess, |
| + file.AddExtension(IntToStringType(id)), |
| + GetHandle()), |
| base::Bind(&RenderProcessHostImpl::SendAecDumpFileToRenderer, |
| weak_factory_.GetWeakPtr(), |
| id)); |
| } |
| -#undef IntToStringType |
| - |
| void RenderProcessHostImpl::SendAecDumpFileToRenderer( |
| int id, |
| IPC::PlatformFileForTransit file_for_transit) { |
| @@ -2511,6 +2532,12 @@ void RenderProcessHostImpl::SendAecDumpFileToRenderer( |
| void RenderProcessHostImpl::SendDisableAecDumpToRenderer() { |
| Send(new AecDumpMsg_DisableAecDump()); |
| } |
| + |
| +base::FilePath RenderProcessHostImpl::GetAecDumpFilePathWithExtensions( |
| + const base::FilePath& file) { |
| + return file.AddExtension(kAecDumpFileNameAddition) |
| + .AddExtension(IntToStringType(base::GetProcId(GetHandle()))); |
| +} |
| #endif |
| void RenderProcessHostImpl::IncrementWorkerRefCount() { |