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

Side by Side Diff: content/browser/renderer_host/render_process_host_impl.cc

Issue 1272223003: Implement writing mic audio input data to file for debugging purposes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Represents the browser side of the browser <--> renderer communication 5 // Represents the browser side of the browser <--> renderer communication
6 // channel. There will be one RenderProcessHost per renderer process. 6 // channel. There will be one RenderProcessHost per renderer process.
7 7
8 #include "content/browser/renderer_host/render_process_host_impl.h" 8 #include "content/browser/renderer_host/render_process_host_impl.h"
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 200
201 #if defined(ENABLE_WEBRTC) 201 #if defined(ENABLE_WEBRTC)
202 #include "content/browser/media/webrtc_internals.h" 202 #include "content/browser/media/webrtc_internals.h"
203 #include "content/browser/renderer_host/media/media_stream_track_metrics_host.h" 203 #include "content/browser/renderer_host/media/media_stream_track_metrics_host.h"
204 #include "content/browser/renderer_host/media/webrtc_identity_service_host.h" 204 #include "content/browser/renderer_host/media/webrtc_identity_service_host.h"
205 #include "content/browser/renderer_host/p2p/socket_dispatcher_host.h" 205 #include "content/browser/renderer_host/p2p/socket_dispatcher_host.h"
206 #include "content/common/media/aec_dump_messages.h" 206 #include "content/common/media/aec_dump_messages.h"
207 #include "content/common/media/media_stream_messages.h" 207 #include "content/common/media/media_stream_messages.h"
208 #endif 208 #endif
209 209
210 #if defined(OS_WIN)
211 #define IntToStringType base::IntToString16
212 #else
213 #define IntToStringType base::IntToString
214 #endif
215
210 extern bool g_exited_main_message_loop; 216 extern bool g_exited_main_message_loop;
211 217
212 namespace content { 218 namespace content {
213 namespace { 219 namespace {
214 220
215 const char kSiteProcessMapKeyName[] = "content_site_process_map"; 221 const char kSiteProcessMapKeyName[] = "content_site_process_map";
216 222
223 const char kAecDumpFileNameAddition[] = "aec_dump";
224
217 void CacheShaderInfo(int32 id, base::FilePath path) { 225 void CacheShaderInfo(int32 id, base::FilePath path) {
218 ShaderCacheFactory::GetInstance()->SetCacheInfo(id, path); 226 ShaderCacheFactory::GetInstance()->SetCacheInfo(id, path);
219 } 227 }
220 228
221 void RemoveShaderInfo(int32 id) { 229 void RemoveShaderInfo(int32 id) {
222 ShaderCacheFactory::GetInstance()->RemoveCacheInfo(id); 230 ShaderCacheFactory::GetInstance()->RemoveCacheInfo(id);
223 } 231 }
224 232
225 net::URLRequestContext* GetRequestContext( 233 net::URLRequestContext* GetRequestContext(
226 scoped_refptr<net::URLRequestContextGetter> request_context, 234 scoped_refptr<net::URLRequestContextGetter> request_context,
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after
770 storage_partition_impl_->GetAppCacheService(), 778 storage_partition_impl_->GetAppCacheService(),
771 ChromeBlobStorageContext::GetFor(browser_context), 779 ChromeBlobStorageContext::GetFor(browser_context),
772 storage_partition_impl_->GetFileSystemContext(), 780 storage_partition_impl_->GetFileSystemContext(),
773 storage_partition_impl_->GetServiceWorkerContext(), 781 storage_partition_impl_->GetServiceWorkerContext(),
774 storage_partition_impl_->GetHostZoomLevelContext(), 782 storage_partition_impl_->GetHostZoomLevelContext(),
775 get_contexts_callback); 783 get_contexts_callback);
776 784
777 AddFilter(resource_message_filter); 785 AddFilter(resource_message_filter);
778 MediaStreamManager* media_stream_manager = 786 MediaStreamManager* media_stream_manager =
779 BrowserMainLoop::GetInstance()->media_stream_manager(); 787 BrowserMainLoop::GetInstance()->media_stream_manager();
780 AddFilter(new AudioInputRendererHost( 788 // The AudioInputRendererHost and AudioRendererHost needs to be available for
789 // lookup, so it's stashed in a member variable.
790 audio_input_renderer_host_ = new AudioInputRendererHost(
781 GetID(), 791 GetID(),
792 this,
782 audio_manager, 793 audio_manager,
783 media_stream_manager, 794 media_stream_manager,
784 AudioMirroringManager::GetInstance(), 795 AudioMirroringManager::GetInstance(),
785 BrowserMainLoop::GetInstance()->user_input_monitor())); 796 BrowserMainLoop::GetInstance()->user_input_monitor());
786 // The AudioRendererHost needs to be available for lookup, so it's 797 AddFilter(audio_input_renderer_host_.get());
787 // stashed in a member variable.
788 audio_renderer_host_ = new AudioRendererHost( 798 audio_renderer_host_ = new AudioRendererHost(
789 GetID(), 799 GetID(),
790 audio_manager, 800 audio_manager,
791 AudioMirroringManager::GetInstance(), 801 AudioMirroringManager::GetInstance(),
792 media_internals, 802 media_internals,
793 media_stream_manager, 803 media_stream_manager,
794 browser_context->GetResourceContext()->GetMediaDeviceIDSalt()); 804 browser_context->GetResourceContext()->GetMediaDeviceIDSalt());
795 AddFilter(audio_renderer_host_.get()); 805 AddFilter(audio_renderer_host_.get());
796 AddFilter( 806 AddFilter(
797 new MidiHost(GetID(), BrowserMainLoop::GetInstance()->midi_manager())); 807 new MidiHost(GetID(), BrowserMainLoop::GetInstance()->midi_manager()));
(...skipping 934 matching lines...) Expand 10 before | Expand all | Expand 10 after
1732 1742
1733 void RenderProcessHostImpl::ResumeRequestsForView(int route_id) { 1743 void RenderProcessHostImpl::ResumeRequestsForView(int route_id) {
1734 widget_helper_->ResumeRequestsForView(route_id); 1744 widget_helper_->ResumeRequestsForView(route_id);
1735 } 1745 }
1736 1746
1737 void RenderProcessHostImpl::FilterURL(bool empty_allowed, GURL* url) { 1747 void RenderProcessHostImpl::FilterURL(bool empty_allowed, GURL* url) {
1738 FilterURL(this, empty_allowed, url); 1748 FilterURL(this, empty_allowed, url);
1739 } 1749 }
1740 1750
1741 #if defined(ENABLE_WEBRTC) 1751 #if defined(ENABLE_WEBRTC)
1742 void RenderProcessHostImpl::EnableAecDump(const base::FilePath& file) { 1752 void RenderProcessHostImpl::EnableAudioDebugRecordings(
1753 const base::FilePath& file) {
1743 DCHECK_CURRENTLY_ON(BrowserThread::UI); 1754 DCHECK_CURRENTLY_ON(BrowserThread::UI);
1755
1744 // Enable AEC dump for each registered consumer. 1756 // Enable AEC dump for each registered consumer.
1757 base::FilePath file_with_extensions = GetAecDumpFilePathWithExtensions(file);
1745 for (std::vector<int>::iterator it = aec_dump_consumers_.begin(); 1758 for (std::vector<int>::iterator it = aec_dump_consumers_.begin();
1746 it != aec_dump_consumers_.end(); ++it) { 1759 it != aec_dump_consumers_.end(); ++it) {
1747 EnableAecDumpForId(file, *it); 1760 EnableAecDumpForId(file_with_extensions, *it);
1748 } 1761 }
1762
1763 // Enable mic input recording.
1764 BrowserThread::PostTask(
1765 BrowserThread::IO, FROM_HERE,
1766 base::Bind(&AudioInputRendererHost::EnableDebugRecording,
1767 audio_input_renderer_host_,
1768 file));
1749 } 1769 }
1750 1770
1751 void RenderProcessHostImpl::DisableAecDump() { 1771 void RenderProcessHostImpl::DisableAudioDebugRecordings() {
1752 DCHECK_CURRENTLY_ON(BrowserThread::UI); 1772 DCHECK_CURRENTLY_ON(BrowserThread::UI);
1773
1753 // Posting on the FILE thread and then replying back on the UI thread is only 1774 // Posting on the FILE thread and then replying back on the UI thread is only
1754 // for avoiding races between enable and disable. Nothing is done on the FILE 1775 // for avoiding races between enable and disable. Nothing is done on the FILE
1755 // thread. 1776 // thread.
1756 BrowserThread::PostTaskAndReply( 1777 BrowserThread::PostTaskAndReply(
1757 BrowserThread::FILE, FROM_HERE, 1778 BrowserThread::FILE, FROM_HERE,
1758 base::Bind(&DisableAecDumpOnFileThread), 1779 base::Bind(&DisableAecDumpOnFileThread),
1759 base::Bind(&RenderProcessHostImpl::SendDisableAecDumpToRenderer, 1780 base::Bind(&RenderProcessHostImpl::SendDisableAecDumpToRenderer,
1760 weak_factory_.GetWeakPtr())); 1781 weak_factory_.GetWeakPtr()));
1782 BrowserThread::PostTask(
1783 BrowserThread::IO, FROM_HERE,
1784 base::Bind(
1785 &AudioInputRendererHost::DisableDebugRecording,
1786 audio_input_renderer_host_));
1761 } 1787 }
1762 1788
1763 void RenderProcessHostImpl::SetWebRtcLogMessageCallback( 1789 void RenderProcessHostImpl::SetWebRtcLogMessageCallback(
1764 base::Callback<void(const std::string&)> callback) { 1790 base::Callback<void(const std::string&)> callback) {
1765 webrtc_log_message_callback_ = callback; 1791 webrtc_log_message_callback_ = callback;
1766 } 1792 }
1767 1793
1768 RenderProcessHostImpl::WebRtcStopRtpDumpCallback 1794 RenderProcessHostImpl::WebRtcStopRtpDumpCallback
1769 RenderProcessHostImpl::StartRtpDump( 1795 RenderProcessHostImpl::StartRtpDump(
1770 bool incoming, 1796 bool incoming,
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after
2354 Send(queued_messages_.front()); 2380 Send(queued_messages_.front());
2355 queued_messages_.pop(); 2381 queued_messages_.pop();
2356 } 2382 }
2357 2383
2358 #if defined(ENABLE_WEBRTC) 2384 #if defined(ENABLE_WEBRTC)
2359 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/465841 2385 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/465841
2360 // is fixed. 2386 // is fixed.
2361 tracked_objects::ScopedTracker tracking_profile7( 2387 tracked_objects::ScopedTracker tracking_profile7(
2362 FROM_HERE_WITH_EXPLICIT_FUNCTION( 2388 FROM_HERE_WITH_EXPLICIT_FUNCTION(
2363 "465841 RenderProcessHostImpl::OnProcessLaunched::EnableAec")); 2389 "465841 RenderProcessHostImpl::OnProcessLaunched::EnableAec"));
2364 if (WebRTCInternals::GetInstance()->aec_dump_enabled()) 2390 if (WebRTCInternals::GetInstance()->audio_debug_recordings_enabled()) {
2365 EnableAecDump(WebRTCInternals::GetInstance()->aec_dump_file_path()); 2391 EnableAudioDebugRecordings(
2392 WebRTCInternals::GetInstance()->audio_debug_recordings_file_path());
2393 }
2366 #endif 2394 #endif
2367 } 2395 }
2368 2396
2369 void RenderProcessHostImpl::OnProcessLaunchFailed() { 2397 void RenderProcessHostImpl::OnProcessLaunchFailed() {
2370 // If this object will be destructed soon, then observers have already been 2398 // If this object will be destructed soon, then observers have already been
2371 // sent a RenderProcessHostDestroyed notification, and we must observe our 2399 // sent a RenderProcessHostDestroyed notification, and we must observe our
2372 // contract that says that will be the last call. 2400 // contract that says that will be the last call.
2373 if (deleting_soon_) 2401 if (deleting_soon_)
2374 return; 2402 return;
2375 2403
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
2434 FROM_HERE, 2462 FROM_HERE,
2435 base::Bind( 2463 base::Bind(
2436 &RenderProcessHostImpl::UnregisterAecDumpConsumerOnUIThread, 2464 &RenderProcessHostImpl::UnregisterAecDumpConsumerOnUIThread,
2437 weak_factory_.GetWeakPtr(), 2465 weak_factory_.GetWeakPtr(),
2438 id)); 2466 id));
2439 } 2467 }
2440 2468
2441 void RenderProcessHostImpl::RegisterAecDumpConsumerOnUIThread(int id) { 2469 void RenderProcessHostImpl::RegisterAecDumpConsumerOnUIThread(int id) {
2442 DCHECK_CURRENTLY_ON(BrowserThread::UI); 2470 DCHECK_CURRENTLY_ON(BrowserThread::UI);
2443 aec_dump_consumers_.push_back(id); 2471 aec_dump_consumers_.push_back(id);
2444 if (WebRTCInternals::GetInstance()->aec_dump_enabled()) { 2472 if (WebRTCInternals::GetInstance()->audio_debug_recordings_enabled()) {
2445 EnableAecDumpForId(WebRTCInternals::GetInstance()->aec_dump_file_path(), 2473 EnableAecDumpForId(
2446 id); 2474 GetAecDumpFilePathWithExtensions(
2475 WebRTCInternals::GetInstance()->audio_debug_recordings_file_path()),
2476 id);
2447 } 2477 }
2448 } 2478 }
2449 2479
2450 void RenderProcessHostImpl::UnregisterAecDumpConsumerOnUIThread(int id) { 2480 void RenderProcessHostImpl::UnregisterAecDumpConsumerOnUIThread(int id) {
2451 DCHECK_CURRENTLY_ON(BrowserThread::UI); 2481 DCHECK_CURRENTLY_ON(BrowserThread::UI);
2452 for (std::vector<int>::iterator it = aec_dump_consumers_.begin(); 2482 for (std::vector<int>::iterator it = aec_dump_consumers_.begin();
2453 it != aec_dump_consumers_.end(); ++it) { 2483 it != aec_dump_consumers_.end(); ++it) {
2454 if (*it == id) { 2484 if (*it == id) {
2455 aec_dump_consumers_.erase(it); 2485 aec_dump_consumers_.erase(it);
2456 break; 2486 break;
2457 } 2487 }
2458 } 2488 }
2459 } 2489 }
2460 2490
2461 #if defined(OS_WIN)
2462 #define IntToStringType base::IntToString16
2463 #else
2464 #define IntToStringType base::IntToString
2465 #endif
2466
2467 void RenderProcessHostImpl::EnableAecDumpForId(const base::FilePath& file, 2491 void RenderProcessHostImpl::EnableAecDumpForId(const base::FilePath& file,
2468 int id) { 2492 int id) {
2469 DCHECK_CURRENTLY_ON(BrowserThread::UI); 2493 DCHECK_CURRENTLY_ON(BrowserThread::UI);
2470 base::FilePath unique_file =
2471 file.AddExtension(IntToStringType(base::GetProcId(GetHandle())))
2472 .AddExtension(IntToStringType(id));
2473 BrowserThread::PostTaskAndReplyWithResult( 2494 BrowserThread::PostTaskAndReplyWithResult(
2474 BrowserThread::FILE, FROM_HERE, 2495 BrowserThread::FILE, FROM_HERE,
2475 base::Bind(&CreateAecDumpFileForProcess, unique_file, GetHandle()), 2496 base::Bind(&CreateAecDumpFileForProcess,
2497 file.AddExtension(IntToStringType(id)),
2498 GetHandle()),
2476 base::Bind(&RenderProcessHostImpl::SendAecDumpFileToRenderer, 2499 base::Bind(&RenderProcessHostImpl::SendAecDumpFileToRenderer,
2477 weak_factory_.GetWeakPtr(), 2500 weak_factory_.GetWeakPtr(),
2478 id)); 2501 id));
2479 } 2502 }
2480 2503
2481 #undef IntToStringType
2482
2483 void RenderProcessHostImpl::SendAecDumpFileToRenderer( 2504 void RenderProcessHostImpl::SendAecDumpFileToRenderer(
2484 int id, 2505 int id,
2485 IPC::PlatformFileForTransit file_for_transit) { 2506 IPC::PlatformFileForTransit file_for_transit) {
2486 if (file_for_transit == IPC::InvalidPlatformFileForTransit()) 2507 if (file_for_transit == IPC::InvalidPlatformFileForTransit())
2487 return; 2508 return;
2488 Send(new AecDumpMsg_EnableAecDump(id, file_for_transit)); 2509 Send(new AecDumpMsg_EnableAecDump(id, file_for_transit));
2489 } 2510 }
2490 2511
2491 void RenderProcessHostImpl::SendDisableAecDumpToRenderer() { 2512 void RenderProcessHostImpl::SendDisableAecDumpToRenderer() {
2492 Send(new AecDumpMsg_DisableAecDump()); 2513 Send(new AecDumpMsg_DisableAecDump());
2493 } 2514 }
2515
2516 base::FilePath RenderProcessHostImpl::GetAecDumpFilePathWithExtensions(
2517 const base::FilePath& file) {
2518 return file.AddExtension(kAecDumpFileNameAddition)
2519 .AddExtension(IntToStringType(base::GetProcId(GetHandle())));
2520 }
2494 #endif 2521 #endif
2495 2522
2496 void RenderProcessHostImpl::IncrementWorkerRefCount() { 2523 void RenderProcessHostImpl::IncrementWorkerRefCount() {
2497 DCHECK_CURRENTLY_ON(BrowserThread::UI); 2524 DCHECK_CURRENTLY_ON(BrowserThread::UI);
2498 ++worker_ref_count_; 2525 ++worker_ref_count_;
2499 if (worker_ref_count_ > max_worker_count_) 2526 if (worker_ref_count_ > max_worker_count_)
2500 max_worker_count_ = worker_ref_count_; 2527 max_worker_count_ = worker_ref_count_;
2501 } 2528 }
2502 2529
2503 void RenderProcessHostImpl::DecrementWorkerRefCount() { 2530 void RenderProcessHostImpl::DecrementWorkerRefCount() {
2504 DCHECK_CURRENTLY_ON(BrowserThread::UI); 2531 DCHECK_CURRENTLY_ON(BrowserThread::UI);
2505 DCHECK_GT(worker_ref_count_, 0); 2532 DCHECK_GT(worker_ref_count_, 0);
2506 --worker_ref_count_; 2533 --worker_ref_count_;
2507 if (worker_ref_count_ == 0) 2534 if (worker_ref_count_ == 0)
2508 Cleanup(); 2535 Cleanup();
2509 } 2536 }
2510 2537
2511 void RenderProcessHostImpl::GetAudioOutputControllers( 2538 void RenderProcessHostImpl::GetAudioOutputControllers(
2512 const GetAudioOutputControllersCallback& callback) const { 2539 const GetAudioOutputControllersCallback& callback) const {
2513 audio_renderer_host()->GetOutputControllers(callback); 2540 audio_renderer_host()->GetOutputControllers(callback);
2514 } 2541 }
2515 2542
2516 BluetoothDispatcherHost* RenderProcessHostImpl::GetBluetoothDispatcherHost() { 2543 BluetoothDispatcherHost* RenderProcessHostImpl::GetBluetoothDispatcherHost() {
2517 return bluetooth_dispatcher_host_.get(); 2544 return bluetooth_dispatcher_host_.get();
2518 } 2545 }
2519 2546
2520 } // namespace content 2547 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698