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 100887d3c51b2828ad4ca25f3df9023751c3fd61..8105d2fe941715c73c46af0f563b35556f93599c 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,9 @@ namespace { |
| const char kSiteProcessMapKeyName[] = "content_site_process_map"; |
| +const base::FilePath::CharType kAecDumpFileNameAddition[] = |
| + FILE_PATH_LITERAL("aec_dump"); |
| + |
| void CacheShaderInfo(int32 id, base::FilePath path) { |
| ShaderCacheFactory::GetInstance()->SetCacheInfo(id, path); |
| } |
| @@ -791,14 +800,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(), |
| + base::GetProcId(GetHandle()), |
| 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, |
| @@ -1605,6 +1616,15 @@ void RenderProcessHostImpl::OnChannelConnected(int32 peer_pid) { |
| GetID()); |
| Send(new ChildProcessMsg_SetIOSurfaceManagerToken(io_surface_manager_token_)); |
| #endif |
| + |
| + // Inform AudioInputRendererHost about the new render process PID. |
| + // AudioInputRendererHost is reference counted, so it's lifetime is |
| + // guarantueed during the lifetime of the closure. |
| + BrowserThread::PostTask( |
| + BrowserThread::IO, FROM_HERE, |
| + base::Bind(&AudioInputRendererHost::set_renderer_pid, |
|
tommi (sloooow) - chröme
2015/08/31 17:19:07
when this happens, does the AudioInputRendererHost
Henrik Grunell
2015/09/04 12:37:37
No, if this happens the previous channel has been
|
| + audio_input_renderer_host_, |
| + peer_pid)); |
| } |
| void RenderProcessHostImpl::OnChannelError() { |
| @@ -1760,17 +1780,30 @@ 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. AudioInputRendererHost is reference counted, so |
| + // it's lifetime is guarantueed during the lifetime of the closure. |
| + BrowserThread::PostTask( |
| + BrowserThread::IO, FROM_HERE, |
| + base::Bind(&AudioInputRendererHost::EnableDebugRecording, |
| + audio_input_renderer_host_, |
| + 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. |
| @@ -1779,6 +1812,14 @@ void RenderProcessHostImpl::DisableAecDump() { |
| base::Bind(&DisableAecDumpOnFileThread), |
| base::Bind(&RenderProcessHostImpl::SendDisableAecDumpToRenderer, |
| weak_factory_.GetWeakPtr())); |
| + |
| + // AudioInputRendererHost is reference counted, so it's lifetime is |
| + // guarantueed during the lifetime of the closure. |
|
tommi (sloooow) - chröme
2015/08/31 17:19:07
guaranteed
Henrik Grunell
2015/09/04 12:37:37
Done.
|
| + BrowserThread::PostTask( |
| + BrowserThread::IO, FROM_HERE, |
| + base::Bind( |
| + &AudioInputRendererHost::DisableDebugRecording, |
| + audio_input_renderer_host_)); |
| } |
| void RenderProcessHostImpl::SetWebRtcLogMessageCallback( |
| @@ -2382,8 +2423,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 |
| } |
| @@ -2462,9 +2505,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()) { |
| + base::FilePath file_with_extensions = GetAecDumpFilePathWithExtensions( |
| + WebRTCInternals::GetInstance()->GetAudioDebugRecordingsFilePath()); |
| + EnableAecDumpForId(file_with_extensions, id); |
| } |
| } |
| @@ -2479,28 +2524,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) { |
| @@ -2512,7 +2548,13 @@ void RenderProcessHostImpl::SendAecDumpFileToRenderer( |
| void RenderProcessHostImpl::SendDisableAecDumpToRenderer() { |
| Send(new AecDumpMsg_DisableAecDump()); |
| } |
| -#endif |
| + |
| +base::FilePath RenderProcessHostImpl::GetAecDumpFilePathWithExtensions( |
| + const base::FilePath& file) { |
| + return file.AddExtension(IntToStringType(base::GetProcId(GetHandle()))) |
| + .AddExtension(kAecDumpFileNameAddition); |
| +} |
| +#endif // defined(ENABLE_WEBRTC) |
| void RenderProcessHostImpl::IncrementWorkerRefCount() { |
| DCHECK_CURRENTLY_ON(BrowserThread::UI); |