Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(606)

Side by Side Diff: content/browser/renderer_host/render_process_host_impl.cc

Issue 1970693002: Use mojo for Chrome Loading, Part 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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_holder.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/constants.h" 89 #include "content/browser/mojo/constants.h"
89 #include "content/browser/mojo/mojo_child_connection.h" 90 #include "content/browser/mojo/mojo_child_connection.h"
90 #include "content/browser/notifications/notification_message_filter.h" 91 #include "content/browser/notifications/notification_message_filter.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 #include "content/common/child_process_host_impl.h" 127 #include "content/common/child_process_host_impl.h"
127 #include "content/common/child_process_messages.h" 128 #include "content/common/child_process_messages.h"
128 #include "content/common/content_switches_internal.h" 129 #include "content/common/content_switches_internal.h"
129 #include "content/common/frame_messages.h" 130 #include "content/common/frame_messages.h"
130 #include "content/common/gpu_host_messages.h" 131 #include "content/common/gpu_host_messages.h"
131 #include "content/common/in_process_child_thread_params.h" 132 #include "content/common/in_process_child_thread_params.h"
132 #include "content/common/mojo/mojo_shell_connection_impl.h" 133 #include "content/common/mojo/mojo_shell_connection_impl.h"
133 #include "content/common/render_process_messages.h" 134 #include "content/common/render_process_messages.h"
134 #include "content/common/resource_messages.h" 135 #include "content/common/resource_messages.h"
135 #include "content/common/site_isolation_policy.h" 136 #include "content/common/site_isolation_policy.h"
137 #include "content/common/url_loader_factory.mojom.h"
136 #include "content/common/view_messages.h" 138 #include "content/common/view_messages.h"
137 #include "content/public/browser/browser_context.h" 139 #include "content/public/browser/browser_context.h"
138 #include "content/public/browser/browser_thread.h" 140 #include "content/public/browser/browser_thread.h"
139 #include "content/public/browser/content_browser_client.h" 141 #include "content/public/browser/content_browser_client.h"
140 #include "content/public/browser/notification_service.h" 142 #include "content/public/browser/notification_service.h"
141 #include "content/public/browser/notification_types.h" 143 #include "content/public/browser/notification_types.h"
142 #include "content/public/browser/render_process_host_factory.h" 144 #include "content/public/browser/render_process_host_factory.h"
143 #include "content/public/browser/render_process_host_observer.h" 145 #include "content/public/browser/render_process_host_observer.h"
144 #include "content/public/browser/render_widget_host.h" 146 #include "content/public/browser/render_widget_host.h"
145 #include "content/public/browser/render_widget_host_iterator.h" 147 #include "content/public/browser/render_widget_host_iterator.h"
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after
648 << "in-process."; 650 << "in-process.";
649 } 651 }
650 } 652 }
651 653
652 void RenderProcessHostImpl::RegisterRendererMainThreadFactory( 654 void RenderProcessHostImpl::RegisterRendererMainThreadFactory(
653 RendererMainThreadFactoryFunction create) { 655 RendererMainThreadFactoryFunction create) {
654 g_renderer_main_thread_factory = create; 656 g_renderer_main_thread_factory = create;
655 } 657 }
656 658
657 RenderProcessHostImpl::~RenderProcessHostImpl() { 659 RenderProcessHostImpl::~RenderProcessHostImpl() {
660 DCHECK_CURRENTLY_ON(BrowserThread::UI);
658 #ifndef NDEBUG 661 #ifndef NDEBUG
659 DCHECK(is_self_deleted_) 662 DCHECK(is_self_deleted_)
660 << "RenderProcessHostImpl is destroyed by something other than itself"; 663 << "RenderProcessHostImpl is destroyed by something other than itself";
661 #endif 664 #endif
662 665
663 // Make sure to clean up the in-process renderer before the channel, otherwise 666 // Make sure to clean up the in-process renderer before the channel, otherwise
664 // it may still run and have its IPCs fail, causing asserts. 667 // it may still run and have its IPCs fail, causing asserts.
665 in_process_renderer_.reset(); 668 in_process_renderer_.reset();
666 669
667 ChildProcessSecurityPolicyImpl::GetInstance()->Remove(GetID()); 670 ChildProcessSecurityPolicyImpl::GetInstance()->Remove(GetID());
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
893 GetStoragePartition()->GetMediaURLRequestContext()); 896 GetStoragePartition()->GetMediaURLRequestContext());
894 897
895 ResourceMessageFilter::GetContextsCallback get_contexts_callback( 898 ResourceMessageFilter::GetContextsCallback get_contexts_callback(
896 base::Bind(&GetContexts, browser_context->GetResourceContext(), 899 base::Bind(&GetContexts, browser_context->GetResourceContext(),
897 request_context, media_request_context)); 900 request_context, media_request_context));
898 901
899 // Several filters need the Blob storage context, so fetch it in advance. 902 // Several filters need the Blob storage context, so fetch it in advance.
900 scoped_refptr<ChromeBlobStorageContext> blob_storage_context = 903 scoped_refptr<ChromeBlobStorageContext> blob_storage_context =
901 ChromeBlobStorageContext::GetFor(browser_context); 904 ChromeBlobStorageContext::GetFor(browser_context);
902 905
903 ResourceMessageFilter* resource_message_filter = new ResourceMessageFilter( 906 resource_message_filter_ = new ResourceMessageFilter(
904 GetID(), PROCESS_TYPE_RENDERER, 907 GetID(), PROCESS_TYPE_RENDERER,
905 storage_partition_impl_->GetAppCacheService(), 908 storage_partition_impl_->GetAppCacheService(), blob_storage_context.get(),
906 blob_storage_context.get(),
907 storage_partition_impl_->GetFileSystemContext(), 909 storage_partition_impl_->GetFileSystemContext(),
908 storage_partition_impl_->GetServiceWorkerContext(), 910 storage_partition_impl_->GetServiceWorkerContext(),
909 storage_partition_impl_->GetHostZoomLevelContext(), 911 storage_partition_impl_->GetHostZoomLevelContext(),
910 get_contexts_callback); 912 get_contexts_callback);
911 913
912 AddFilter(resource_message_filter); 914 AddFilter(resource_message_filter_.get());
915
913 MediaStreamManager* media_stream_manager = 916 MediaStreamManager* media_stream_manager =
914 BrowserMainLoop::GetInstance()->media_stream_manager(); 917 BrowserMainLoop::GetInstance()->media_stream_manager();
915 // The AudioInputRendererHost and AudioRendererHost needs to be available for 918 // The AudioInputRendererHost and AudioRendererHost needs to be available for
916 // lookup, so it's stashed in a member variable. 919 // lookup, so it's stashed in a member variable.
917 audio_input_renderer_host_ = new AudioInputRendererHost( 920 audio_input_renderer_host_ = new AudioInputRendererHost(
918 GetID(), base::GetProcId(GetHandle()), audio_manager, 921 GetID(), base::GetProcId(GetHandle()), audio_manager,
919 media_stream_manager, AudioMirroringManager::GetInstance(), 922 media_stream_manager, AudioMirroringManager::GetInstance(),
920 BrowserMainLoop::GetInstance()->user_input_monitor()); 923 BrowserMainLoop::GetInstance()->user_input_monitor());
921 AddFilter(audio_input_renderer_host_.get()); 924 AddFilter(audio_input_renderer_host_.get());
922 audio_renderer_host_ = new AudioRendererHost( 925 audio_renderer_host_ = new AudioRendererHost(
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
1106 if (memory_coordinator::IsEnabled()) { 1109 if (memory_coordinator::IsEnabled()) {
1107 GetInterfaceRegistry()->AddInterface( 1110 GetInterfaceRegistry()->AddInterface(
1108 base::Bind(&CreateMemoryCoordinatorHandle, GetID())); 1111 base::Bind(&CreateMemoryCoordinatorHandle, GetID()));
1109 } 1112 }
1110 1113
1111 #if defined(OS_ANDROID) 1114 #if defined(OS_ANDROID)
1112 InterfaceRegistrarAndroid::ExposeInterfacesToRenderer( 1115 InterfaceRegistrarAndroid::ExposeInterfacesToRenderer(
1113 mojo_child_connection_->interface_registry_android()); 1116 mojo_child_connection_->interface_registry_android());
1114 #endif 1117 #endif
1115 1118
1119 GetInterfaceRegistry()->AddInterface(base::Bind(
1120 &RenderProcessHostImpl::CreateURLLoaderFactory, base::Unretained(this)));
1121
1116 GetContentClient()->browser()->ExposeInterfacesToRenderer( 1122 GetContentClient()->browser()->ExposeInterfacesToRenderer(
1117 GetInterfaceRegistry(), this); 1123 GetInterfaceRegistry(), this);
1118 } 1124 }
1119 1125
1120 void RenderProcessHostImpl::CreateStoragePartitionService( 1126 void RenderProcessHostImpl::CreateStoragePartitionService(
1121 mojo::InterfaceRequest<mojom::StoragePartitionService> request) { 1127 mojo::InterfaceRequest<mojom::StoragePartitionService> request) {
1122 // DO NOT REMOVE THIS COMMAND LINE CHECK WITHOUT SECURITY REVIEW! 1128 // DO NOT REMOVE THIS COMMAND LINE CHECK WITHOUT SECURITY REVIEW!
1123 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 1129 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
1124 switches::kMojoLocalStorage)) { 1130 switches::kMojoLocalStorage)) {
1125 storage_partition_impl_->Bind(std::move(request)); 1131 storage_partition_impl_->Bind(std::move(request));
1126 } 1132 }
1127 } 1133 }
1128 1134
1135 void RenderProcessHostImpl::CreateURLLoaderFactory(
1136 mojo::InterfaceRequest<mojom::URLLoaderFactory> request) {
1137 url_loader_factory_holder_.reset(
1138 new URLLoaderFactoryHolder(resource_message_filter_, std::move(request)));
1139 }
1140
1129 int RenderProcessHostImpl::GetNextRoutingID() { 1141 int RenderProcessHostImpl::GetNextRoutingID() {
1130 return widget_helper_->GetNextRoutingID(); 1142 return widget_helper_->GetNextRoutingID();
1131 } 1143 }
1132 1144
1133 void RenderProcessHostImpl::ResumeDeferredNavigation( 1145 void RenderProcessHostImpl::ResumeDeferredNavigation(
1134 const GlobalRequestID& request_id) { 1146 const GlobalRequestID& request_id) {
1135 widget_helper_->ResumeDeferredNavigation(request_id); 1147 widget_helper_->ResumeDeferredNavigation(request_id);
1136 } 1148 }
1137 1149
1138 void RenderProcessHostImpl::NotifyTimezoneChange(const std::string& zone_id) { 1150 void RenderProcessHostImpl::NotifyTimezoneChange(const std::string& zone_id) {
(...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after
1852 1864
1853 void RenderProcessHostImpl::SetIgnoreInputEvents(bool ignore_input_events) { 1865 void RenderProcessHostImpl::SetIgnoreInputEvents(bool ignore_input_events) {
1854 ignore_input_events_ = ignore_input_events; 1866 ignore_input_events_ = ignore_input_events;
1855 } 1867 }
1856 1868
1857 bool RenderProcessHostImpl::IgnoreInputEvents() const { 1869 bool RenderProcessHostImpl::IgnoreInputEvents() const {
1858 return ignore_input_events_; 1870 return ignore_input_events_;
1859 } 1871 }
1860 1872
1861 void RenderProcessHostImpl::Cleanup() { 1873 void RenderProcessHostImpl::Cleanup() {
1874 DCHECK_CURRENTLY_ON(BrowserThread::UI);
1862 // Keep the one renderer thread around forever in single process mode. 1875 // Keep the one renderer thread around forever in single process mode.
1863 if (run_renderer_in_process()) 1876 if (run_renderer_in_process())
1864 return; 1877 return;
1865 1878
1866 // If within_process_died_observer_ is true, one of our observers performed an 1879 // If within_process_died_observer_ is true, one of our observers performed an
1867 // action that caused us to die (e.g. http://crbug.com/339504). Therefore, 1880 // action that caused us to die (e.g. http://crbug.com/339504). Therefore,
1868 // delay the destruction until all of the observer callbacks have been made, 1881 // delay the destruction until all of the observer callbacks have been made,
1869 // and guarantee that the RenderProcessHostDestroyed observer callback is 1882 // and guarantee that the RenderProcessHostDestroyed observer callback is
1870 // always the last callback fired. 1883 // always the last callback fired.
1871 if (within_process_died_observer_) { 1884 if (within_process_died_observer_) {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
1935 1948
1936 // It's important not to wait for the DeleteTask to delete the channel 1949 // It's important not to wait for the DeleteTask to delete the channel
1937 // proxy. Kill it off now. That way, in case the profile is going away, the 1950 // proxy. Kill it off now. That way, in case the profile is going away, the
1938 // rest of the objects attached to this RenderProcessHost start going 1951 // rest of the objects attached to this RenderProcessHost start going
1939 // away first, since deleting the channel proxy will post a 1952 // away first, since deleting the channel proxy will post a
1940 // OnChannelClosed() to IPC::ChannelProxy::Context on the IO thread. 1953 // OnChannelClosed() to IPC::ChannelProxy::Context on the IO thread.
1941 channel_.reset(); 1954 channel_.reset();
1942 1955
1943 // The following members should be cleared in ProcessDied() as well! 1956 // The following members should be cleared in ProcessDied() as well!
1944 message_port_message_filter_ = NULL; 1957 message_port_message_filter_ = NULL;
1958 url_loader_factory_holder_ = nullptr;
1945 1959
1946 RemoveUserData(kSessionStorageHolderKey); 1960 RemoveUserData(kSessionStorageHolderKey);
1947 1961
1948 // Remove ourself from the list of renderer processes so that we can't be 1962 // Remove ourself from the list of renderer processes so that we can't be
1949 // reused in between now and when the Delete task runs. 1963 // reused in between now and when the Delete task runs.
1950 UnregisterHost(GetID()); 1964 UnregisterHost(GetID());
1951 } 1965 }
1952 } 1966 }
1953 1967
1954 void RenderProcessHostImpl::AddPendingView() { 1968 void RenderProcessHostImpl::AddPendingView() {
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after
2440 2454
2441 within_process_died_observer_ = true; 2455 within_process_died_observer_ = true;
2442 NotificationService::current()->Notify( 2456 NotificationService::current()->Notify(
2443 NOTIFICATION_RENDERER_PROCESS_CLOSED, Source<RenderProcessHost>(this), 2457 NOTIFICATION_RENDERER_PROCESS_CLOSED, Source<RenderProcessHost>(this),
2444 Details<RendererClosedDetails>(&details)); 2458 Details<RendererClosedDetails>(&details));
2445 FOR_EACH_OBSERVER(RenderProcessHostObserver, observers_, 2459 FOR_EACH_OBSERVER(RenderProcessHostObserver, observers_,
2446 RenderProcessExited(this, status, exit_code)); 2460 RenderProcessExited(this, status, exit_code));
2447 within_process_died_observer_ = false; 2461 within_process_died_observer_ = false;
2448 2462
2449 message_port_message_filter_ = NULL; 2463 message_port_message_filter_ = NULL;
2464 url_loader_factory_holder_ = nullptr;
2450 RemoveUserData(kSessionStorageHolderKey); 2465 RemoveUserData(kSessionStorageHolderKey);
2451 2466
2452 IDMap<IPC::Listener>::iterator iter(&listeners_); 2467 IDMap<IPC::Listener>::iterator iter(&listeners_);
2453 while (!iter.IsAtEnd()) { 2468 while (!iter.IsAtEnd()) {
2454 iter.GetCurrentValue()->OnMessageReceived(FrameHostMsg_RenderProcessGone( 2469 iter.GetCurrentValue()->OnMessageReceived(FrameHostMsg_RenderProcessGone(
2455 iter.GetCurrentKey(), static_cast<int>(status), exit_code)); 2470 iter.GetCurrentKey(), static_cast<int>(status), exit_code));
2456 iter.Advance(); 2471 iter.Advance();
2457 } 2472 }
2458 2473
2459 // It's possible that one of the calls out to the observers might have caused 2474 // It's possible that one of the calls out to the observers might have caused
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
2764 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; 2779 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error;
2765 2780
2766 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. Alias 2781 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. Alias
2767 // enough information here so that we can determine what the bad message was. 2782 // enough information here so that we can determine what the bad message was.
2768 base::debug::Alias(&error); 2783 base::debug::Alias(&error);
2769 bad_message::ReceivedBadMessage(process.get(), 2784 bad_message::ReceivedBadMessage(process.get(),
2770 bad_message::RPH_MOJO_PROCESS_ERROR); 2785 bad_message::RPH_MOJO_PROCESS_ERROR);
2771 } 2786 }
2772 2787
2773 } // namespace content 2788 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698