| 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 #include "content/browser/indexed_db/indexed_db_dispatcher_host.h" | 81 #include "content/browser/indexed_db/indexed_db_dispatcher_host.h" |
| 82 #include "content/browser/loader/resource_message_filter.h" | 82 #include "content/browser/loader/resource_message_filter.h" |
| 83 #include "content/browser/loader/resource_scheduler_filter.h" | 83 #include "content/browser/loader/resource_scheduler_filter.h" |
| 84 #include "content/browser/loader/url_loader_factory_impl.h" | 84 #include "content/browser/loader/url_loader_factory_impl.h" |
| 85 #include "content/browser/media/capture/audio_mirroring_manager.h" | 85 #include "content/browser/media/capture/audio_mirroring_manager.h" |
| 86 #include "content/browser/media/capture/image_capture_impl.h" | 86 #include "content/browser/media/capture/image_capture_impl.h" |
| 87 #include "content/browser/media/media_internals.h" | 87 #include "content/browser/media/media_internals.h" |
| 88 #include "content/browser/media/midi_host.h" | 88 #include "content/browser/media/midi_host.h" |
| 89 #include "content/browser/memory/memory_coordinator_impl.h" | 89 #include "content/browser/memory/memory_coordinator_impl.h" |
| 90 #include "content/browser/memory/memory_message_filter.h" | 90 #include "content/browser/memory/memory_message_filter.h" |
| 91 #include "content/browser/message_port_message_filter.h" | |
| 92 #include "content/browser/mime_registry_impl.h" | 91 #include "content/browser/mime_registry_impl.h" |
| 93 #include "content/browser/notifications/notification_message_filter.h" | 92 #include "content/browser/notifications/notification_message_filter.h" |
| 94 #include "content/browser/notifications/platform_notification_context_impl.h" | 93 #include "content/browser/notifications/platform_notification_context_impl.h" |
| 95 #include "content/browser/payments/payment_app_manager.h" | 94 #include "content/browser/payments/payment_app_manager.h" |
| 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" |
| (...skipping 1016 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1118 #elif defined(OS_WIN) | 1117 #elif defined(OS_WIN) |
| 1119 AddFilter(new DWriteFontProxyMessageFilter()); | 1118 AddFilter(new DWriteFontProxyMessageFilter()); |
| 1120 | 1119 |
| 1121 // The FontCacheDispatcher is required only when we're using GDI rendering. | 1120 // The FontCacheDispatcher is required only when we're using GDI rendering. |
| 1122 // TODO(scottmg): pdf/ppapi still require the renderer to be able to precache | 1121 // TODO(scottmg): pdf/ppapi still require the renderer to be able to precache |
| 1123 // GDI fonts (http://crbug.com/383227), even when using DirectWrite. This | 1122 // GDI fonts (http://crbug.com/383227), even when using DirectWrite. This |
| 1124 // should eventually be if (!ShouldUseDirectWrite()) guarded. | 1123 // should eventually be if (!ShouldUseDirectWrite()) guarded. |
| 1125 channel_->AddFilter(new FontCacheDispatcher()); | 1124 channel_->AddFilter(new FontCacheDispatcher()); |
| 1126 #endif | 1125 #endif |
| 1127 | 1126 |
| 1128 message_port_message_filter_ = new MessagePortMessageFilter( | |
| 1129 base::Bind(&RenderWidgetHelper::GetNextRoutingID, | |
| 1130 base::Unretained(widget_helper_.get()))); | |
| 1131 AddFilter(message_port_message_filter_.get()); | |
| 1132 | |
| 1133 scoped_refptr<CacheStorageDispatcherHost> cache_storage_filter = | 1127 scoped_refptr<CacheStorageDispatcherHost> cache_storage_filter = |
| 1134 new CacheStorageDispatcherHost(); | 1128 new CacheStorageDispatcherHost(); |
| 1135 cache_storage_filter->Init(storage_partition_impl_->GetCacheStorageContext()); | 1129 cache_storage_filter->Init(storage_partition_impl_->GetCacheStorageContext()); |
| 1136 AddFilter(cache_storage_filter.get()); | 1130 AddFilter(cache_storage_filter.get()); |
| 1137 | 1131 |
| 1138 scoped_refptr<ServiceWorkerDispatcherHost> service_worker_filter = | 1132 scoped_refptr<ServiceWorkerDispatcherHost> service_worker_filter = |
| 1139 new ServiceWorkerDispatcherHost( | 1133 new ServiceWorkerDispatcherHost(GetID(), resource_context); |
| 1140 GetID(), message_port_message_filter_.get(), resource_context); | |
| 1141 service_worker_filter->Init( | 1134 service_worker_filter->Init( |
| 1142 storage_partition_impl_->GetServiceWorkerContext()); | 1135 storage_partition_impl_->GetServiceWorkerContext()); |
| 1143 AddFilter(service_worker_filter.get()); | 1136 AddFilter(service_worker_filter.get()); |
| 1144 | 1137 |
| 1145 AddFilter(new SharedWorkerMessageFilter( | 1138 AddFilter(new SharedWorkerMessageFilter( |
| 1146 GetID(), resource_context, | 1139 GetID(), resource_context, |
| 1147 WorkerStoragePartition( | 1140 WorkerStoragePartition( |
| 1148 storage_partition_impl_->GetURLRequestContext(), | 1141 storage_partition_impl_->GetURLRequestContext(), |
| 1149 storage_partition_impl_->GetMediaURLRequestContext(), | 1142 storage_partition_impl_->GetMediaURLRequestContext(), |
| 1150 storage_partition_impl_->GetAppCacheService(), | 1143 storage_partition_impl_->GetAppCacheService(), |
| 1151 storage_partition_impl_->GetQuotaManager(), | 1144 storage_partition_impl_->GetQuotaManager(), |
| 1152 storage_partition_impl_->GetFileSystemContext(), | 1145 storage_partition_impl_->GetFileSystemContext(), |
| 1153 storage_partition_impl_->GetDatabaseTracker(), | 1146 storage_partition_impl_->GetDatabaseTracker(), |
| 1154 storage_partition_impl_->GetIndexedDBContext(), | 1147 storage_partition_impl_->GetIndexedDBContext(), |
| 1155 storage_partition_impl_->GetServiceWorkerContext()), | 1148 storage_partition_impl_->GetServiceWorkerContext()), |
| 1156 message_port_message_filter_.get())); | 1149 base::Bind(&RenderWidgetHelper::GetNextRoutingID, |
| 1150 base::Unretained(widget_helper_.get())))); |
| 1157 | 1151 |
| 1158 #if BUILDFLAG(ENABLE_WEBRTC) | 1152 #if BUILDFLAG(ENABLE_WEBRTC) |
| 1159 p2p_socket_dispatcher_host_ = new P2PSocketDispatcherHost( | 1153 p2p_socket_dispatcher_host_ = new P2PSocketDispatcherHost( |
| 1160 resource_context, request_context.get()); | 1154 resource_context, request_context.get()); |
| 1161 AddFilter(p2p_socket_dispatcher_host_.get()); | 1155 AddFilter(p2p_socket_dispatcher_host_.get()); |
| 1162 #endif | 1156 #endif |
| 1163 | 1157 |
| 1164 AddFilter(new TraceMessageFilter(GetID())); | 1158 AddFilter(new TraceMessageFilter(GetID())); |
| 1165 AddFilter(new ResolveProxyMsgHelper(request_context.get())); | 1159 AddFilter(new ResolveProxyMsgHelper(request_context.get())); |
| 1166 AddFilter(new QuotaDispatcherHost( | 1160 AddFilter(new QuotaDispatcherHost( |
| (...skipping 1040 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2207 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this); | 2201 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this); |
| 2208 deleting_soon_ = true; | 2202 deleting_soon_ = true; |
| 2209 | 2203 |
| 2210 // It's important not to wait for the DeleteTask to delete the channel | 2204 // It's important not to wait for the DeleteTask to delete the channel |
| 2211 // proxy. Kill it off now. That way, in case the profile is going away, the | 2205 // proxy. Kill it off now. That way, in case the profile is going away, the |
| 2212 // rest of the objects attached to this RenderProcessHost start going | 2206 // rest of the objects attached to this RenderProcessHost start going |
| 2213 // away first, since deleting the channel proxy will post a | 2207 // away first, since deleting the channel proxy will post a |
| 2214 // OnChannelClosed() to IPC::ChannelProxy::Context on the IO thread. | 2208 // OnChannelClosed() to IPC::ChannelProxy::Context on the IO thread. |
| 2215 ResetChannelProxy(); | 2209 ResetChannelProxy(); |
| 2216 | 2210 |
| 2217 // The following members should be cleared in ProcessDied() as well! | |
| 2218 message_port_message_filter_ = NULL; | |
| 2219 | |
| 2220 // Its important to remove the kSessionStorageHolder after the channel | 2211 // Its important to remove the kSessionStorageHolder after the channel |
| 2221 // has been reset to avoid deleting the underlying namespaces prior | 2212 // has been reset to avoid deleting the underlying namespaces prior |
| 2222 // to processing ipcs referring to them. | 2213 // to processing ipcs referring to them. |
| 2223 DCHECK(!channel_); | 2214 DCHECK(!channel_); |
| 2224 RemoveUserData(kSessionStorageHolderKey); | 2215 RemoveUserData(kSessionStorageHolderKey); |
| 2225 | 2216 |
| 2226 // Remove ourself from the list of renderer processes so that we can't be | 2217 // Remove ourself from the list of renderer processes so that we can't be |
| 2227 // reused in between now and when the Delete task runs. | 2218 // reused in between now and when the Delete task runs. |
| 2228 UnregisterHost(GetID()); | 2219 UnregisterHost(GetID()); |
| 2229 | 2220 |
| (...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2702 DCHECK(!is_process_backgrounded_); | 2693 DCHECK(!is_process_backgrounded_); |
| 2703 | 2694 |
| 2704 within_process_died_observer_ = true; | 2695 within_process_died_observer_ = true; |
| 2705 NotificationService::current()->Notify( | 2696 NotificationService::current()->Notify( |
| 2706 NOTIFICATION_RENDERER_PROCESS_CLOSED, Source<RenderProcessHost>(this), | 2697 NOTIFICATION_RENDERER_PROCESS_CLOSED, Source<RenderProcessHost>(this), |
| 2707 Details<RendererClosedDetails>(&details)); | 2698 Details<RendererClosedDetails>(&details)); |
| 2708 for (auto& observer : observers_) | 2699 for (auto& observer : observers_) |
| 2709 observer.RenderProcessExited(this, status, exit_code); | 2700 observer.RenderProcessExited(this, status, exit_code); |
| 2710 within_process_died_observer_ = false; | 2701 within_process_died_observer_ = false; |
| 2711 | 2702 |
| 2712 message_port_message_filter_ = NULL; | |
| 2713 | |
| 2714 RemoveUserData(kSessionStorageHolderKey); | 2703 RemoveUserData(kSessionStorageHolderKey); |
| 2715 | 2704 |
| 2716 IDMap<IPC::Listener*>::iterator iter(&listeners_); | 2705 IDMap<IPC::Listener*>::iterator iter(&listeners_); |
| 2717 while (!iter.IsAtEnd()) { | 2706 while (!iter.IsAtEnd()) { |
| 2718 iter.GetCurrentValue()->OnMessageReceived(FrameHostMsg_RenderProcessGone( | 2707 iter.GetCurrentValue()->OnMessageReceived(FrameHostMsg_RenderProcessGone( |
| 2719 iter.GetCurrentKey(), static_cast<int>(status), exit_code)); | 2708 iter.GetCurrentKey(), static_cast<int>(status), exit_code)); |
| 2720 iter.Advance(); | 2709 iter.Advance(); |
| 2721 } | 2710 } |
| 2722 | 2711 |
| 2723 // Initialize a new ChannelProxy in case this host is re-used for a new | 2712 // Initialize a new ChannelProxy in case this host is re-used for a new |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3035 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; | 3024 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; |
| 3036 | 3025 |
| 3037 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. | 3026 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. |
| 3038 // Capture the error message in a crash key value. | 3027 // Capture the error message in a crash key value. |
| 3039 base::debug::ScopedCrashKey error_key_value("mojo-message-error", error); | 3028 base::debug::ScopedCrashKey error_key_value("mojo-message-error", error); |
| 3040 bad_message::ReceivedBadMessage(render_process_id, | 3029 bad_message::ReceivedBadMessage(render_process_id, |
| 3041 bad_message::RPH_MOJO_PROCESS_ERROR); | 3030 bad_message::RPH_MOJO_PROCESS_ERROR); |
| 3042 } | 3031 } |
| 3043 | 3032 |
| 3044 } // namespace content | 3033 } // namespace content |
| OLD | NEW |