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

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: Code review 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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 203
204 #if defined(ENABLE_WEBRTC) 204 #if defined(ENABLE_WEBRTC)
205 #include "content/browser/media/webrtc_internals.h" 205 #include "content/browser/media/webrtc_internals.h"
206 #include "content/browser/renderer_host/media/media_stream_track_metrics_host.h" 206 #include "content/browser/renderer_host/media/media_stream_track_metrics_host.h"
207 #include "content/browser/renderer_host/media/webrtc_identity_service_host.h" 207 #include "content/browser/renderer_host/media/webrtc_identity_service_host.h"
208 #include "content/browser/renderer_host/p2p/socket_dispatcher_host.h" 208 #include "content/browser/renderer_host/p2p/socket_dispatcher_host.h"
209 #include "content/common/media/aec_dump_messages.h" 209 #include "content/common/media/aec_dump_messages.h"
210 #include "content/common/media/media_stream_messages.h" 210 #include "content/common/media/media_stream_messages.h"
211 #endif 211 #endif
212 212
213 #if defined(OS_WIN)
214 #define IntToStringType base::IntToString16
215 #else
216 #define IntToStringType base::IntToString
217 #endif
218
213 extern bool g_exited_main_message_loop; 219 extern bool g_exited_main_message_loop;
214 220
215 namespace content { 221 namespace content {
216 namespace { 222 namespace {
217 223
218 const char kSiteProcessMapKeyName[] = "content_site_process_map"; 224 const char kSiteProcessMapKeyName[] = "content_site_process_map";
219 225
226 const char kAecDumpFileNameAddition[] = "aec_dump";
227
220 void CacheShaderInfo(int32 id, base::FilePath path) { 228 void CacheShaderInfo(int32 id, base::FilePath path) {
221 ShaderCacheFactory::GetInstance()->SetCacheInfo(id, path); 229 ShaderCacheFactory::GetInstance()->SetCacheInfo(id, path);
222 } 230 }
223 231
224 void RemoveShaderInfo(int32 id) { 232 void RemoveShaderInfo(int32 id) {
225 ShaderCacheFactory::GetInstance()->RemoveCacheInfo(id); 233 ShaderCacheFactory::GetInstance()->RemoveCacheInfo(id);
226 } 234 }
227 235
228 net::URLRequestContext* GetRequestContext( 236 net::URLRequestContext* GetRequestContext(
229 scoped_refptr<net::URLRequestContextGetter> request_context, 237 scoped_refptr<net::URLRequestContextGetter> request_context,
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after
783 storage_partition_impl_->GetAppCacheService(), 791 storage_partition_impl_->GetAppCacheService(),
784 ChromeBlobStorageContext::GetFor(browser_context), 792 ChromeBlobStorageContext::GetFor(browser_context),
785 storage_partition_impl_->GetFileSystemContext(), 793 storage_partition_impl_->GetFileSystemContext(),
786 storage_partition_impl_->GetServiceWorkerContext(), 794 storage_partition_impl_->GetServiceWorkerContext(),
787 storage_partition_impl_->GetHostZoomLevelContext(), 795 storage_partition_impl_->GetHostZoomLevelContext(),
788 get_contexts_callback); 796 get_contexts_callback);
789 797
790 AddFilter(resource_message_filter); 798 AddFilter(resource_message_filter);
791 MediaStreamManager* media_stream_manager = 799 MediaStreamManager* media_stream_manager =
792 BrowserMainLoop::GetInstance()->media_stream_manager(); 800 BrowserMainLoop::GetInstance()->media_stream_manager();
793 AddFilter(new AudioInputRendererHost( 801 // The AudioInputRendererHost and AudioRendererHost needs to be available for
802 // lookup, so it's stashed in a member variable.
803 audio_input_renderer_host_ = new AudioInputRendererHost(
794 GetID(), 804 GetID(),
805 this,
795 audio_manager, 806 audio_manager,
796 media_stream_manager, 807 media_stream_manager,
797 AudioMirroringManager::GetInstance(), 808 AudioMirroringManager::GetInstance(),
798 BrowserMainLoop::GetInstance()->user_input_monitor())); 809 BrowserMainLoop::GetInstance()->user_input_monitor());
799 // The AudioRendererHost needs to be available for lookup, so it's 810 AddFilter(audio_input_renderer_host_.get());
800 // stashed in a member variable.
801 audio_renderer_host_ = new AudioRendererHost( 811 audio_renderer_host_ = new AudioRendererHost(
802 GetID(), 812 GetID(),
803 audio_manager, 813 audio_manager,
804 AudioMirroringManager::GetInstance(), 814 AudioMirroringManager::GetInstance(),
805 media_internals, 815 media_internals,
806 media_stream_manager, 816 media_stream_manager,
807 browser_context->GetResourceContext()->GetMediaDeviceIDSalt()); 817 browser_context->GetResourceContext()->GetMediaDeviceIDSalt());
808 AddFilter(audio_renderer_host_.get()); 818 AddFilter(audio_renderer_host_.get());
809 AddFilter( 819 AddFilter(
810 new MidiHost(GetID(), BrowserMainLoop::GetInstance()->midi_manager())); 820 new MidiHost(GetID(), BrowserMainLoop::GetInstance()->midi_manager()));
(...skipping 937 matching lines...) Expand 10 before | Expand all | Expand 10 after
1748 1758
1749 void RenderProcessHostImpl::ResumeRequestsForView(int route_id) { 1759 void RenderProcessHostImpl::ResumeRequestsForView(int route_id) {
1750 widget_helper_->ResumeRequestsForView(route_id); 1760 widget_helper_->ResumeRequestsForView(route_id);
1751 } 1761 }
1752 1762
1753 void RenderProcessHostImpl::FilterURL(bool empty_allowed, GURL* url) { 1763 void RenderProcessHostImpl::FilterURL(bool empty_allowed, GURL* url) {
1754 FilterURL(this, empty_allowed, url); 1764 FilterURL(this, empty_allowed, url);
1755 } 1765 }
1756 1766
1757 #if defined(ENABLE_WEBRTC) 1767 #if defined(ENABLE_WEBRTC)
1758 void RenderProcessHostImpl::EnableAecDump(const base::FilePath& file) { 1768 void RenderProcessHostImpl::EnableAudioDebugRecordings(
1769 const base::FilePath& file) {
1759 DCHECK_CURRENTLY_ON(BrowserThread::UI); 1770 DCHECK_CURRENTLY_ON(BrowserThread::UI);
1771
1760 // Enable AEC dump for each registered consumer. 1772 // Enable AEC dump for each registered consumer.
1773 base::FilePath file_with_extensions = GetAecDumpFilePathWithExtensions(file);
1761 for (std::vector<int>::iterator it = aec_dump_consumers_.begin(); 1774 for (std::vector<int>::iterator it = aec_dump_consumers_.begin();
1762 it != aec_dump_consumers_.end(); ++it) { 1775 it != aec_dump_consumers_.end(); ++it) {
1763 EnableAecDumpForId(file, *it); 1776 EnableAecDumpForId(file_with_extensions, *it);
1764 } 1777 }
1778
1779 // Enable mic input recording.
1780 BrowserThread::PostTask(
1781 BrowserThread::IO, FROM_HERE,
1782 base::Bind(&AudioInputRendererHost::EnableDebugRecording,
1783 audio_input_renderer_host_,
1784 file));
1765 } 1785 }
1766 1786
1767 void RenderProcessHostImpl::DisableAecDump() { 1787 void RenderProcessHostImpl::DisableAudioDebugRecordings() {
1768 DCHECK_CURRENTLY_ON(BrowserThread::UI); 1788 DCHECK_CURRENTLY_ON(BrowserThread::UI);
1789
1769 // Posting on the FILE thread and then replying back on the UI thread is only 1790 // Posting on the FILE thread and then replying back on the UI thread is only
1770 // for avoiding races between enable and disable. Nothing is done on the FILE 1791 // for avoiding races between enable and disable. Nothing is done on the FILE
1771 // thread. 1792 // thread.
1772 BrowserThread::PostTaskAndReply( 1793 BrowserThread::PostTaskAndReply(
1773 BrowserThread::FILE, FROM_HERE, 1794 BrowserThread::FILE, FROM_HERE,
1774 base::Bind(&DisableAecDumpOnFileThread), 1795 base::Bind(&DisableAecDumpOnFileThread),
1775 base::Bind(&RenderProcessHostImpl::SendDisableAecDumpToRenderer, 1796 base::Bind(&RenderProcessHostImpl::SendDisableAecDumpToRenderer,
1776 weak_factory_.GetWeakPtr())); 1797 weak_factory_.GetWeakPtr()));
1798 BrowserThread::PostTask(
1799 BrowserThread::IO, FROM_HERE,
1800 base::Bind(
1801 &AudioInputRendererHost::DisableDebugRecording,
1802 audio_input_renderer_host_));
1777 } 1803 }
1778 1804
1779 void RenderProcessHostImpl::SetWebRtcLogMessageCallback( 1805 void RenderProcessHostImpl::SetWebRtcLogMessageCallback(
1780 base::Callback<void(const std::string&)> callback) { 1806 base::Callback<void(const std::string&)> callback) {
1781 webrtc_log_message_callback_ = callback; 1807 webrtc_log_message_callback_ = callback;
1782 } 1808 }
1783 1809
1784 RenderProcessHostImpl::WebRtcStopRtpDumpCallback 1810 RenderProcessHostImpl::WebRtcStopRtpDumpCallback
1785 RenderProcessHostImpl::StartRtpDump( 1811 RenderProcessHostImpl::StartRtpDump(
1786 bool incoming, 1812 bool incoming,
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after
2370 Send(queued_messages_.front()); 2396 Send(queued_messages_.front());
2371 queued_messages_.pop(); 2397 queued_messages_.pop();
2372 } 2398 }
2373 2399
2374 #if defined(ENABLE_WEBRTC) 2400 #if defined(ENABLE_WEBRTC)
2375 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/465841 2401 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/465841
2376 // is fixed. 2402 // is fixed.
2377 tracked_objects::ScopedTracker tracking_profile7( 2403 tracked_objects::ScopedTracker tracking_profile7(
2378 FROM_HERE_WITH_EXPLICIT_FUNCTION( 2404 FROM_HERE_WITH_EXPLICIT_FUNCTION(
2379 "465841 RenderProcessHostImpl::OnProcessLaunched::EnableAec")); 2405 "465841 RenderProcessHostImpl::OnProcessLaunched::EnableAec"));
2380 if (WebRTCInternals::GetInstance()->aec_dump_enabled()) 2406 if (WebRTCInternals::GetInstance()->IsAudioDebugRecordingsEnabled()) {
2381 EnableAecDump(WebRTCInternals::GetInstance()->aec_dump_file_path()); 2407 EnableAudioDebugRecordings(
2408 WebRTCInternals::GetInstance()->GetAudioDebugRecordingsFilePath());
2409 }
2382 #endif 2410 #endif
2383 } 2411 }
2384 2412
2385 void RenderProcessHostImpl::OnProcessLaunchFailed() { 2413 void RenderProcessHostImpl::OnProcessLaunchFailed() {
2386 // If this object will be destructed soon, then observers have already been 2414 // If this object will be destructed soon, then observers have already been
2387 // sent a RenderProcessHostDestroyed notification, and we must observe our 2415 // sent a RenderProcessHostDestroyed notification, and we must observe our
2388 // contract that says that will be the last call. 2416 // contract that says that will be the last call.
2389 if (deleting_soon_) 2417 if (deleting_soon_)
2390 return; 2418 return;
2391 2419
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
2450 FROM_HERE, 2478 FROM_HERE,
2451 base::Bind( 2479 base::Bind(
2452 &RenderProcessHostImpl::UnregisterAecDumpConsumerOnUIThread, 2480 &RenderProcessHostImpl::UnregisterAecDumpConsumerOnUIThread,
2453 weak_factory_.GetWeakPtr(), 2481 weak_factory_.GetWeakPtr(),
2454 id)); 2482 id));
2455 } 2483 }
2456 2484
2457 void RenderProcessHostImpl::RegisterAecDumpConsumerOnUIThread(int id) { 2485 void RenderProcessHostImpl::RegisterAecDumpConsumerOnUIThread(int id) {
2458 DCHECK_CURRENTLY_ON(BrowserThread::UI); 2486 DCHECK_CURRENTLY_ON(BrowserThread::UI);
2459 aec_dump_consumers_.push_back(id); 2487 aec_dump_consumers_.push_back(id);
2460 if (WebRTCInternals::GetInstance()->aec_dump_enabled()) { 2488 if (WebRTCInternals::GetInstance()->IsAudioDebugRecordingsEnabled()) {
2461 EnableAecDumpForId(WebRTCInternals::GetInstance()->aec_dump_file_path(), 2489 EnableAecDumpForId(
2462 id); 2490 GetAecDumpFilePathWithExtensions(
2491 WebRTCInternals::GetInstance()->GetAudioDebugRecordingsFilePath()),
2492 id);
2463 } 2493 }
2464 } 2494 }
2465 2495
2466 void RenderProcessHostImpl::UnregisterAecDumpConsumerOnUIThread(int id) { 2496 void RenderProcessHostImpl::UnregisterAecDumpConsumerOnUIThread(int id) {
2467 DCHECK_CURRENTLY_ON(BrowserThread::UI); 2497 DCHECK_CURRENTLY_ON(BrowserThread::UI);
2468 for (std::vector<int>::iterator it = aec_dump_consumers_.begin(); 2498 for (std::vector<int>::iterator it = aec_dump_consumers_.begin();
2469 it != aec_dump_consumers_.end(); ++it) { 2499 it != aec_dump_consumers_.end(); ++it) {
2470 if (*it == id) { 2500 if (*it == id) {
2471 aec_dump_consumers_.erase(it); 2501 aec_dump_consumers_.erase(it);
2472 break; 2502 break;
2473 } 2503 }
2474 } 2504 }
2475 } 2505 }
2476 2506
2477 #if defined(OS_WIN)
2478 #define IntToStringType base::IntToString16
2479 #else
2480 #define IntToStringType base::IntToString
2481 #endif
2482
2483 void RenderProcessHostImpl::EnableAecDumpForId(const base::FilePath& file, 2507 void RenderProcessHostImpl::EnableAecDumpForId(const base::FilePath& file,
2484 int id) { 2508 int id) {
2485 DCHECK_CURRENTLY_ON(BrowserThread::UI); 2509 DCHECK_CURRENTLY_ON(BrowserThread::UI);
2486 base::FilePath unique_file =
2487 file.AddExtension(IntToStringType(base::GetProcId(GetHandle())))
2488 .AddExtension(IntToStringType(id));
2489 BrowserThread::PostTaskAndReplyWithResult( 2510 BrowserThread::PostTaskAndReplyWithResult(
2490 BrowserThread::FILE, FROM_HERE, 2511 BrowserThread::FILE, FROM_HERE,
2491 base::Bind(&CreateAecDumpFileForProcess, unique_file, GetHandle()), 2512 base::Bind(&CreateAecDumpFileForProcess,
2513 file.AddExtension(IntToStringType(id)),
2514 GetHandle()),
2492 base::Bind(&RenderProcessHostImpl::SendAecDumpFileToRenderer, 2515 base::Bind(&RenderProcessHostImpl::SendAecDumpFileToRenderer,
2493 weak_factory_.GetWeakPtr(), 2516 weak_factory_.GetWeakPtr(),
2494 id)); 2517 id));
2495 } 2518 }
2496 2519
2497 #undef IntToStringType
2498
2499 void RenderProcessHostImpl::SendAecDumpFileToRenderer( 2520 void RenderProcessHostImpl::SendAecDumpFileToRenderer(
2500 int id, 2521 int id,
2501 IPC::PlatformFileForTransit file_for_transit) { 2522 IPC::PlatformFileForTransit file_for_transit) {
2502 if (file_for_transit == IPC::InvalidPlatformFileForTransit()) 2523 if (file_for_transit == IPC::InvalidPlatformFileForTransit())
2503 return; 2524 return;
2504 Send(new AecDumpMsg_EnableAecDump(id, file_for_transit)); 2525 Send(new AecDumpMsg_EnableAecDump(id, file_for_transit));
2505 } 2526 }
2506 2527
2507 void RenderProcessHostImpl::SendDisableAecDumpToRenderer() { 2528 void RenderProcessHostImpl::SendDisableAecDumpToRenderer() {
2508 Send(new AecDumpMsg_DisableAecDump()); 2529 Send(new AecDumpMsg_DisableAecDump());
2509 } 2530 }
2531
2532 base::FilePath RenderProcessHostImpl::GetAecDumpFilePathWithExtensions(
2533 const base::FilePath& file) {
2534 return file.AddExtension(kAecDumpFileNameAddition)
2535 .AddExtension(IntToStringType(base::GetProcId(GetHandle())));
2536 }
2510 #endif 2537 #endif
2511 2538
2512 void RenderProcessHostImpl::IncrementWorkerRefCount() { 2539 void RenderProcessHostImpl::IncrementWorkerRefCount() {
2513 DCHECK_CURRENTLY_ON(BrowserThread::UI); 2540 DCHECK_CURRENTLY_ON(BrowserThread::UI);
2514 ++worker_ref_count_; 2541 ++worker_ref_count_;
2515 if (worker_ref_count_ > max_worker_count_) 2542 if (worker_ref_count_ > max_worker_count_)
2516 max_worker_count_ = worker_ref_count_; 2543 max_worker_count_ = worker_ref_count_;
2517 } 2544 }
2518 2545
2519 void RenderProcessHostImpl::DecrementWorkerRefCount() { 2546 void RenderProcessHostImpl::DecrementWorkerRefCount() {
2520 DCHECK_CURRENTLY_ON(BrowserThread::UI); 2547 DCHECK_CURRENTLY_ON(BrowserThread::UI);
2521 DCHECK_GT(worker_ref_count_, 0); 2548 DCHECK_GT(worker_ref_count_, 0);
2522 --worker_ref_count_; 2549 --worker_ref_count_;
2523 if (worker_ref_count_ == 0) 2550 if (worker_ref_count_ == 0)
2524 Cleanup(); 2551 Cleanup();
2525 } 2552 }
2526 2553
2527 void RenderProcessHostImpl::GetAudioOutputControllers( 2554 void RenderProcessHostImpl::GetAudioOutputControllers(
2528 const GetAudioOutputControllersCallback& callback) const { 2555 const GetAudioOutputControllersCallback& callback) const {
2529 audio_renderer_host()->GetOutputControllers(callback); 2556 audio_renderer_host()->GetOutputControllers(callback);
2530 } 2557 }
2531 2558
2532 BluetoothDispatcherHost* RenderProcessHostImpl::GetBluetoothDispatcherHost() { 2559 BluetoothDispatcherHost* RenderProcessHostImpl::GetBluetoothDispatcherHost() {
2533 return bluetooth_dispatcher_host_.get(); 2560 return bluetooth_dispatcher_host_.get();
2534 } 2561 }
2535 2562
2536 } // namespace content 2563 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698