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 90d4f0df388461e0cd4a1d15854e4095ae55fd5f..eca6007d5a945448a453a5dee6ddf732daaf338c 100644 |
--- a/content/browser/renderer_host/render_process_host_impl.cc |
+++ b/content/browser/renderer_host/render_process_host_impl.cc |
@@ -73,6 +73,7 @@ |
#include "content/browser/indexed_db/indexed_db_dispatcher_host.h" |
#include "content/browser/loader/resource_message_filter.h" |
#include "content/browser/loader/resource_scheduler_filter.h" |
+#include "content/browser/media/audio_debug_controller.h" |
#include "content/browser/media/capture/audio_mirroring_manager.h" |
#include "content/browser/media/media_internals.h" |
#include "content/browser/media/midi_host.h" |
@@ -222,6 +223,7 @@ |
#endif |
#if defined(ENABLE_WEBRTC) |
+#include "content/browser/media/audio_debug_controller.h" |
#include "content/browser/media/webrtc_internals.h" |
#include "content/browser/renderer_host/media/media_stream_track_metrics_host.h" |
#include "content/browser/renderer_host/media/webrtc_identity_service_host.h" |
@@ -247,8 +249,6 @@ namespace { |
const char kSiteProcessMapKeyName[] = "content_site_process_map"; |
#ifdef ENABLE_WEBRTC |
-const base::FilePath::CharType kAecDumpFileNameAddition[] = |
- FILE_PATH_LITERAL("aec_dump"); |
const base::FilePath::CharType kEventLogFileNameAddition[] = |
FILE_PATH_LITERAL("event_log"); |
#endif |
@@ -1082,6 +1082,12 @@ void RenderProcessHostImpl::RegisterMojoServices() { |
make_scoped_refptr(storage_partition_impl_->GetNavigatorConnectContext()), |
message_port_message_filter_)); |
+#if defined(ENABLE_WEBRTC) |
+ mojo_application_host_->service_registry()->AddService( |
+ base::Bind(&AudioDebugController::CreateService, GetID(), |
+ audio_input_renderer_host_)); |
+#endif |
+ |
#if defined(OS_ANDROID) |
ServiceRegistrarAndroid::RegisterProcessHostServices( |
mojo_application_host_->service_registry_android()); |
@@ -1716,12 +1722,8 @@ bool RenderProcessHostImpl::OnMessageReceived(const IPC::Message& msg) { |
OnUserMetricsRecordAction) |
IPC_MESSAGE_HANDLER(ViewHostMsg_Close_ACK, OnCloseACK) |
#if defined(ENABLE_WEBRTC) |
- IPC_MESSAGE_HANDLER(AecDumpMsg_RegisterAecDumpConsumer, |
- OnRegisterAecDumpConsumer) |
IPC_MESSAGE_HANDLER(WebRTCEventLogMsg_RegisterEventLogConsumer, |
OnRegisterEventLogConsumer) |
- IPC_MESSAGE_HANDLER(AecDumpMsg_UnregisterAecDumpConsumer, |
- OnUnregisterAecDumpConsumer) |
IPC_MESSAGE_HANDLER(WebRTCEventLogMsg_UnregisterEventLogConsumer, |
OnUnregisterEventLogConsumer) |
#endif |
@@ -1962,44 +1964,15 @@ 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_with_extensions, *it); |
- } |
- |
- // Enable mic input recording. AudioInputRendererHost is reference counted, so |
- // its lifetime is guaranteed during the lifetime of the closure. |
- if (audio_input_renderer_host_) { |
- // Not null if RenderProcessHostImpl::Init has already been called. |
- BrowserThread::PostTask( |
- BrowserThread::IO, FROM_HERE, |
- base::Bind(&AudioInputRendererHost::EnableDebugRecording, |
- audio_input_renderer_host_, file)); |
- } |
+ AudioDebugController::GetInstance()->EnableAudioDebugRecordingForHost( |
+ GetID(), file); |
} |
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. |
- BrowserThread::PostTaskAndReply( |
- BrowserThread::FILE, FROM_HERE, base::Bind(&DisableAecDumpOnFileThread), |
- base::Bind(&RenderProcessHostImpl::SendDisableAecDumpToRenderer, |
- weak_factory_.GetWeakPtr())); |
- |
- // AudioInputRendererHost is reference counted, so it's lifetime is |
- // guaranteed during the lifetime of the closure. |
- if (audio_input_renderer_host_) { |
- // Not null if RenderProcessHostImpl::Init has already been called. |
- BrowserThread::PostTask( |
- BrowserThread::IO, FROM_HERE, |
- base::Bind(&AudioInputRendererHost::DisableDebugRecording, |
- audio_input_renderer_host_)); |
- } |
+ AudioDebugController::GetInstance()->DisableAudioDebugRecordingForHost( |
+ GetID()); |
} |
void RenderProcessHostImpl::EnableEventLogRecordings( |
@@ -2605,13 +2578,6 @@ void RenderProcessHostImpl::OnProcessLaunched() { |
observers_, |
RenderProcessReady(this)); |
} |
- |
-#if defined(ENABLE_WEBRTC) |
- if (WebRTCInternals::GetInstance()->IsAudioDebugRecordingsEnabled()) { |
- EnableAudioDebugRecordings( |
- WebRTCInternals::GetInstance()->GetAudioDebugRecordingsFilePath()); |
- } |
-#endif |
} |
void RenderProcessHostImpl::OnProcessLaunchFailed() { |
@@ -2662,13 +2628,6 @@ void RenderProcessHostImpl::OnGpuSwitched() { |
} |
#if defined(ENABLE_WEBRTC) |
-void RenderProcessHostImpl::OnRegisterAecDumpConsumer(int id) { |
- BrowserThread::PostTask( |
- BrowserThread::UI, FROM_HERE, |
- base::Bind(&RenderProcessHostImpl::RegisterAecDumpConsumerOnUIThread, |
- weak_factory_.GetWeakPtr(), id)); |
-} |
- |
void RenderProcessHostImpl::OnRegisterEventLogConsumer(int id) { |
BrowserThread::PostTask( |
BrowserThread::UI, FROM_HERE, |
@@ -2676,13 +2635,6 @@ void RenderProcessHostImpl::OnRegisterEventLogConsumer(int id) { |
weak_factory_.GetWeakPtr(), id)); |
} |
-void RenderProcessHostImpl::OnUnregisterAecDumpConsumer(int id) { |
- BrowserThread::PostTask( |
- BrowserThread::UI, FROM_HERE, |
- base::Bind(&RenderProcessHostImpl::UnregisterAecDumpConsumerOnUIThread, |
- weak_factory_.GetWeakPtr(), id)); |
-} |
- |
void RenderProcessHostImpl::OnUnregisterEventLogConsumer(int id) { |
BrowserThread::PostTask( |
BrowserThread::UI, FROM_HERE, |
@@ -2690,17 +2642,6 @@ void RenderProcessHostImpl::OnUnregisterEventLogConsumer(int id) { |
weak_factory_.GetWeakPtr(), id)); |
} |
-void RenderProcessHostImpl::RegisterAecDumpConsumerOnUIThread(int id) { |
- DCHECK_CURRENTLY_ON(BrowserThread::UI); |
- aec_dump_consumers_.push_back(id); |
- |
- if (WebRTCInternals::GetInstance()->IsAudioDebugRecordingsEnabled()) { |
- base::FilePath file_with_extensions = GetAecDumpFilePathWithExtensions( |
- WebRTCInternals::GetInstance()->GetAudioDebugRecordingsFilePath()); |
- EnableAecDumpForId(file_with_extensions, id); |
- } |
-} |
- |
void RenderProcessHostImpl::RegisterEventLogConsumerOnUIThread(int id) { |
DCHECK_CURRENTLY_ON(BrowserThread::UI); |
aec_dump_consumers_.push_back(id); |
@@ -2712,17 +2653,6 @@ void RenderProcessHostImpl::RegisterEventLogConsumerOnUIThread(int id) { |
} |
} |
-void RenderProcessHostImpl::UnregisterAecDumpConsumerOnUIThread(int id) { |
- DCHECK_CURRENTLY_ON(BrowserThread::UI); |
- for (std::vector<int>::iterator it = aec_dump_consumers_.begin(); |
- it != aec_dump_consumers_.end(); ++it) { |
- if (*it == id) { |
- aec_dump_consumers_.erase(it); |
- break; |
- } |
- } |
-} |
- |
void RenderProcessHostImpl::UnregisterEventLogConsumerOnUIThread(int id) { |
DCHECK_CURRENTLY_ON(BrowserThread::UI); |
for (std::vector<int>::iterator it = aec_dump_consumers_.begin(); |
@@ -2734,17 +2664,6 @@ void RenderProcessHostImpl::UnregisterEventLogConsumerOnUIThread(int id) { |
} |
} |
-void RenderProcessHostImpl::EnableAecDumpForId(const base::FilePath& file, |
- int id) { |
- DCHECK_CURRENTLY_ON(BrowserThread::UI); |
- BrowserThread::PostTaskAndReplyWithResult( |
- BrowserThread::FILE, FROM_HERE, |
- base::Bind(&CreateFileForProcess, file.AddExtension(IntToStringType(id)), |
- GetHandle()), |
- base::Bind(&RenderProcessHostImpl::SendAecDumpFileToRenderer, |
- weak_factory_.GetWeakPtr(), id)); |
-} |
- |
void RenderProcessHostImpl::EnableEventLogForId(const base::FilePath& file, |
int id) { |
DCHECK_CURRENTLY_ON(BrowserThread::UI); |
@@ -2756,14 +2675,6 @@ void RenderProcessHostImpl::EnableEventLogForId(const base::FilePath& file, |
weak_factory_.GetWeakPtr(), id)); |
} |
-void RenderProcessHostImpl::SendAecDumpFileToRenderer( |
- int id, |
- IPC::PlatformFileForTransit file_for_transit) { |
- if (file_for_transit == IPC::InvalidPlatformFileForTransit()) |
- return; |
- Send(new AecDumpMsg_EnableAecDump(id, file_for_transit)); |
-} |
- |
void RenderProcessHostImpl::SendEventLogFileToRenderer( |
int id, |
IPC::PlatformFileForTransit file_for_transit) { |
@@ -2772,20 +2683,10 @@ void RenderProcessHostImpl::SendEventLogFileToRenderer( |
Send(new WebRTCEventLogMsg_EnableEventLog(id, file_for_transit)); |
} |
-void RenderProcessHostImpl::SendDisableAecDumpToRenderer() { |
- Send(new AecDumpMsg_DisableAecDump()); |
-} |
- |
void RenderProcessHostImpl::SendDisableEventLogToRenderer() { |
Send(new WebRTCEventLogMsg_DisableEventLog()); |
} |
-base::FilePath RenderProcessHostImpl::GetAecDumpFilePathWithExtensions( |
- const base::FilePath& file) { |
- return file.AddExtension(IntToStringType(base::GetProcId(GetHandle()))) |
- .AddExtension(kAecDumpFileNameAddition); |
-} |
- |
base::FilePath RenderProcessHostImpl::GetEventLogFilePathWithExtensions( |
const base::FilePath& file) { |
return file.AddExtension(IntToStringType(base::GetProcId(GetHandle()))) |