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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
71 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h" | 71 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h" |
72 #include "content/browser/gpu/compositor_util.h" | 72 #include "content/browser/gpu/compositor_util.h" |
73 #include "content/browser/gpu/gpu_data_manager_impl.h" | 73 #include "content/browser/gpu/gpu_data_manager_impl.h" |
74 #include "content/browser/gpu/gpu_process_host.h" | 74 #include "content/browser/gpu/gpu_process_host.h" |
75 #include "content/browser/gpu/shader_disk_cache.h" | 75 #include "content/browser/gpu/shader_disk_cache.h" |
76 #include "content/browser/histogram_message_filter.h" | 76 #include "content/browser/histogram_message_filter.h" |
77 #include "content/browser/indexed_db/indexed_db_context_impl.h" | 77 #include "content/browser/indexed_db/indexed_db_context_impl.h" |
78 #include "content/browser/indexed_db/indexed_db_dispatcher_host.h" | 78 #include "content/browser/indexed_db/indexed_db_dispatcher_host.h" |
79 #include "content/browser/loader/resource_message_filter.h" | 79 #include "content/browser/loader/resource_message_filter.h" |
80 #include "content/browser/loader/resource_scheduler_filter.h" | 80 #include "content/browser/loader/resource_scheduler_filter.h" |
81 #include "content/browser/loader/url_loader_factory_impl.h" | |
81 #include "content/browser/media/capture/audio_mirroring_manager.h" | 82 #include "content/browser/media/capture/audio_mirroring_manager.h" |
82 #include "content/browser/media/capture/image_capture_impl.h" | 83 #include "content/browser/media/capture/image_capture_impl.h" |
83 #include "content/browser/media/media_internals.h" | 84 #include "content/browser/media/media_internals.h" |
84 #include "content/browser/media/midi_host.h" | 85 #include "content/browser/media/midi_host.h" |
85 #include "content/browser/memory/memory_message_filter.h" | 86 #include "content/browser/memory/memory_message_filter.h" |
86 #include "content/browser/message_port_message_filter.h" | 87 #include "content/browser/message_port_message_filter.h" |
87 #include "content/browser/mime_registry_impl.h" | 88 #include "content/browser/mime_registry_impl.h" |
88 #include "content/browser/mojo/mojo_child_connection.h" | 89 #include "content/browser/mojo/mojo_child_connection.h" |
89 #include "content/browser/notifications/notification_message_filter.h" | 90 #include "content/browser/notifications/notification_message_filter.h" |
90 #include "content/browser/notifications/platform_notification_context_impl.h" | 91 #include "content/browser/notifications/platform_notification_context_impl.h" |
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
705 << "in-process."; | 706 << "in-process."; |
706 } | 707 } |
707 } | 708 } |
708 | 709 |
709 void RenderProcessHostImpl::RegisterRendererMainThreadFactory( | 710 void RenderProcessHostImpl::RegisterRendererMainThreadFactory( |
710 RendererMainThreadFactoryFunction create) { | 711 RendererMainThreadFactoryFunction create) { |
711 g_renderer_main_thread_factory = create; | 712 g_renderer_main_thread_factory = create; |
712 } | 713 } |
713 | 714 |
714 RenderProcessHostImpl::~RenderProcessHostImpl() { | 715 RenderProcessHostImpl::~RenderProcessHostImpl() { |
716 DCHECK_CURRENTLY_ON(BrowserThread::UI); | |
715 #ifndef NDEBUG | 717 #ifndef NDEBUG |
716 DCHECK(is_self_deleted_) | 718 DCHECK(is_self_deleted_) |
717 << "RenderProcessHostImpl is destroyed by something other than itself"; | 719 << "RenderProcessHostImpl is destroyed by something other than itself"; |
718 #endif | 720 #endif |
719 | 721 |
720 // Make sure to clean up the in-process renderer before the channel, otherwise | 722 // Make sure to clean up the in-process renderer before the channel, otherwise |
721 // it may still run and have its IPCs fail, causing asserts. | 723 // it may still run and have its IPCs fail, causing asserts. |
722 in_process_renderer_.reset(); | 724 in_process_renderer_.reset(); |
723 | 725 |
724 ChildProcessSecurityPolicyImpl::GetInstance()->Remove(GetID()); | 726 ChildProcessSecurityPolicyImpl::GetInstance()->Remove(GetID()); |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
950 GetStoragePartition()->GetMediaURLRequestContext()); | 952 GetStoragePartition()->GetMediaURLRequestContext()); |
951 | 953 |
952 ResourceMessageFilter::GetContextsCallback get_contexts_callback( | 954 ResourceMessageFilter::GetContextsCallback get_contexts_callback( |
953 base::Bind(&GetContexts, browser_context->GetResourceContext(), | 955 base::Bind(&GetContexts, browser_context->GetResourceContext(), |
954 request_context, media_request_context)); | 956 request_context, media_request_context)); |
955 | 957 |
956 // Several filters need the Blob storage context, so fetch it in advance. | 958 // Several filters need the Blob storage context, so fetch it in advance. |
957 scoped_refptr<ChromeBlobStorageContext> blob_storage_context = | 959 scoped_refptr<ChromeBlobStorageContext> blob_storage_context = |
958 ChromeBlobStorageContext::GetFor(browser_context); | 960 ChromeBlobStorageContext::GetFor(browser_context); |
959 | 961 |
960 ResourceMessageFilter* resource_message_filter = new ResourceMessageFilter( | 962 resource_message_filter_ = new ResourceMessageFilter( |
961 GetID(), PROCESS_TYPE_RENDERER, | 963 GetID(), PROCESS_TYPE_RENDERER, |
962 storage_partition_impl_->GetAppCacheService(), | 964 storage_partition_impl_->GetAppCacheService(), blob_storage_context.get(), |
963 blob_storage_context.get(), | |
964 storage_partition_impl_->GetFileSystemContext(), | 965 storage_partition_impl_->GetFileSystemContext(), |
965 storage_partition_impl_->GetServiceWorkerContext(), | 966 storage_partition_impl_->GetServiceWorkerContext(), |
966 get_contexts_callback); | 967 get_contexts_callback); |
967 | 968 |
968 AddFilter(resource_message_filter); | 969 AddFilter(resource_message_filter_.get()); |
970 | |
969 MediaStreamManager* media_stream_manager = | 971 MediaStreamManager* media_stream_manager = |
970 BrowserMainLoop::GetInstance()->media_stream_manager(); | 972 BrowserMainLoop::GetInstance()->media_stream_manager(); |
971 // The AudioInputRendererHost and AudioRendererHost needs to be available for | 973 // The AudioInputRendererHost and AudioRendererHost needs to be available for |
972 // lookup, so it's stashed in a member variable. | 974 // lookup, so it's stashed in a member variable. |
973 audio_input_renderer_host_ = new AudioInputRendererHost( | 975 audio_input_renderer_host_ = new AudioInputRendererHost( |
974 GetID(), base::GetProcId(GetHandle()), audio_manager, | 976 GetID(), base::GetProcId(GetHandle()), audio_manager, |
975 media_stream_manager, AudioMirroringManager::GetInstance(), | 977 media_stream_manager, AudioMirroringManager::GetInstance(), |
976 BrowserMainLoop::GetInstance()->user_input_monitor()); | 978 BrowserMainLoop::GetInstance()->user_input_monitor()); |
977 AddFilter(audio_input_renderer_host_.get()); | 979 AddFilter(audio_input_renderer_host_.get()); |
978 audio_renderer_host_ = new AudioRendererHost( | 980 audio_renderer_host_ = new AudioRendererHost( |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1160 #if defined(USE_MINIKIN_HYPHENATION) | 1162 #if defined(USE_MINIKIN_HYPHENATION) |
1161 registry->AddInterface(base::Bind(&hyphenation::HyphenationImpl::Create), | 1163 registry->AddInterface(base::Bind(&hyphenation::HyphenationImpl::Create), |
1162 file_task_runner); | 1164 file_task_runner); |
1163 #endif | 1165 #endif |
1164 | 1166 |
1165 // These callbacks will be run immediately on the IO thread. | 1167 // These callbacks will be run immediately on the IO thread. |
1166 registry->AddInterface(base::Bind(&DeviceLightHost::Create)); | 1168 registry->AddInterface(base::Bind(&DeviceLightHost::Create)); |
1167 registry->AddInterface(base::Bind(&DeviceMotionHost::Create)); | 1169 registry->AddInterface(base::Bind(&DeviceMotionHost::Create)); |
1168 registry->AddInterface(base::Bind(&DeviceOrientationHost::Create)); | 1170 registry->AddInterface(base::Bind(&DeviceOrientationHost::Create)); |
1169 registry->AddInterface(base::Bind(&DeviceOrientationAbsoluteHost::Create)); | 1171 registry->AddInterface(base::Bind(&DeviceOrientationAbsoluteHost::Create)); |
1172 registry->AddInterface( | |
1173 base::Bind(&URLLoaderFactoryImpl::Create, resource_message_filter_)); | |
kinuko
2016/08/09 15:44:28
Cool :)
| |
1170 | 1174 |
1171 GetContentClient()->browser()->ExposeInterfacesToRenderer(registry.get(), | 1175 GetContentClient()->browser()->ExposeInterfacesToRenderer(registry.get(), |
1172 this); | 1176 this); |
1173 | 1177 |
1174 MojoShellConnection* mojo_shell_connection = | 1178 MojoShellConnection* mojo_shell_connection = |
1175 BrowserContext::GetMojoShellConnectionFor(browser_context_); | 1179 BrowserContext::GetMojoShellConnectionFor(browser_context_); |
1176 std::unique_ptr<ConnectionFilterImpl> connection_filter( | 1180 std::unique_ptr<ConnectionFilterImpl> connection_filter( |
1177 new ConnectionFilterImpl(mojo_child_connection_->child_identity(), | 1181 new ConnectionFilterImpl(mojo_child_connection_->child_identity(), |
1178 std::move(registry))); | 1182 std::move(registry))); |
1179 connection_filter_ = connection_filter.get(); | 1183 connection_filter_ = connection_filter.get(); |
(...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1910 | 1914 |
1911 void RenderProcessHostImpl::SetIgnoreInputEvents(bool ignore_input_events) { | 1915 void RenderProcessHostImpl::SetIgnoreInputEvents(bool ignore_input_events) { |
1912 ignore_input_events_ = ignore_input_events; | 1916 ignore_input_events_ = ignore_input_events; |
1913 } | 1917 } |
1914 | 1918 |
1915 bool RenderProcessHostImpl::IgnoreInputEvents() const { | 1919 bool RenderProcessHostImpl::IgnoreInputEvents() const { |
1916 return ignore_input_events_; | 1920 return ignore_input_events_; |
1917 } | 1921 } |
1918 | 1922 |
1919 void RenderProcessHostImpl::Cleanup() { | 1923 void RenderProcessHostImpl::Cleanup() { |
1924 DCHECK_CURRENTLY_ON(BrowserThread::UI); | |
1920 // Keep the one renderer thread around forever in single process mode. | 1925 // Keep the one renderer thread around forever in single process mode. |
1921 if (run_renderer_in_process()) | 1926 if (run_renderer_in_process()) |
1922 return; | 1927 return; |
1923 | 1928 |
1924 // If within_process_died_observer_ is true, one of our observers performed an | 1929 // If within_process_died_observer_ is true, one of our observers performed an |
1925 // action that caused us to die (e.g. http://crbug.com/339504). Therefore, | 1930 // action that caused us to die (e.g. http://crbug.com/339504). Therefore, |
1926 // delay the destruction until all of the observer callbacks have been made, | 1931 // delay the destruction until all of the observer callbacks have been made, |
1927 // and guarantee that the RenderProcessHostDestroyed observer callback is | 1932 // and guarantee that the RenderProcessHostDestroyed observer callback is |
1928 // always the last callback fired. | 1933 // always the last callback fired. |
1929 if (within_process_died_observer_) { | 1934 if (within_process_died_observer_) { |
(...skipping 899 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2829 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; | 2834 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; |
2830 | 2835 |
2831 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. Alias | 2836 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. Alias |
2832 // enough information here so that we can determine what the bad message was. | 2837 // enough information here so that we can determine what the bad message was. |
2833 base::debug::Alias(&error); | 2838 base::debug::Alias(&error); |
2834 bad_message::ReceivedBadMessage(process.get(), | 2839 bad_message::ReceivedBadMessage(process.get(), |
2835 bad_message::RPH_MOJO_PROCESS_ERROR); | 2840 bad_message::RPH_MOJO_PROCESS_ERROR); |
2836 } | 2841 } |
2837 | 2842 |
2838 } // namespace content | 2843 } // namespace content |
OLD | NEW |