Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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(), |
| 806 this, | |
| 796 audio_manager, | 807 audio_manager, |
| 797 media_stream_manager, | 808 media_stream_manager, |
| 798 AudioMirroringManager::GetInstance(), | 809 AudioMirroringManager::GetInstance(), |
| 799 BrowserMainLoop::GetInstance()->user_input_monitor())); | 810 BrowserMainLoop::GetInstance()->user_input_monitor()); |
| 800 // The AudioRendererHost needs to be available for lookup, so it's | 811 AddFilter(audio_input_renderer_host_.get()); |
| 801 // stashed in a member variable. | |
| 802 audio_renderer_host_ = new AudioRendererHost( | 812 audio_renderer_host_ = new AudioRendererHost( |
| 803 GetID(), | 813 GetID(), |
| 804 audio_manager, | 814 audio_manager, |
| 805 AudioMirroringManager::GetInstance(), | 815 AudioMirroringManager::GetInstance(), |
| 806 media_internals, | 816 media_internals, |
| 807 media_stream_manager, | 817 media_stream_manager, |
| 808 browser_context->GetResourceContext()->GetMediaDeviceIDSalt()); | 818 browser_context->GetResourceContext()->GetMediaDeviceIDSalt()); |
| 809 AddFilter(audio_renderer_host_.get()); | 819 AddFilter(audio_renderer_host_.get()); |
| 810 AddFilter( | 820 AddFilter( |
| 811 new MidiHost(GetID(), BrowserMainLoop::GetInstance()->midi_manager())); | 821 new MidiHost(GetID(), BrowserMainLoop::GetInstance()->midi_manager())); |
| (...skipping 940 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1752 | 1762 |
| 1753 void RenderProcessHostImpl::ResumeRequestsForView(int route_id) { | 1763 void RenderProcessHostImpl::ResumeRequestsForView(int route_id) { |
| 1754 widget_helper_->ResumeRequestsForView(route_id); | 1764 widget_helper_->ResumeRequestsForView(route_id); |
| 1755 } | 1765 } |
| 1756 | 1766 |
| 1757 void RenderProcessHostImpl::FilterURL(bool empty_allowed, GURL* url) { | 1767 void RenderProcessHostImpl::FilterURL(bool empty_allowed, GURL* url) { |
| 1758 FilterURL(this, empty_allowed, url); | 1768 FilterURL(this, empty_allowed, url); |
| 1759 } | 1769 } |
| 1760 | 1770 |
| 1761 #if defined(ENABLE_WEBRTC) | 1771 #if defined(ENABLE_WEBRTC) |
| 1762 void RenderProcessHostImpl::EnableAecDump(const base::FilePath& file) { | 1772 void RenderProcessHostImpl::EnableAudioDebugRecordings( |
| 1773 const base::FilePath& file) { | |
| 1763 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1774 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1775 | |
| 1764 // Enable AEC dump for each registered consumer. | 1776 // Enable AEC dump for each registered consumer. |
| 1777 base::FilePath file_with_extensions = GetAecDumpFilePathWithExtensions(file); | |
| 1765 for (std::vector<int>::iterator it = aec_dump_consumers_.begin(); | 1778 for (std::vector<int>::iterator it = aec_dump_consumers_.begin(); |
| 1766 it != aec_dump_consumers_.end(); ++it) { | 1779 it != aec_dump_consumers_.end(); ++it) { |
| 1767 EnableAecDumpForId(file, *it); | 1780 EnableAecDumpForId(file_with_extensions, *it); |
| 1768 } | 1781 } |
| 1782 | |
| 1783 // Enable mic input recording. | |
| 1784 BrowserThread::PostTask( | |
| 1785 BrowserThread::IO, FROM_HERE, | |
| 1786 base::Bind(&AudioInputRendererHost::EnableDebugRecording, | |
| 1787 audio_input_renderer_host_, | |
|
nasko
2015/08/19 22:04:15
How do we guarantee that audio_input_renderer_host
Henrik Grunell
2015/08/20 07:26:19
AudioInputRendererHost is reference counted. Added
| |
| 1788 file)); | |
| 1769 } | 1789 } |
| 1770 | 1790 |
| 1771 void RenderProcessHostImpl::DisableAecDump() { | 1791 void RenderProcessHostImpl::DisableAudioDebugRecordings() { |
| 1772 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1792 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1793 | |
| 1773 // Posting on the FILE thread and then replying back on the UI thread is only | 1794 // 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 | 1795 // for avoiding races between enable and disable. Nothing is done on the FILE |
| 1775 // thread. | 1796 // thread. |
| 1776 BrowserThread::PostTaskAndReply( | 1797 BrowserThread::PostTaskAndReply( |
| 1777 BrowserThread::FILE, FROM_HERE, | 1798 BrowserThread::FILE, FROM_HERE, |
| 1778 base::Bind(&DisableAecDumpOnFileThread), | 1799 base::Bind(&DisableAecDumpOnFileThread), |
| 1779 base::Bind(&RenderProcessHostImpl::SendDisableAecDumpToRenderer, | 1800 base::Bind(&RenderProcessHostImpl::SendDisableAecDumpToRenderer, |
| 1780 weak_factory_.GetWeakPtr())); | 1801 weak_factory_.GetWeakPtr())); |
| 1802 BrowserThread::PostTask( | |
| 1803 BrowserThread::IO, FROM_HERE, | |
| 1804 base::Bind( | |
| 1805 &AudioInputRendererHost::DisableDebugRecording, | |
| 1806 audio_input_renderer_host_)); | |
|
nasko
2015/08/19 22:04:15
Same as above, it isn't clear how we guarantee lif
Henrik Grunell
2015/08/20 07:26:19
Ditto.
| |
| 1781 } | 1807 } |
| 1782 | 1808 |
| 1783 void RenderProcessHostImpl::SetWebRtcLogMessageCallback( | 1809 void RenderProcessHostImpl::SetWebRtcLogMessageCallback( |
| 1784 base::Callback<void(const std::string&)> callback) { | 1810 base::Callback<void(const std::string&)> callback) { |
| 1785 webrtc_log_message_callback_ = callback; | 1811 webrtc_log_message_callback_ = callback; |
| 1786 } | 1812 } |
| 1787 | 1813 |
| 1788 RenderProcessHostImpl::WebRtcStopRtpDumpCallback | 1814 RenderProcessHostImpl::WebRtcStopRtpDumpCallback |
| 1789 RenderProcessHostImpl::StartRtpDump( | 1815 RenderProcessHostImpl::StartRtpDump( |
| 1790 bool incoming, | 1816 bool incoming, |
| (...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2374 Send(queued_messages_.front()); | 2400 Send(queued_messages_.front()); |
| 2375 queued_messages_.pop(); | 2401 queued_messages_.pop(); |
| 2376 } | 2402 } |
| 2377 | 2403 |
| 2378 #if defined(ENABLE_WEBRTC) | 2404 #if defined(ENABLE_WEBRTC) |
| 2379 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/465841 | 2405 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/465841 |
| 2380 // is fixed. | 2406 // is fixed. |
| 2381 tracked_objects::ScopedTracker tracking_profile7( | 2407 tracked_objects::ScopedTracker tracking_profile7( |
| 2382 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 2408 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 2383 "465841 RenderProcessHostImpl::OnProcessLaunched::EnableAec")); | 2409 "465841 RenderProcessHostImpl::OnProcessLaunched::EnableAec")); |
| 2384 if (WebRTCInternals::GetInstance()->aec_dump_enabled()) | 2410 if (WebRTCInternals::GetInstance()->IsAudioDebugRecordingsEnabled()) { |
| 2385 EnableAecDump(WebRTCInternals::GetInstance()->aec_dump_file_path()); | 2411 EnableAudioDebugRecordings( |
| 2412 WebRTCInternals::GetInstance()->GetAudioDebugRecordingsFilePath()); | |
| 2413 } | |
| 2386 #endif | 2414 #endif |
| 2387 } | 2415 } |
| 2388 | 2416 |
| 2389 void RenderProcessHostImpl::OnProcessLaunchFailed() { | 2417 void RenderProcessHostImpl::OnProcessLaunchFailed() { |
| 2390 // If this object will be destructed soon, then observers have already been | 2418 // If this object will be destructed soon, then observers have already been |
| 2391 // sent a RenderProcessHostDestroyed notification, and we must observe our | 2419 // sent a RenderProcessHostDestroyed notification, and we must observe our |
| 2392 // contract that says that will be the last call. | 2420 // contract that says that will be the last call. |
| 2393 if (deleting_soon_) | 2421 if (deleting_soon_) |
| 2394 return; | 2422 return; |
| 2395 | 2423 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2454 FROM_HERE, | 2482 FROM_HERE, |
| 2455 base::Bind( | 2483 base::Bind( |
| 2456 &RenderProcessHostImpl::UnregisterAecDumpConsumerOnUIThread, | 2484 &RenderProcessHostImpl::UnregisterAecDumpConsumerOnUIThread, |
| 2457 weak_factory_.GetWeakPtr(), | 2485 weak_factory_.GetWeakPtr(), |
| 2458 id)); | 2486 id)); |
| 2459 } | 2487 } |
| 2460 | 2488 |
| 2461 void RenderProcessHostImpl::RegisterAecDumpConsumerOnUIThread(int id) { | 2489 void RenderProcessHostImpl::RegisterAecDumpConsumerOnUIThread(int id) { |
| 2462 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 2490 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 2463 aec_dump_consumers_.push_back(id); | 2491 aec_dump_consumers_.push_back(id); |
| 2464 if (WebRTCInternals::GetInstance()->aec_dump_enabled()) { | 2492 if (WebRTCInternals::GetInstance()->IsAudioDebugRecordingsEnabled()) { |
| 2465 EnableAecDumpForId(WebRTCInternals::GetInstance()->aec_dump_file_path(), | 2493 EnableAecDumpForId( |
| 2466 id); | 2494 GetAecDumpFilePathWithExtensions( |
| 2495 WebRTCInternals::GetInstance()->GetAudioDebugRecordingsFilePath()), | |
| 2496 id); | |
| 2467 } | 2497 } |
| 2468 } | 2498 } |
| 2469 | 2499 |
| 2470 void RenderProcessHostImpl::UnregisterAecDumpConsumerOnUIThread(int id) { | 2500 void RenderProcessHostImpl::UnregisterAecDumpConsumerOnUIThread(int id) { |
| 2471 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 2501 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 2472 for (std::vector<int>::iterator it = aec_dump_consumers_.begin(); | 2502 for (std::vector<int>::iterator it = aec_dump_consumers_.begin(); |
| 2473 it != aec_dump_consumers_.end(); ++it) { | 2503 it != aec_dump_consumers_.end(); ++it) { |
| 2474 if (*it == id) { | 2504 if (*it == id) { |
| 2475 aec_dump_consumers_.erase(it); | 2505 aec_dump_consumers_.erase(it); |
| 2476 break; | 2506 break; |
| 2477 } | 2507 } |
| 2478 } | 2508 } |
| 2479 } | 2509 } |
| 2480 | 2510 |
| 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, | 2511 void RenderProcessHostImpl::EnableAecDumpForId(const base::FilePath& file, |
| 2488 int id) { | 2512 int id) { |
| 2489 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 2513 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 2490 base::FilePath unique_file = | |
| 2491 file.AddExtension(IntToStringType(base::GetProcId(GetHandle()))) | |
| 2492 .AddExtension(IntToStringType(id)); | |
| 2493 BrowserThread::PostTaskAndReplyWithResult( | 2514 BrowserThread::PostTaskAndReplyWithResult( |
| 2494 BrowserThread::FILE, FROM_HERE, | 2515 BrowserThread::FILE, FROM_HERE, |
| 2495 base::Bind(&CreateAecDumpFileForProcess, unique_file, GetHandle()), | 2516 base::Bind(&CreateAecDumpFileForProcess, |
| 2517 file.AddExtension(IntToStringType(id)), | |
| 2518 GetHandle()), | |
| 2496 base::Bind(&RenderProcessHostImpl::SendAecDumpFileToRenderer, | 2519 base::Bind(&RenderProcessHostImpl::SendAecDumpFileToRenderer, |
| 2497 weak_factory_.GetWeakPtr(), | 2520 weak_factory_.GetWeakPtr(), |
| 2498 id)); | 2521 id)); |
| 2499 } | 2522 } |
| 2500 | 2523 |
| 2501 #undef IntToStringType | |
| 2502 | |
| 2503 void RenderProcessHostImpl::SendAecDumpFileToRenderer( | 2524 void RenderProcessHostImpl::SendAecDumpFileToRenderer( |
| 2504 int id, | 2525 int id, |
| 2505 IPC::PlatformFileForTransit file_for_transit) { | 2526 IPC::PlatformFileForTransit file_for_transit) { |
| 2506 if (file_for_transit == IPC::InvalidPlatformFileForTransit()) | 2527 if (file_for_transit == IPC::InvalidPlatformFileForTransit()) |
| 2507 return; | 2528 return; |
| 2508 Send(new AecDumpMsg_EnableAecDump(id, file_for_transit)); | 2529 Send(new AecDumpMsg_EnableAecDump(id, file_for_transit)); |
| 2509 } | 2530 } |
| 2510 | 2531 |
| 2511 void RenderProcessHostImpl::SendDisableAecDumpToRenderer() { | 2532 void RenderProcessHostImpl::SendDisableAecDumpToRenderer() { |
| 2512 Send(new AecDumpMsg_DisableAecDump()); | 2533 Send(new AecDumpMsg_DisableAecDump()); |
| 2513 } | 2534 } |
| 2535 | |
| 2536 base::FilePath RenderProcessHostImpl::GetAecDumpFilePathWithExtensions( | |
| 2537 const base::FilePath& file) { | |
| 2538 return file.AddExtension(kAecDumpFileNameAddition) | |
| 2539 .AddExtension(IntToStringType(base::GetProcId(GetHandle()))); | |
| 2540 } | |
| 2514 #endif | 2541 #endif |
| 2515 | 2542 |
| 2516 void RenderProcessHostImpl::IncrementWorkerRefCount() { | 2543 void RenderProcessHostImpl::IncrementWorkerRefCount() { |
| 2517 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 2544 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 2518 ++worker_ref_count_; | 2545 ++worker_ref_count_; |
| 2519 if (worker_ref_count_ > max_worker_count_) | 2546 if (worker_ref_count_ > max_worker_count_) |
| 2520 max_worker_count_ = worker_ref_count_; | 2547 max_worker_count_ = worker_ref_count_; |
| 2521 } | 2548 } |
| 2522 | 2549 |
| 2523 void RenderProcessHostImpl::DecrementWorkerRefCount() { | 2550 void RenderProcessHostImpl::DecrementWorkerRefCount() { |
| 2524 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 2551 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 2525 DCHECK_GT(worker_ref_count_, 0); | 2552 DCHECK_GT(worker_ref_count_, 0); |
| 2526 --worker_ref_count_; | 2553 --worker_ref_count_; |
| 2527 if (worker_ref_count_ == 0) | 2554 if (worker_ref_count_ == 0) |
| 2528 Cleanup(); | 2555 Cleanup(); |
| 2529 } | 2556 } |
| 2530 | 2557 |
| 2531 void RenderProcessHostImpl::GetAudioOutputControllers( | 2558 void RenderProcessHostImpl::GetAudioOutputControllers( |
| 2532 const GetAudioOutputControllersCallback& callback) const { | 2559 const GetAudioOutputControllersCallback& callback) const { |
| 2533 audio_renderer_host()->GetOutputControllers(callback); | 2560 audio_renderer_host()->GetOutputControllers(callback); |
| 2534 } | 2561 } |
| 2535 | 2562 |
| 2536 BluetoothDispatcherHost* RenderProcessHostImpl::GetBluetoothDispatcherHost() { | 2563 BluetoothDispatcherHost* RenderProcessHostImpl::GetBluetoothDispatcherHost() { |
| 2537 return bluetooth_dispatcher_host_.get(); | 2564 return bluetooth_dispatcher_host_.get(); |
| 2538 } | 2565 } |
| 2539 | 2566 |
| 2540 } // namespace content | 2567 } // namespace content |
| OLD | NEW |