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> |
11 #include <limits> | 11 #include <limits> |
12 #include <utility> | 12 #include <set> |
13 #include <vector> | |
14 | 13 |
15 #include "base/base_switches.h" | 14 #include "base/base_switches.h" |
16 #include "base/bind.h" | 15 #include "base/bind.h" |
17 #include "base/bind_helpers.h" | 16 #include "base/bind_helpers.h" |
18 #include "base/callback.h" | 17 #include "base/callback.h" |
19 #include "base/command_line.h" | 18 #include "base/command_line.h" |
20 #include "base/debug/crash_logging.h" | 19 #include "base/debug/crash_logging.h" |
21 #include "base/debug/dump_without_crashing.h" | 20 #include "base/debug/dump_without_crashing.h" |
22 #include "base/feature_list.h" | 21 #include "base/feature_list.h" |
23 #include "base/files/file.h" | 22 #include "base/files/file.h" |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 #include "content/browser/permissions/permission_service_context.h" | 95 #include "content/browser/permissions/permission_service_context.h" |
97 #include "content/browser/permissions/permission_service_impl.h" | 96 #include "content/browser/permissions/permission_service_impl.h" |
98 #include "content/browser/profiler_message_filter.h" | 97 #include "content/browser/profiler_message_filter.h" |
99 #include "content/browser/push_messaging/push_messaging_message_filter.h" | 98 #include "content/browser/push_messaging/push_messaging_message_filter.h" |
100 #include "content/browser/quota_dispatcher_host.h" | 99 #include "content/browser/quota_dispatcher_host.h" |
101 #include "content/browser/renderer_host/clipboard_message_filter.h" | 100 #include "content/browser/renderer_host/clipboard_message_filter.h" |
102 #include "content/browser/renderer_host/database_message_filter.h" | 101 #include "content/browser/renderer_host/database_message_filter.h" |
103 #include "content/browser/renderer_host/file_utilities_message_filter.h" | 102 #include "content/browser/renderer_host/file_utilities_message_filter.h" |
104 #include "content/browser/renderer_host/media/audio_input_renderer_host.h" | 103 #include "content/browser/renderer_host/media/audio_input_renderer_host.h" |
105 #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" |
106 #include "content/browser/renderer_host/media/media_stream_dispatcher_host.h" | 106 #include "content/browser/renderer_host/media/media_stream_dispatcher_host.h" |
107 #include "content/browser/renderer_host/media/peer_connection_tracker_host.h" | 107 #include "content/browser/renderer_host/media/peer_connection_tracker_host.h" |
108 #include "content/browser/renderer_host/media/video_capture_host.h" | 108 #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" | 109 #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" | 110 #include "content/browser/renderer_host/offscreen_canvas_surface_factory_impl.h" |
111 #include "content/browser/renderer_host/pepper/pepper_message_filter.h" | 111 #include "content/browser/renderer_host/pepper/pepper_message_filter.h" |
112 #include "content/browser/renderer_host/pepper/pepper_renderer_connection.h" | 112 #include "content/browser/renderer_host/pepper/pepper_renderer_connection.h" |
113 #include "content/browser/renderer_host/render_message_filter.h" | 113 #include "content/browser/renderer_host/render_message_filter.h" |
114 #include "content/browser/renderer_host/render_view_host_delegate.h" | 114 #include "content/browser/renderer_host/render_view_host_delegate.h" |
115 #include "content/browser/renderer_host/render_view_host_impl.h" | 115 #include "content/browser/renderer_host/render_view_host_impl.h" |
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
672 is_process_backgrounded_(false), | 672 is_process_backgrounded_(false), |
673 id_(ChildProcessHostImpl::GenerateChildProcessUniqueId()), | 673 id_(ChildProcessHostImpl::GenerateChildProcessUniqueId()), |
674 browser_context_(browser_context), | 674 browser_context_(browser_context), |
675 storage_partition_impl_(storage_partition_impl), | 675 storage_partition_impl_(storage_partition_impl), |
676 sudden_termination_allowed_(true), | 676 sudden_termination_allowed_(true), |
677 ignore_input_events_(false), | 677 ignore_input_events_(false), |
678 is_for_guests_only_(is_for_guests_only), | 678 is_for_guests_only_(is_for_guests_only), |
679 gpu_observer_registered_(false), | 679 gpu_observer_registered_(false), |
680 delayed_cleanup_needed_(false), | 680 delayed_cleanup_needed_(false), |
681 within_process_died_observer_(false), | 681 within_process_died_observer_(false), |
| 682 audio_stream_registry_(AudioStreamRegistryImpl::Create(id_)), |
682 #if BUILDFLAG(ENABLE_WEBRTC) | 683 #if BUILDFLAG(ENABLE_WEBRTC) |
683 webrtc_eventlog_host_(id_), | 684 webrtc_eventlog_host_(id_), |
684 #endif | 685 #endif |
685 permission_service_context_(new PermissionServiceContext(this)), | 686 permission_service_context_(new PermissionServiceContext(this)), |
686 indexed_db_factory_(new IndexedDBDispatcherHost( | 687 indexed_db_factory_(new IndexedDBDispatcherHost( |
687 id_, | 688 id_, |
688 storage_partition_impl_->GetURLRequestContext(), | 689 storage_partition_impl_->GetURLRequestContext(), |
689 storage_partition_impl_->GetIndexedDBContext(), | 690 storage_partition_impl_->GetIndexedDBContext(), |
690 ChromeBlobStorageContext::GetFor(browser_context_))), | 691 ChromeBlobStorageContext::GetFor(browser_context_))), |
691 channel_connected_(false), | 692 channel_connected_(false), |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1069 MediaStreamManager* media_stream_manager = | 1070 MediaStreamManager* media_stream_manager = |
1070 BrowserMainLoop::GetInstance()->media_stream_manager(); | 1071 BrowserMainLoop::GetInstance()->media_stream_manager(); |
1071 // The AudioInputRendererHost and AudioRendererHost needs to be available for | 1072 // The AudioInputRendererHost and AudioRendererHost needs to be available for |
1072 // lookup, so it's stashed in a member variable. | 1073 // lookup, so it's stashed in a member variable. |
1073 audio_input_renderer_host_ = new AudioInputRendererHost( | 1074 audio_input_renderer_host_ = new AudioInputRendererHost( |
1074 GetID(), base::GetProcId(GetHandle()), audio_manager, | 1075 GetID(), base::GetProcId(GetHandle()), audio_manager, |
1075 media_stream_manager, AudioMirroringManager::GetInstance(), | 1076 media_stream_manager, AudioMirroringManager::GetInstance(), |
1076 BrowserMainLoop::GetInstance()->user_input_monitor()); | 1077 BrowserMainLoop::GetInstance()->user_input_monitor()); |
1077 AddFilter(audio_input_renderer_host_.get()); | 1078 AddFilter(audio_input_renderer_host_.get()); |
1078 audio_renderer_host_ = new AudioRendererHost( | 1079 audio_renderer_host_ = new AudioRendererHost( |
1079 GetID(), audio_manager, AudioMirroringManager::GetInstance(), | 1080 GetID(), audio_stream_registry_.get(), audio_manager, |
1080 media_stream_manager, | 1081 AudioMirroringManager::GetInstance(), media_stream_manager, |
1081 browser_context->GetResourceContext()->GetMediaDeviceIDSalt()); | 1082 browser_context->GetResourceContext()->GetMediaDeviceIDSalt()); |
1082 AddFilter(audio_renderer_host_.get()); | 1083 AddFilter(audio_renderer_host_.get()); |
1083 AddFilter( | 1084 AddFilter( |
1084 new MidiHost(GetID(), BrowserMainLoop::GetInstance()->midi_service())); | 1085 new MidiHost(GetID(), BrowserMainLoop::GetInstance()->midi_service())); |
1085 AddFilter(new AppCacheDispatcherHost( | 1086 AddFilter(new AppCacheDispatcherHost( |
1086 storage_partition_impl_->GetAppCacheService(), GetID())); | 1087 storage_partition_impl_->GetAppCacheService(), GetID())); |
1087 AddFilter(new ClipboardMessageFilter(blob_storage_context)); | 1088 AddFilter(new ClipboardMessageFilter(blob_storage_context)); |
1088 AddFilter(new DOMStorageMessageFilter( | 1089 AddFilter(new DOMStorageMessageFilter( |
1089 storage_partition_impl_->GetDOMStorageContext())); | 1090 storage_partition_impl_->GetDOMStorageContext())); |
1090 | 1091 |
(...skipping 1692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2783 void RenderProcessHostImpl::UpdateProcessPriority() { | 2784 void RenderProcessHostImpl::UpdateProcessPriority() { |
2784 if (!child_process_launcher_.get() || child_process_launcher_->IsStarting()) { | 2785 if (!child_process_launcher_.get() || child_process_launcher_->IsStarting()) { |
2785 is_process_backgrounded_ = false; | 2786 is_process_backgrounded_ = false; |
2786 return; | 2787 return; |
2787 } | 2788 } |
2788 | 2789 |
2789 // We background a process as soon as it hosts no active audio streams and no | 2790 // We background a process as soon as it hosts no active audio streams and no |
2790 // visible widgets -- the callers must call this function whenever we | 2791 // visible widgets -- the callers must call this function whenever we |
2791 // transition in/out of those states. | 2792 // transition in/out of those states. |
2792 const bool should_background = | 2793 const bool should_background = |
2793 visible_widgets_ == 0 && !audio_renderer_host_->HasActiveAudio() && | 2794 visible_widgets_ == 0 && !audio_stream_registry_->HasActiveAudio() && |
2794 !base::CommandLine::ForCurrentProcess()->HasSwitch( | 2795 !base::CommandLine::ForCurrentProcess()->HasSwitch( |
2795 switches::kDisableRendererBackgrounding); | 2796 switches::kDisableRendererBackgrounding); |
2796 | 2797 |
2797 // TODO(sebsg): Remove this ifdef when https://crbug.com/537671 is fixed. | 2798 // TODO(sebsg): Remove this ifdef when https://crbug.com/537671 is fixed. |
2798 #if !defined(OS_ANDROID) | 2799 #if !defined(OS_ANDROID) |
2799 if (is_process_backgrounded_ == should_background) | 2800 if (is_process_backgrounded_ == should_background) |
2800 return; | 2801 return; |
2801 #endif | 2802 #endif |
2802 | 2803 |
2803 TRACE_EVENT1("renderer_host", "RenderProcessHostImpl::UpdateProcessPriority", | 2804 TRACE_EVENT1("renderer_host", "RenderProcessHostImpl::UpdateProcessPriority", |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3032 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; | 3033 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; |
3033 | 3034 |
3034 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. | 3035 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. |
3035 // Capture the error message in a crash key value. | 3036 // Capture the error message in a crash key value. |
3036 base::debug::ScopedCrashKey error_key_value("mojo-message-error", error); | 3037 base::debug::ScopedCrashKey error_key_value("mojo-message-error", error); |
3037 bad_message::ReceivedBadMessage(render_process_id, | 3038 bad_message::ReceivedBadMessage(render_process_id, |
3038 bad_message::RPH_MOJO_PROCESS_ERROR); | 3039 bad_message::RPH_MOJO_PROCESS_ERROR); |
3039 } | 3040 } |
3040 | 3041 |
3041 } // namespace content | 3042 } // namespace content |
OLD | NEW |