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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h" | 70 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h" |
71 #include "content/browser/gpu/compositor_util.h" | 71 #include "content/browser/gpu/compositor_util.h" |
72 #include "content/browser/gpu/gpu_data_manager_impl.h" | 72 #include "content/browser/gpu/gpu_data_manager_impl.h" |
73 #include "content/browser/gpu/gpu_process_host.h" | 73 #include "content/browser/gpu/gpu_process_host.h" |
74 #include "content/browser/gpu/shader_disk_cache.h" | 74 #include "content/browser/gpu/shader_disk_cache.h" |
75 #include "content/browser/histogram_message_filter.h" | 75 #include "content/browser/histogram_message_filter.h" |
76 #include "content/browser/indexed_db/indexed_db_context_impl.h" | 76 #include "content/browser/indexed_db/indexed_db_context_impl.h" |
77 #include "content/browser/indexed_db/indexed_db_dispatcher_host.h" | 77 #include "content/browser/indexed_db/indexed_db_dispatcher_host.h" |
78 #include "content/browser/loader/resource_message_filter.h" | 78 #include "content/browser/loader/resource_message_filter.h" |
79 #include "content/browser/loader/resource_scheduler_filter.h" | 79 #include "content/browser/loader/resource_scheduler_filter.h" |
| 80 #include "content/browser/loader/url_loader_factory_impl.h" |
80 #include "content/browser/media/capture/audio_mirroring_manager.h" | 81 #include "content/browser/media/capture/audio_mirroring_manager.h" |
81 #include "content/browser/media/capture/image_capture_impl.h" | 82 #include "content/browser/media/capture/image_capture_impl.h" |
82 #include "content/browser/media/media_internals.h" | 83 #include "content/browser/media/media_internals.h" |
83 #include "content/browser/media/midi_host.h" | 84 #include "content/browser/media/midi_host.h" |
84 #include "content/browser/memory/memory_message_filter.h" | 85 #include "content/browser/memory/memory_message_filter.h" |
85 #include "content/browser/message_port_message_filter.h" | 86 #include "content/browser/message_port_message_filter.h" |
86 #include "content/browser/mime_registry_impl.h" | 87 #include "content/browser/mime_registry_impl.h" |
87 #include "content/browser/mojo/mojo_child_connection.h" | 88 #include "content/browser/mojo/mojo_child_connection.h" |
88 #include "content/browser/notifications/notification_message_filter.h" | 89 #include "content/browser/notifications/notification_message_filter.h" |
89 #include "content/browser/notifications/platform_notification_context_impl.h" | 90 #include "content/browser/notifications/platform_notification_context_impl.h" |
(...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
719 void RenderProcessHostImpl::CheckAllWorkersTerminated() { | 720 void RenderProcessHostImpl::CheckAllWorkersTerminated() { |
720 iterator iter(AllHostsIterator()); | 721 iterator iter(AllHostsIterator()); |
721 while (!iter.IsAtEnd()) { | 722 while (!iter.IsAtEnd()) { |
722 RenderProcessHostImpl* host = | 723 RenderProcessHostImpl* host = |
723 static_cast<RenderProcessHostImpl*>(iter.GetCurrentValue()); | 724 static_cast<RenderProcessHostImpl*>(iter.GetCurrentValue()); |
724 CHECK_EQ(0, host->worker_ref_count_); | 725 CHECK_EQ(0, host->worker_ref_count_); |
725 } | 726 } |
726 } | 727 } |
727 | 728 |
728 RenderProcessHostImpl::~RenderProcessHostImpl() { | 729 RenderProcessHostImpl::~RenderProcessHostImpl() { |
| 730 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
729 #ifndef NDEBUG | 731 #ifndef NDEBUG |
730 DCHECK(is_self_deleted_) | 732 DCHECK(is_self_deleted_) |
731 << "RenderProcessHostImpl is destroyed by something other than itself"; | 733 << "RenderProcessHostImpl is destroyed by something other than itself"; |
732 #endif | 734 #endif |
733 | 735 |
734 // Make sure to clean up the in-process renderer before the channel, otherwise | 736 // Make sure to clean up the in-process renderer before the channel, otherwise |
735 // it may still run and have its IPCs fail, causing asserts. | 737 // it may still run and have its IPCs fail, causing asserts. |
736 in_process_renderer_.reset(); | 738 in_process_renderer_.reset(); |
737 | 739 |
738 ChildProcessSecurityPolicyImpl::GetInstance()->Remove(GetID()); | 740 ChildProcessSecurityPolicyImpl::GetInstance()->Remove(GetID()); |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
962 GetStoragePartition()->GetMediaURLRequestContext()); | 964 GetStoragePartition()->GetMediaURLRequestContext()); |
963 | 965 |
964 ResourceMessageFilter::GetContextsCallback get_contexts_callback( | 966 ResourceMessageFilter::GetContextsCallback get_contexts_callback( |
965 base::Bind(&GetContexts, browser_context->GetResourceContext(), | 967 base::Bind(&GetContexts, browser_context->GetResourceContext(), |
966 request_context, media_request_context)); | 968 request_context, media_request_context)); |
967 | 969 |
968 // Several filters need the Blob storage context, so fetch it in advance. | 970 // Several filters need the Blob storage context, so fetch it in advance. |
969 scoped_refptr<ChromeBlobStorageContext> blob_storage_context = | 971 scoped_refptr<ChromeBlobStorageContext> blob_storage_context = |
970 ChromeBlobStorageContext::GetFor(browser_context); | 972 ChromeBlobStorageContext::GetFor(browser_context); |
971 | 973 |
972 ResourceMessageFilter* resource_message_filter = new ResourceMessageFilter( | 974 resource_message_filter_ = new ResourceMessageFilter( |
973 GetID(), PROCESS_TYPE_RENDERER, | 975 GetID(), PROCESS_TYPE_RENDERER, |
974 storage_partition_impl_->GetAppCacheService(), | 976 storage_partition_impl_->GetAppCacheService(), blob_storage_context.get(), |
975 blob_storage_context.get(), | |
976 storage_partition_impl_->GetFileSystemContext(), | 977 storage_partition_impl_->GetFileSystemContext(), |
977 storage_partition_impl_->GetServiceWorkerContext(), | 978 storage_partition_impl_->GetServiceWorkerContext(), |
978 storage_partition_impl_->GetHostZoomLevelContext(), | 979 storage_partition_impl_->GetHostZoomLevelContext(), |
979 get_contexts_callback); | 980 get_contexts_callback); |
980 | 981 |
981 AddFilter(resource_message_filter); | 982 AddFilter(resource_message_filter_.get()); |
| 983 |
982 MediaStreamManager* media_stream_manager = | 984 MediaStreamManager* media_stream_manager = |
983 BrowserMainLoop::GetInstance()->media_stream_manager(); | 985 BrowserMainLoop::GetInstance()->media_stream_manager(); |
984 // The AudioInputRendererHost and AudioRendererHost needs to be available for | 986 // The AudioInputRendererHost and AudioRendererHost needs to be available for |
985 // lookup, so it's stashed in a member variable. | 987 // lookup, so it's stashed in a member variable. |
986 audio_input_renderer_host_ = new AudioInputRendererHost( | 988 audio_input_renderer_host_ = new AudioInputRendererHost( |
987 GetID(), base::GetProcId(GetHandle()), audio_manager, | 989 GetID(), base::GetProcId(GetHandle()), audio_manager, |
988 media_stream_manager, AudioMirroringManager::GetInstance(), | 990 media_stream_manager, AudioMirroringManager::GetInstance(), |
989 BrowserMainLoop::GetInstance()->user_input_monitor()); | 991 BrowserMainLoop::GetInstance()->user_input_monitor()); |
990 AddFilter(audio_input_renderer_host_.get()); | 992 AddFilter(audio_input_renderer_host_.get()); |
991 audio_renderer_host_ = new AudioRendererHost( | 993 audio_renderer_host_ = new AudioRendererHost( |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1164 #if defined(USE_MINIKIN_HYPHENATION) | 1166 #if defined(USE_MINIKIN_HYPHENATION) |
1165 registry->AddInterface(base::Bind(&hyphenation::HyphenationImpl::Create), | 1167 registry->AddInterface(base::Bind(&hyphenation::HyphenationImpl::Create), |
1166 file_task_runner); | 1168 file_task_runner); |
1167 #endif | 1169 #endif |
1168 | 1170 |
1169 // These callbacks will be run immediately on the IO thread. | 1171 // These callbacks will be run immediately on the IO thread. |
1170 registry->AddInterface(base::Bind(&DeviceLightHost::Create)); | 1172 registry->AddInterface(base::Bind(&DeviceLightHost::Create)); |
1171 registry->AddInterface(base::Bind(&DeviceMotionHost::Create)); | 1173 registry->AddInterface(base::Bind(&DeviceMotionHost::Create)); |
1172 registry->AddInterface(base::Bind(&DeviceOrientationHost::Create)); | 1174 registry->AddInterface(base::Bind(&DeviceOrientationHost::Create)); |
1173 registry->AddInterface(base::Bind(&DeviceOrientationAbsoluteHost::Create)); | 1175 registry->AddInterface(base::Bind(&DeviceOrientationAbsoluteHost::Create)); |
| 1176 registry->AddInterface( |
| 1177 base::Bind(&URLLoaderFactoryImpl::Create, resource_message_filter_)); |
1174 | 1178 |
1175 // This is to support usage of WebSockets in cases in which there is no | 1179 // This is to support usage of WebSockets in cases in which there is no |
1176 // associated RenderFrame (e.g., Shared Workers). | 1180 // associated RenderFrame (e.g., Shared Workers). |
1177 registry->AddInterface( | 1181 registry->AddInterface( |
1178 base::Bind(&WebSocketManager::CreateWebSocket, GetID(), MSG_ROUTING_NONE), | 1182 base::Bind(&WebSocketManager::CreateWebSocket, GetID(), MSG_ROUTING_NONE), |
1179 ui_task_runner); | 1183 ui_task_runner); |
1180 | 1184 |
1181 GetContentClient()->browser()->ExposeInterfacesToRenderer(registry.get(), | 1185 GetContentClient()->browser()->ExposeInterfacesToRenderer(registry.get(), |
1182 this); | 1186 this); |
1183 | 1187 |
(...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1916 | 1920 |
1917 void RenderProcessHostImpl::SetIgnoreInputEvents(bool ignore_input_events) { | 1921 void RenderProcessHostImpl::SetIgnoreInputEvents(bool ignore_input_events) { |
1918 ignore_input_events_ = ignore_input_events; | 1922 ignore_input_events_ = ignore_input_events; |
1919 } | 1923 } |
1920 | 1924 |
1921 bool RenderProcessHostImpl::IgnoreInputEvents() const { | 1925 bool RenderProcessHostImpl::IgnoreInputEvents() const { |
1922 return ignore_input_events_; | 1926 return ignore_input_events_; |
1923 } | 1927 } |
1924 | 1928 |
1925 void RenderProcessHostImpl::Cleanup() { | 1929 void RenderProcessHostImpl::Cleanup() { |
| 1930 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
1926 // Keep the one renderer thread around forever in single process mode. | 1931 // Keep the one renderer thread around forever in single process mode. |
1927 if (run_renderer_in_process()) | 1932 if (run_renderer_in_process()) |
1928 return; | 1933 return; |
1929 | 1934 |
1930 // If within_process_died_observer_ is true, one of our observers performed an | 1935 // If within_process_died_observer_ is true, one of our observers performed an |
1931 // action that caused us to die (e.g. http://crbug.com/339504). Therefore, | 1936 // action that caused us to die (e.g. http://crbug.com/339504). Therefore, |
1932 // delay the destruction until all of the observer callbacks have been made, | 1937 // delay the destruction until all of the observer callbacks have been made, |
1933 // and guarantee that the RenderProcessHostDestroyed observer callback is | 1938 // and guarantee that the RenderProcessHostDestroyed observer callback is |
1934 // always the last callback fired. | 1939 // always the last callback fired. |
1935 if (within_process_died_observer_) { | 1940 if (within_process_died_observer_) { |
(...skipping 900 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2836 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; | 2841 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; |
2837 | 2842 |
2838 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. Alias | 2843 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. Alias |
2839 // enough information here so that we can determine what the bad message was. | 2844 // enough information here so that we can determine what the bad message was. |
2840 base::debug::Alias(&error); | 2845 base::debug::Alias(&error); |
2841 bad_message::ReceivedBadMessage(process.get(), | 2846 bad_message::ReceivedBadMessage(process.get(), |
2842 bad_message::RPH_MOJO_PROCESS_ERROR); | 2847 bad_message::RPH_MOJO_PROCESS_ERROR); |
2843 } | 2848 } |
2844 | 2849 |
2845 } // namespace content | 2850 } // namespace content |
OLD | NEW |