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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
95 #include "content/browser/permissions/permission_service_context.h" | 95 #include "content/browser/permissions/permission_service_context.h" |
96 #include "content/browser/permissions/permission_service_impl.h" | 96 #include "content/browser/permissions/permission_service_impl.h" |
97 #include "content/browser/profiler_message_filter.h" | 97 #include "content/browser/profiler_message_filter.h" |
98 #include "content/browser/push_messaging/push_messaging_message_filter.h" | 98 #include "content/browser/push_messaging/push_messaging_message_filter.h" |
99 #include "content/browser/quota_dispatcher_host.h" | 99 #include "content/browser/quota_dispatcher_host.h" |
100 #include "content/browser/renderer_host/clipboard_message_filter.h" | 100 #include "content/browser/renderer_host/clipboard_message_filter.h" |
101 #include "content/browser/renderer_host/database_message_filter.h" | 101 #include "content/browser/renderer_host/database_message_filter.h" |
102 #include "content/browser/renderer_host/file_utilities_message_filter.h" | 102 #include "content/browser/renderer_host/file_utilities_message_filter.h" |
103 #include "content/browser/renderer_host/media/audio_input_renderer_host.h" | 103 #include "content/browser/renderer_host/media/audio_input_renderer_host.h" |
104 #include "content/browser/renderer_host/media/audio_renderer_host.h" | 104 #include "content/browser/renderer_host/media/audio_renderer_host.h" |
105 #include "content/browser/renderer_host/media/audio_stream_registry_impl.h" | |
105 #include "content/browser/renderer_host/media/media_stream_dispatcher_host.h" | 106 #include "content/browser/renderer_host/media/media_stream_dispatcher_host.h" |
106 #include "content/browser/renderer_host/media/peer_connection_tracker_host.h" | 107 #include "content/browser/renderer_host/media/peer_connection_tracker_host.h" |
107 #include "content/browser/renderer_host/media/video_capture_host.h" | 108 #include "content/browser/renderer_host/media/video_capture_host.h" |
108 #include "content/browser/renderer_host/offscreen_canvas_compositor_frame_sink_p rovider_impl.h" | 109 #include "content/browser/renderer_host/offscreen_canvas_compositor_frame_sink_p rovider_impl.h" |
109 #include "content/browser/renderer_host/offscreen_canvas_surface_factory_impl.h" | 110 #include "content/browser/renderer_host/offscreen_canvas_surface_factory_impl.h" |
110 #include "content/browser/renderer_host/pepper/pepper_message_filter.h" | 111 #include "content/browser/renderer_host/pepper/pepper_message_filter.h" |
111 #include "content/browser/renderer_host/pepper/pepper_renderer_connection.h" | 112 #include "content/browser/renderer_host/pepper/pepper_renderer_connection.h" |
112 #include "content/browser/renderer_host/render_message_filter.h" | 113 #include "content/browser/renderer_host/render_message_filter.h" |
113 #include "content/browser/renderer_host/render_view_host_delegate.h" | 114 #include "content/browser/renderer_host/render_view_host_delegate.h" |
114 #include "content/browser/renderer_host/render_view_host_impl.h" | 115 #include "content/browser/renderer_host/render_view_host_impl.h" |
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
673 is_process_backgrounded_(false), | 674 is_process_backgrounded_(false), |
674 id_(ChildProcessHostImpl::GenerateChildProcessUniqueId()), | 675 id_(ChildProcessHostImpl::GenerateChildProcessUniqueId()), |
675 browser_context_(browser_context), | 676 browser_context_(browser_context), |
676 storage_partition_impl_(storage_partition_impl), | 677 storage_partition_impl_(storage_partition_impl), |
677 sudden_termination_allowed_(true), | 678 sudden_termination_allowed_(true), |
678 ignore_input_events_(false), | 679 ignore_input_events_(false), |
679 is_for_guests_only_(is_for_guests_only), | 680 is_for_guests_only_(is_for_guests_only), |
680 gpu_observer_registered_(false), | 681 gpu_observer_registered_(false), |
681 delayed_cleanup_needed_(false), | 682 delayed_cleanup_needed_(false), |
682 within_process_died_observer_(false), | 683 within_process_died_observer_(false), |
684 audio_stream_registry_(AudioStreamRegistryImpl::Create(id_)), | |
683 #if BUILDFLAG(ENABLE_WEBRTC) | 685 #if BUILDFLAG(ENABLE_WEBRTC) |
684 webrtc_eventlog_host_(id_), | 686 webrtc_eventlog_host_(id_), |
685 #endif | 687 #endif |
686 max_worker_count_(0), | 688 max_worker_count_(0), |
687 permission_service_context_(new PermissionServiceContext(this)), | 689 permission_service_context_(new PermissionServiceContext(this)), |
688 channel_connected_(false), | 690 channel_connected_(false), |
689 sent_render_process_ready_(false), | 691 sent_render_process_ready_(false), |
690 #if defined(OS_ANDROID) | 692 #if defined(OS_ANDROID) |
691 never_signaled_(base::WaitableEvent::ResetPolicy::MANUAL, | 693 never_signaled_(base::WaitableEvent::ResetPolicy::MANUAL, |
692 base::WaitableEvent::InitialState::NOT_SIGNALED), | 694 base::WaitableEvent::InitialState::NOT_SIGNALED), |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1065 MediaStreamManager* media_stream_manager = | 1067 MediaStreamManager* media_stream_manager = |
1066 BrowserMainLoop::GetInstance()->media_stream_manager(); | 1068 BrowserMainLoop::GetInstance()->media_stream_manager(); |
1067 // The AudioInputRendererHost and AudioRendererHost needs to be available for | 1069 // The AudioInputRendererHost and AudioRendererHost needs to be available for |
1068 // lookup, so it's stashed in a member variable. | 1070 // lookup, so it's stashed in a member variable. |
1069 audio_input_renderer_host_ = new AudioInputRendererHost( | 1071 audio_input_renderer_host_ = new AudioInputRendererHost( |
1070 GetID(), base::GetProcId(GetHandle()), audio_manager, | 1072 GetID(), base::GetProcId(GetHandle()), audio_manager, |
1071 media_stream_manager, AudioMirroringManager::GetInstance(), | 1073 media_stream_manager, AudioMirroringManager::GetInstance(), |
1072 BrowserMainLoop::GetInstance()->user_input_monitor()); | 1074 BrowserMainLoop::GetInstance()->user_input_monitor()); |
1073 AddFilter(audio_input_renderer_host_.get()); | 1075 AddFilter(audio_input_renderer_host_.get()); |
1074 audio_renderer_host_ = new AudioRendererHost( | 1076 audio_renderer_host_ = new AudioRendererHost( |
1075 GetID(), audio_manager, AudioMirroringManager::GetInstance(), | 1077 GetID(), audio_stream_registry_.get(), audio_manager, |
1076 media_stream_manager, | 1078 AudioMirroringManager::GetInstance(), media_stream_manager, |
1077 browser_context->GetResourceContext()->GetMediaDeviceIDSalt()); | 1079 browser_context->GetResourceContext()->GetMediaDeviceIDSalt()); |
1078 AddFilter(audio_renderer_host_.get()); | 1080 AddFilter(audio_renderer_host_.get()); |
1079 AddFilter( | 1081 AddFilter( |
1080 new MidiHost(GetID(), BrowserMainLoop::GetInstance()->midi_service())); | 1082 new MidiHost(GetID(), BrowserMainLoop::GetInstance()->midi_service())); |
1081 AddFilter(new AppCacheDispatcherHost( | 1083 AddFilter(new AppCacheDispatcherHost( |
1082 storage_partition_impl_->GetAppCacheService(), GetID())); | 1084 storage_partition_impl_->GetAppCacheService(), GetID())); |
1083 AddFilter(new ClipboardMessageFilter(blob_storage_context)); | 1085 AddFilter(new ClipboardMessageFilter(blob_storage_context)); |
1084 AddFilter(new DOMStorageMessageFilter( | 1086 AddFilter(new DOMStorageMessageFilter( |
1085 storage_partition_impl_->GetDOMStorageContext())); | 1087 storage_partition_impl_->GetDOMStorageContext())); |
1086 AddFilter(new IndexedDBDispatcherHost( | 1088 AddFilter(new IndexedDBDispatcherHost( |
(...skipping 1173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2260 | 2262 |
2261 // Enable mic input recording. AudioInputRendererHost is reference counted, so | 2263 // Enable mic input recording. AudioInputRendererHost is reference counted, so |
2262 // its lifetime is guaranteed during the lifetime of the closure. | 2264 // its lifetime is guaranteed during the lifetime of the closure. |
2263 if (audio_input_renderer_host_) { | 2265 if (audio_input_renderer_host_) { |
2264 // Not null if RenderProcessHostImpl::Init has already been called. | 2266 // Not null if RenderProcessHostImpl::Init has already been called. |
2265 BrowserThread::PostTask( | 2267 BrowserThread::PostTask( |
2266 BrowserThread::IO, FROM_HERE, | 2268 BrowserThread::IO, FROM_HERE, |
2267 base::Bind(&AudioInputRendererHost::EnableDebugRecording, | 2269 base::Bind(&AudioInputRendererHost::EnableDebugRecording, |
2268 audio_input_renderer_host_, file)); | 2270 audio_input_renderer_host_, file)); |
2269 } | 2271 } |
2272 | |
2273 if (audio_stream_registry_) { | |
o1ka
2016/12/22 10:46:52
We should not have two approaches side by side, sh
Max Morin
2017/01/09 15:34:23
Right, null check is not actually necessary.
| |
2274 // |audio_stream_registry_| is deleted on the IO thread and if |this| is | |
2275 // alive now it means that the task to delete |audio_stream_registry_| | |
o1ka
2016/12/22 10:46:52
Could you clarify in the comment how one follows f
Max Morin
2017/01/09 15:34:23
Done.
| |
2276 // isn't posted yet, so unretained is safe. | |
2277 BrowserThread::PostTask( | |
2278 BrowserThread::IO, FROM_HERE, | |
2279 base::Bind(&AudioStreamRegistryImpl::EnableDebugRecording, | |
2280 base::Unretained(audio_stream_registry_.get()), file)); | |
2281 } | |
2270 } | 2282 } |
2271 | 2283 |
2272 void RenderProcessHostImpl::DisableAudioDebugRecordings() { | 2284 void RenderProcessHostImpl::DisableAudioDebugRecordings() { |
2273 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 2285 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
2274 | 2286 |
2275 // Posting on the FILE thread and then replying back on the UI thread is only | 2287 // Posting on the FILE thread and then replying back on the UI thread is only |
2276 // for avoiding races between enable and disable. Nothing is done on the FILE | 2288 // for avoiding races between enable and disable. Nothing is done on the FILE |
2277 // thread. | 2289 // thread. |
2278 BrowserThread::PostTaskAndReply( | 2290 BrowserThread::PostTaskAndReply( |
2279 BrowserThread::FILE, FROM_HERE, base::Bind(&base::DoNothing), | 2291 BrowserThread::FILE, FROM_HERE, base::Bind(&base::DoNothing), |
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2773 void RenderProcessHostImpl::UpdateProcessPriority() { | 2785 void RenderProcessHostImpl::UpdateProcessPriority() { |
2774 if (!child_process_launcher_.get() || child_process_launcher_->IsStarting()) { | 2786 if (!child_process_launcher_.get() || child_process_launcher_->IsStarting()) { |
2775 is_process_backgrounded_ = false; | 2787 is_process_backgrounded_ = false; |
2776 return; | 2788 return; |
2777 } | 2789 } |
2778 | 2790 |
2779 // We background a process as soon as it hosts no active audio streams and no | 2791 // We background a process as soon as it hosts no active audio streams and no |
2780 // visible widgets -- the callers must call this function whenever we | 2792 // visible widgets -- the callers must call this function whenever we |
2781 // transition in/out of those states. | 2793 // transition in/out of those states. |
2782 const bool should_background = | 2794 const bool should_background = |
2783 visible_widgets_ == 0 && !audio_renderer_host_->HasActiveAudio() && | 2795 visible_widgets_ == 0 && !audio_stream_registry_->HasActiveAudio() && |
2784 !base::CommandLine::ForCurrentProcess()->HasSwitch( | 2796 !base::CommandLine::ForCurrentProcess()->HasSwitch( |
2785 switches::kDisableRendererBackgrounding); | 2797 switches::kDisableRendererBackgrounding); |
2786 | 2798 |
2787 // TODO(sebsg): Remove this ifdef when https://crbug.com/537671 is fixed. | 2799 // TODO(sebsg): Remove this ifdef when https://crbug.com/537671 is fixed. |
2788 #if !defined(OS_ANDROID) | 2800 #if !defined(OS_ANDROID) |
2789 if (is_process_backgrounded_ == should_background) | 2801 if (is_process_backgrounded_ == should_background) |
2790 return; | 2802 return; |
2791 #endif | 2803 #endif |
2792 | 2804 |
2793 TRACE_EVENT1("renderer_host", "RenderProcessHostImpl::UpdateProcessPriority", | 2805 TRACE_EVENT1("renderer_host", "RenderProcessHostImpl::UpdateProcessPriority", |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3022 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; | 3034 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; |
3023 | 3035 |
3024 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. | 3036 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. |
3025 // Capture the error message in a crash key value. | 3037 // Capture the error message in a crash key value. |
3026 base::debug::ScopedCrashKey error_key_value("mojo-message-error", error); | 3038 base::debug::ScopedCrashKey error_key_value("mojo-message-error", error); |
3027 bad_message::ReceivedBadMessage(render_process_id, | 3039 bad_message::ReceivedBadMessage(render_process_id, |
3028 bad_message::RPH_MOJO_PROCESS_ERROR); | 3040 bad_message::RPH_MOJO_PROCESS_ERROR); |
3029 } | 3041 } |
3030 | 3042 |
3031 } // namespace content | 3043 } // namespace content |
OLD | NEW |