Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(238)

Unified Diff: content/browser/renderer_host/render_process_host_impl.cc

Issue 1246283003: Split out audio debug recording from RenderProcessHostImpl. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 8b96d45745bd90c5ec1a0613fa09173ec28c4b8d..c9e0d5a05984da8bc8c4b96ed48f9cedbcdba4ae 100644
--- a/content/browser/renderer_host/render_process_host_impl.cc
+++ b/content/browser/renderer_host/render_process_host_impl.cc
@@ -29,6 +29,7 @@
#include "base/single_thread_task_runner.h"
#include "base/stl_util.h"
#include "base/strings/string_number_conversions.h"
+#include "base/strings/string_util.h"
Henrik Grunell 2015/10/15 12:17:03 I guess you added this for something else already
Anand Mistry (off Chromium) 2015/10/21 03:58:24 Hmmm. It compiles without it. I guess it was neede
#include "base/supports_user_data.h"
#include "base/sys_info.h"
#include "base/threading/thread.h"
@@ -207,30 +208,18 @@
#endif
#if defined(ENABLE_WEBRTC)
-#include "content/browser/media/webrtc_internals.h"
+#include "content/browser/media/audio_debug_controller.h"
#include "content/browser/renderer_host/media/media_stream_track_metrics_host.h"
#include "content/browser/renderer_host/media/webrtc_identity_service_host.h"
#include "content/browser/renderer_host/p2p/socket_dispatcher_host.h"
-#include "content/common/media/aec_dump_messages.h"
#include "content/common/media/media_stream_messages.h"
#endif
-#if defined(OS_WIN)
-#define IntToStringType base::IntToString16
-#else
-#define IntToStringType base::IntToString
-#endif
-
namespace content {
namespace {
const char kSiteProcessMapKeyName[] = "content_site_process_map";
-#ifdef ENABLE_WEBRTC
-const base::FilePath::CharType kAecDumpFileNameAddition[] =
- FILE_PATH_LITERAL("aec_dump");
-#endif
-
void CacheShaderInfo(int32 id, base::FilePath path) {
ShaderCacheFactory::GetInstance()->SetCacheInfo(id, path);
}
@@ -268,26 +257,6 @@ void GetContexts(
// Allow us to only run the trial in the first renderer.
bool has_done_stun_trials = false;
-// Creates a file used for diagnostic echo canceller recordings for handing
-// over to the renderer.
-IPC::PlatformFileForTransit CreateAecDumpFileForProcess(
- base::FilePath file_path,
- base::ProcessHandle process) {
- DCHECK_CURRENTLY_ON(BrowserThread::FILE);
- base::File dump_file(file_path,
- base::File::FLAG_OPEN_ALWAYS | base::File::FLAG_APPEND);
- if (!dump_file.IsValid()) {
- VLOG(1) << "Could not open AEC dump file, error="
- << dump_file.error_details();
- return IPC::InvalidPlatformFileForTransit();
- }
- return IPC::TakeFileHandleForProcess(dump_file.Pass(), process);
-}
-
-// Does nothing. Just to avoid races between enable and disable.
-void DisableAecDumpOnFileThread() {
- DCHECK_CURRENTLY_ON(BrowserThread::FILE);
-}
#endif
// the global list of all renderer processes
@@ -971,6 +940,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());
@@ -1551,12 +1526,6 @@ bool RenderProcessHostImpl::OnMessageReceived(const IPC::Message& msg) {
OnUserMetricsRecordAction)
IPC_MESSAGE_HANDLER(ViewHostMsg_SavedPageAsMHTML, OnSavedPageAsMHTML)
IPC_MESSAGE_HANDLER(ViewHostMsg_Close_ACK, OnCloseACK)
-#if defined(ENABLE_WEBRTC)
- IPC_MESSAGE_HANDLER(AecDumpMsg_RegisterAecDumpConsumer,
- OnRegisterAecDumpConsumer)
- IPC_MESSAGE_HANDLER(AecDumpMsg_UnregisterAecDumpConsumer,
- OnUnregisterAecDumpConsumer)
-#endif
// Adding single handlers for your service here is fine, but once your
// service needs more than one handler, please extract them into a new
// message filter and add that filter to CreateMessageFilters().
@@ -1773,44 +1742,6 @@ void RenderProcessHostImpl::FilterURL(bool empty_allowed, GURL* url) {
}
#if defined(ENABLE_WEBRTC)
-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
- // 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::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.
- BrowserThread::PostTask(
- BrowserThread::IO, FROM_HERE,
- base::Bind(&AudioInputRendererHost::DisableDebugRecording,
- audio_input_renderer_host_));
-}
-
void RenderProcessHostImpl::SetWebRtcLogMessageCallback(
base::Callback<void(const std::string&)> callback) {
webrtc_log_message_callback_ = callback;
@@ -2383,18 +2314,6 @@ void RenderProcessHostImpl::OnProcessLaunched() {
observers_,
RenderProcessReady(this));
}
-
-#if defined(ENABLE_WEBRTC)
- // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/465841
- // is fixed.
- tracked_objects::ScopedTracker tracking_profile7(
- FROM_HERE_WITH_EXPLICIT_FUNCTION(
- "465841 RenderProcessHostImpl::OnProcessLaunched::EnableAec"));
- if (WebRTCInternals::GetInstance()->IsAudioDebugRecordingsEnabled()) {
- EnableAudioDebugRecordings(
- WebRTCInternals::GetInstance()->GetAudioDebugRecordingsFilePath());
- }
-#endif
}
void RenderProcessHostImpl::OnProcessLaunchFailed() {
@@ -2448,73 +2367,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::OnUnregisterAecDumpConsumer(int id) {
- BrowserThread::PostTask(
- BrowserThread::UI, FROM_HERE,
- base::Bind(&RenderProcessHostImpl::UnregisterAecDumpConsumerOnUIThread,
- 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::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::EnableAecDumpForId(const base::FilePath& file,
- int id) {
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
- BrowserThread::PostTaskAndReplyWithResult(
- BrowserThread::FILE, FROM_HERE,
- base::Bind(&CreateAecDumpFileForProcess,
- file.AddExtension(IntToStringType(id)), GetHandle()),
- base::Bind(&RenderProcessHostImpl::SendAecDumpFileToRenderer,
- 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::SendDisableAecDumpToRenderer() {
- Send(new AecDumpMsg_DisableAecDump());
-}
-
-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);
++worker_ref_count_;

Powered by Google App Engine
This is Rietveld 408576698