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

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

Powered by Google App Engine
This is Rietveld 408576698