| 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 #include "content/browser/permissions/permission_service_context.h" | 96 #include "content/browser/permissions/permission_service_context.h" |
| 97 #include "content/browser/permissions/permission_service_impl.h" | 97 #include "content/browser/permissions/permission_service_impl.h" |
| 98 #include "content/browser/profiler_message_filter.h" | 98 #include "content/browser/profiler_message_filter.h" |
| 99 #include "content/browser/push_messaging/push_messaging_message_filter.h" | 99 #include "content/browser/push_messaging/push_messaging_message_filter.h" |
| 100 #include "content/browser/quota_dispatcher_host.h" | 100 #include "content/browser/quota_dispatcher_host.h" |
| 101 #include "content/browser/renderer_host/clipboard_message_filter.h" | 101 #include "content/browser/renderer_host/clipboard_message_filter.h" |
| 102 #include "content/browser/renderer_host/database_message_filter.h" | 102 #include "content/browser/renderer_host/database_message_filter.h" |
| 103 #include "content/browser/renderer_host/file_utilities_message_filter.h" | 103 #include "content/browser/renderer_host/file_utilities_message_filter.h" |
| 104 #include "content/browser/renderer_host/media/audio_input_renderer_host.h" | 104 #include "content/browser/renderer_host/media/audio_input_renderer_host.h" |
| 105 #include "content/browser/renderer_host/media/audio_renderer_host.h" | 105 #include "content/browser/renderer_host/media/audio_renderer_host.h" |
| 106 #include "content/browser/renderer_host/media/audio_stream_registry_impl.h" |
| 106 #include "content/browser/renderer_host/media/media_stream_dispatcher_host.h" | 107 #include "content/browser/renderer_host/media/media_stream_dispatcher_host.h" |
| 107 #include "content/browser/renderer_host/media/peer_connection_tracker_host.h" | 108 #include "content/browser/renderer_host/media/peer_connection_tracker_host.h" |
| 108 #include "content/browser/renderer_host/media/video_capture_host.h" | 109 #include "content/browser/renderer_host/media/video_capture_host.h" |
| 109 #include "content/browser/renderer_host/offscreen_canvas_compositor_frame_sink_p
rovider_impl.h" | 110 #include "content/browser/renderer_host/offscreen_canvas_compositor_frame_sink_p
rovider_impl.h" |
| 110 #include "content/browser/renderer_host/offscreen_canvas_surface_factory_impl.h" | 111 #include "content/browser/renderer_host/offscreen_canvas_surface_factory_impl.h" |
| 111 #include "content/browser/renderer_host/pepper/pepper_message_filter.h" | 112 #include "content/browser/renderer_host/pepper/pepper_message_filter.h" |
| 112 #include "content/browser/renderer_host/pepper/pepper_renderer_connection.h" | 113 #include "content/browser/renderer_host/pepper/pepper_renderer_connection.h" |
| 113 #include "content/browser/renderer_host/render_message_filter.h" | 114 #include "content/browser/renderer_host/render_message_filter.h" |
| 114 #include "content/browser/renderer_host/render_view_host_delegate.h" | 115 #include "content/browser/renderer_host/render_view_host_delegate.h" |
| 115 #include "content/browser/renderer_host/render_view_host_impl.h" | 116 #include "content/browser/renderer_host/render_view_host_impl.h" |
| (...skipping 557 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 permission_service_context_(new PermissionServiceContext(this)), | 688 permission_service_context_(new PermissionServiceContext(this)), |
| 687 indexed_db_factory_(new IndexedDBDispatcherHost( | 689 indexed_db_factory_(new IndexedDBDispatcherHost( |
| 688 id_, | 690 id_, |
| 689 storage_partition_impl_->GetURLRequestContext(), | 691 storage_partition_impl_->GetURLRequestContext(), |
| 690 storage_partition_impl_->GetIndexedDBContext(), | 692 storage_partition_impl_->GetIndexedDBContext(), |
| 691 ChromeBlobStorageContext::GetFor(browser_context_))), | 693 ChromeBlobStorageContext::GetFor(browser_context_))), |
| 692 channel_connected_(false), | 694 channel_connected_(false), |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1070 MediaStreamManager* media_stream_manager = | 1072 MediaStreamManager* media_stream_manager = |
| 1071 BrowserMainLoop::GetInstance()->media_stream_manager(); | 1073 BrowserMainLoop::GetInstance()->media_stream_manager(); |
| 1072 // The AudioInputRendererHost and AudioRendererHost needs to be available for | 1074 // The AudioInputRendererHost and AudioRendererHost needs to be available for |
| 1073 // lookup, so it's stashed in a member variable. | 1075 // lookup, so it's stashed in a member variable. |
| 1074 audio_input_renderer_host_ = new AudioInputRendererHost( | 1076 audio_input_renderer_host_ = new AudioInputRendererHost( |
| 1075 GetID(), base::GetProcId(GetHandle()), audio_manager, | 1077 GetID(), base::GetProcId(GetHandle()), audio_manager, |
| 1076 media_stream_manager, AudioMirroringManager::GetInstance(), | 1078 media_stream_manager, AudioMirroringManager::GetInstance(), |
| 1077 BrowserMainLoop::GetInstance()->user_input_monitor()); | 1079 BrowserMainLoop::GetInstance()->user_input_monitor()); |
| 1078 AddFilter(audio_input_renderer_host_.get()); | 1080 AddFilter(audio_input_renderer_host_.get()); |
| 1079 audio_renderer_host_ = new AudioRendererHost( | 1081 audio_renderer_host_ = new AudioRendererHost( |
| 1080 GetID(), audio_manager, AudioMirroringManager::GetInstance(), | 1082 GetID(), audio_stream_registry_.get(), audio_manager, |
| 1081 media_stream_manager, | 1083 AudioMirroringManager::GetInstance(), media_stream_manager, |
| 1082 browser_context->GetResourceContext()->GetMediaDeviceIDSalt()); | 1084 browser_context->GetResourceContext()->GetMediaDeviceIDSalt()); |
| 1083 AddFilter(audio_renderer_host_.get()); | 1085 AddFilter(audio_renderer_host_.get()); |
| 1084 AddFilter( | 1086 AddFilter( |
| 1085 new MidiHost(GetID(), BrowserMainLoop::GetInstance()->midi_service())); | 1087 new MidiHost(GetID(), BrowserMainLoop::GetInstance()->midi_service())); |
| 1086 AddFilter(new AppCacheDispatcherHost( | 1088 AddFilter(new AppCacheDispatcherHost( |
| 1087 storage_partition_impl_->GetAppCacheService(), GetID())); | 1089 storage_partition_impl_->GetAppCacheService(), GetID())); |
| 1088 AddFilter(new ClipboardMessageFilter(blob_storage_context)); | 1090 AddFilter(new ClipboardMessageFilter(blob_storage_context)); |
| 1089 AddFilter(new DOMStorageMessageFilter( | 1091 AddFilter(new DOMStorageMessageFilter( |
| 1090 storage_partition_impl_->GetDOMStorageContext())); | 1092 storage_partition_impl_->GetDOMStorageContext())); |
| 1091 | 1093 |
| (...skipping 1178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2270 | 2272 |
| 2271 // Enable mic input recording. AudioInputRendererHost is reference counted, so | 2273 // Enable mic input recording. AudioInputRendererHost is reference counted, so |
| 2272 // its lifetime is guaranteed during the lifetime of the closure. | 2274 // its lifetime is guaranteed during the lifetime of the closure. |
| 2273 if (audio_input_renderer_host_) { | 2275 if (audio_input_renderer_host_) { |
| 2274 // Not null if RenderProcessHostImpl::Init has already been called. | 2276 // Not null if RenderProcessHostImpl::Init has already been called. |
| 2275 BrowserThread::PostTask( | 2277 BrowserThread::PostTask( |
| 2276 BrowserThread::IO, FROM_HERE, | 2278 BrowserThread::IO, FROM_HERE, |
| 2277 base::Bind(&AudioInputRendererHost::EnableDebugRecording, | 2279 base::Bind(&AudioInputRendererHost::EnableDebugRecording, |
| 2278 audio_input_renderer_host_, file)); | 2280 audio_input_renderer_host_, file)); |
| 2279 } | 2281 } |
| 2282 |
| 2283 // |audio_stream_registry_| is deleted on the IO thread and if |this| is |
| 2284 // alive now it means that the task to delete |audio_stream_registry_| |
| 2285 // isn't posted, so this task is scheduled before any task to delete |
| 2286 // |audio_stream_registry_.get()|. |
| 2287 BrowserThread::PostTask( |
| 2288 BrowserThread::IO, FROM_HERE, |
| 2289 base::Bind(&AudioStreamRegistryImpl::EnableDebugRecording, |
| 2290 base::Unretained(audio_stream_registry_.get()), file)); |
| 2280 } | 2291 } |
| 2281 | 2292 |
| 2282 void RenderProcessHostImpl::DisableAudioDebugRecordings() { | 2293 void RenderProcessHostImpl::DisableAudioDebugRecordings() { |
| 2283 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 2294 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 2284 | 2295 |
| 2285 // Posting on the FILE thread and then replying back on the UI thread is only | 2296 // Posting on the FILE thread and then replying back on the UI thread is only |
| 2286 // for avoiding races between enable and disable. Nothing is done on the FILE | 2297 // for avoiding races between enable and disable. Nothing is done on the FILE |
| 2287 // thread. | 2298 // thread. |
| 2288 BrowserThread::PostTaskAndReply( | 2299 BrowserThread::PostTaskAndReply( |
| 2289 BrowserThread::FILE, FROM_HERE, base::Bind(&base::DoNothing), | 2300 BrowserThread::FILE, FROM_HERE, base::Bind(&base::DoNothing), |
| (...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2786 void RenderProcessHostImpl::UpdateProcessPriority() { | 2797 void RenderProcessHostImpl::UpdateProcessPriority() { |
| 2787 if (!child_process_launcher_.get() || child_process_launcher_->IsStarting()) { | 2798 if (!child_process_launcher_.get() || child_process_launcher_->IsStarting()) { |
| 2788 is_process_backgrounded_ = false; | 2799 is_process_backgrounded_ = false; |
| 2789 return; | 2800 return; |
| 2790 } | 2801 } |
| 2791 | 2802 |
| 2792 // We background a process as soon as it hosts no active audio streams and no | 2803 // We background a process as soon as it hosts no active audio streams and no |
| 2793 // visible widgets -- the callers must call this function whenever we | 2804 // visible widgets -- the callers must call this function whenever we |
| 2794 // transition in/out of those states. | 2805 // transition in/out of those states. |
| 2795 const bool should_background = | 2806 const bool should_background = |
| 2796 visible_widgets_ == 0 && !audio_renderer_host_->HasActiveAudio() && | 2807 visible_widgets_ == 0 && !audio_stream_registry_->HasActiveAudio() && |
| 2797 !base::CommandLine::ForCurrentProcess()->HasSwitch( | 2808 !base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 2798 switches::kDisableRendererBackgrounding); | 2809 switches::kDisableRendererBackgrounding); |
| 2799 | 2810 |
| 2800 // TODO(sebsg): Remove this ifdef when https://crbug.com/537671 is fixed. | 2811 // TODO(sebsg): Remove this ifdef when https://crbug.com/537671 is fixed. |
| 2801 #if !defined(OS_ANDROID) | 2812 #if !defined(OS_ANDROID) |
| 2802 if (is_process_backgrounded_ == should_background) | 2813 if (is_process_backgrounded_ == should_background) |
| 2803 return; | 2814 return; |
| 2804 #endif | 2815 #endif |
| 2805 | 2816 |
| 2806 TRACE_EVENT1("renderer_host", "RenderProcessHostImpl::UpdateProcessPriority", | 2817 TRACE_EVENT1("renderer_host", "RenderProcessHostImpl::UpdateProcessPriority", |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3035 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; | 3046 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; |
| 3036 | 3047 |
| 3037 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. | 3048 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. |
| 3038 // Capture the error message in a crash key value. | 3049 // Capture the error message in a crash key value. |
| 3039 base::debug::ScopedCrashKey error_key_value("mojo-message-error", error); | 3050 base::debug::ScopedCrashKey error_key_value("mojo-message-error", error); |
| 3040 bad_message::ReceivedBadMessage(render_process_id, | 3051 bad_message::ReceivedBadMessage(render_process_id, |
| 3041 bad_message::RPH_MOJO_PROCESS_ERROR); | 3052 bad_message::RPH_MOJO_PROCESS_ERROR); |
| 3042 } | 3053 } |
| 3043 | 3054 |
| 3044 } // namespace content | 3055 } // namespace content |
| OLD | NEW |