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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 #include "content/browser/indexed_db/indexed_db_dispatcher_host.h" | 80 #include "content/browser/indexed_db/indexed_db_dispatcher_host.h" |
81 #include "content/browser/loader/resource_message_filter.h" | 81 #include "content/browser/loader/resource_message_filter.h" |
82 #include "content/browser/loader/resource_scheduler_filter.h" | 82 #include "content/browser/loader/resource_scheduler_filter.h" |
83 #include "content/browser/loader/url_loader_factory_impl.h" | 83 #include "content/browser/loader/url_loader_factory_impl.h" |
84 #include "content/browser/media/capture/audio_mirroring_manager.h" | 84 #include "content/browser/media/capture/audio_mirroring_manager.h" |
85 #include "content/browser/media/capture/image_capture_impl.h" | 85 #include "content/browser/media/capture/image_capture_impl.h" |
86 #include "content/browser/media/media_internals.h" | 86 #include "content/browser/media/media_internals.h" |
87 #include "content/browser/media/midi_host.h" | 87 #include "content/browser/media/midi_host.h" |
88 #include "content/browser/memory/memory_coordinator_impl.h" | 88 #include "content/browser/memory/memory_coordinator_impl.h" |
89 #include "content/browser/memory/memory_message_filter.h" | 89 #include "content/browser/memory/memory_message_filter.h" |
90 #include "content/browser/message_port_message_filter.h" | |
91 #include "content/browser/mime_registry_impl.h" | 90 #include "content/browser/mime_registry_impl.h" |
92 #include "content/browser/notifications/notification_message_filter.h" | 91 #include "content/browser/notifications/notification_message_filter.h" |
93 #include "content/browser/notifications/platform_notification_context_impl.h" | 92 #include "content/browser/notifications/platform_notification_context_impl.h" |
94 #include "content/browser/payments/payment_app_manager.h" | 93 #include "content/browser/payments/payment_app_manager.h" |
95 #include "content/browser/permissions/permission_service_context.h" | 94 #include "content/browser/permissions/permission_service_context.h" |
96 #include "content/browser/permissions/permission_service_impl.h" | 95 #include "content/browser/permissions/permission_service_impl.h" |
97 #include "content/browser/profiler_message_filter.h" | 96 #include "content/browser/profiler_message_filter.h" |
98 #include "content/browser/push_messaging/push_messaging_message_filter.h" | 97 #include "content/browser/push_messaging/push_messaging_message_filter.h" |
99 #include "content/browser/quota_dispatcher_host.h" | 98 #include "content/browser/quota_dispatcher_host.h" |
100 #include "content/browser/renderer_host/clipboard_message_filter.h" | 99 #include "content/browser/renderer_host/clipboard_message_filter.h" |
(...skipping 1030 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1131 #elif defined(OS_WIN) | 1130 #elif defined(OS_WIN) |
1132 AddFilter(new DWriteFontProxyMessageFilter()); | 1131 AddFilter(new DWriteFontProxyMessageFilter()); |
1133 | 1132 |
1134 // The FontCacheDispatcher is required only when we're using GDI rendering. | 1133 // The FontCacheDispatcher is required only when we're using GDI rendering. |
1135 // TODO(scottmg): pdf/ppapi still require the renderer to be able to precache | 1134 // TODO(scottmg): pdf/ppapi still require the renderer to be able to precache |
1136 // GDI fonts (http://crbug.com/383227), even when using DirectWrite. This | 1135 // GDI fonts (http://crbug.com/383227), even when using DirectWrite. This |
1137 // should eventually be if (!ShouldUseDirectWrite()) guarded. | 1136 // should eventually be if (!ShouldUseDirectWrite()) guarded. |
1138 channel_->AddFilter(new FontCacheDispatcher()); | 1137 channel_->AddFilter(new FontCacheDispatcher()); |
1139 #endif | 1138 #endif |
1140 | 1139 |
1141 message_port_message_filter_ = new MessagePortMessageFilter( | |
1142 base::Bind(&RenderWidgetHelper::GetNextRoutingID, | |
1143 base::Unretained(widget_helper_.get()))); | |
1144 AddFilter(message_port_message_filter_.get()); | |
1145 | |
1146 scoped_refptr<CacheStorageDispatcherHost> cache_storage_filter = | 1140 scoped_refptr<CacheStorageDispatcherHost> cache_storage_filter = |
1147 new CacheStorageDispatcherHost(); | 1141 new CacheStorageDispatcherHost(); |
1148 cache_storage_filter->Init(storage_partition_impl_->GetCacheStorageContext()); | 1142 cache_storage_filter->Init(storage_partition_impl_->GetCacheStorageContext()); |
1149 AddFilter(cache_storage_filter.get()); | 1143 AddFilter(cache_storage_filter.get()); |
1150 | 1144 |
1151 scoped_refptr<ServiceWorkerDispatcherHost> service_worker_filter = | 1145 scoped_refptr<ServiceWorkerDispatcherHost> service_worker_filter = |
1152 new ServiceWorkerDispatcherHost( | 1146 new ServiceWorkerDispatcherHost(GetID(), resource_context); |
1153 GetID(), message_port_message_filter_.get(), resource_context); | |
1154 service_worker_filter->Init( | 1147 service_worker_filter->Init( |
1155 storage_partition_impl_->GetServiceWorkerContext()); | 1148 storage_partition_impl_->GetServiceWorkerContext()); |
1156 AddFilter(service_worker_filter.get()); | 1149 AddFilter(service_worker_filter.get()); |
1157 | 1150 |
1158 AddFilter(new SharedWorkerMessageFilter( | 1151 AddFilter(new SharedWorkerMessageFilter( |
1159 GetID(), resource_context, | 1152 GetID(), resource_context, |
1160 WorkerStoragePartition( | 1153 WorkerStoragePartition( |
1161 storage_partition_impl_->GetURLRequestContext(), | 1154 storage_partition_impl_->GetURLRequestContext(), |
1162 storage_partition_impl_->GetMediaURLRequestContext(), | 1155 storage_partition_impl_->GetMediaURLRequestContext(), |
1163 storage_partition_impl_->GetAppCacheService(), | 1156 storage_partition_impl_->GetAppCacheService(), |
1164 storage_partition_impl_->GetQuotaManager(), | 1157 storage_partition_impl_->GetQuotaManager(), |
1165 storage_partition_impl_->GetFileSystemContext(), | 1158 storage_partition_impl_->GetFileSystemContext(), |
1166 storage_partition_impl_->GetDatabaseTracker(), | 1159 storage_partition_impl_->GetDatabaseTracker(), |
1167 storage_partition_impl_->GetIndexedDBContext(), | 1160 storage_partition_impl_->GetIndexedDBContext(), |
1168 storage_partition_impl_->GetServiceWorkerContext()), | 1161 storage_partition_impl_->GetServiceWorkerContext()), |
1169 message_port_message_filter_.get())); | 1162 base::Bind(&RenderWidgetHelper::GetNextRoutingID, |
| 1163 base::Unretained(widget_helper_.get())))); |
1170 | 1164 |
1171 #if BUILDFLAG(ENABLE_WEBRTC) | 1165 #if BUILDFLAG(ENABLE_WEBRTC) |
1172 p2p_socket_dispatcher_host_ = new P2PSocketDispatcherHost( | 1166 p2p_socket_dispatcher_host_ = new P2PSocketDispatcherHost( |
1173 resource_context, request_context.get()); | 1167 resource_context, request_context.get()); |
1174 AddFilter(p2p_socket_dispatcher_host_.get()); | 1168 AddFilter(p2p_socket_dispatcher_host_.get()); |
1175 #endif | 1169 #endif |
1176 | 1170 |
1177 AddFilter(new TraceMessageFilter(GetID())); | 1171 AddFilter(new TraceMessageFilter(GetID())); |
1178 AddFilter(new ResolveProxyMsgHelper(request_context.get())); | 1172 AddFilter(new ResolveProxyMsgHelper(request_context.get())); |
1179 AddFilter(new QuotaDispatcherHost( | 1173 AddFilter(new QuotaDispatcherHost( |
(...skipping 1065 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2245 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this); | 2239 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this); |
2246 deleting_soon_ = true; | 2240 deleting_soon_ = true; |
2247 | 2241 |
2248 // It's important not to wait for the DeleteTask to delete the channel | 2242 // It's important not to wait for the DeleteTask to delete the channel |
2249 // proxy. Kill it off now. That way, in case the profile is going away, the | 2243 // proxy. Kill it off now. That way, in case the profile is going away, the |
2250 // rest of the objects attached to this RenderProcessHost start going | 2244 // rest of the objects attached to this RenderProcessHost start going |
2251 // away first, since deleting the channel proxy will post a | 2245 // away first, since deleting the channel proxy will post a |
2252 // OnChannelClosed() to IPC::ChannelProxy::Context on the IO thread. | 2246 // OnChannelClosed() to IPC::ChannelProxy::Context on the IO thread. |
2253 ResetChannelProxy(); | 2247 ResetChannelProxy(); |
2254 | 2248 |
2255 // The following members should be cleared in ProcessDied() as well! | |
2256 message_port_message_filter_ = NULL; | |
2257 | |
2258 // Its important to remove the kSessionStorageHolder after the channel | 2249 // Its important to remove the kSessionStorageHolder after the channel |
2259 // has been reset to avoid deleting the underlying namespaces prior | 2250 // has been reset to avoid deleting the underlying namespaces prior |
2260 // to processing ipcs referring to them. | 2251 // to processing ipcs referring to them. |
2261 DCHECK(!channel_); | 2252 DCHECK(!channel_); |
2262 RemoveUserData(kSessionStorageHolderKey); | 2253 RemoveUserData(kSessionStorageHolderKey); |
2263 | 2254 |
2264 // Remove ourself from the list of renderer processes so that we can't be | 2255 // Remove ourself from the list of renderer processes so that we can't be |
2265 // reused in between now and when the Delete task runs. | 2256 // reused in between now and when the Delete task runs. |
2266 UnregisterHost(GetID()); | 2257 UnregisterHost(GetID()); |
2267 | 2258 |
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2735 DCHECK(!is_process_backgrounded_); | 2726 DCHECK(!is_process_backgrounded_); |
2736 | 2727 |
2737 within_process_died_observer_ = true; | 2728 within_process_died_observer_ = true; |
2738 NotificationService::current()->Notify( | 2729 NotificationService::current()->Notify( |
2739 NOTIFICATION_RENDERER_PROCESS_CLOSED, Source<RenderProcessHost>(this), | 2730 NOTIFICATION_RENDERER_PROCESS_CLOSED, Source<RenderProcessHost>(this), |
2740 Details<RendererClosedDetails>(&details)); | 2731 Details<RendererClosedDetails>(&details)); |
2741 for (auto& observer : observers_) | 2732 for (auto& observer : observers_) |
2742 observer.RenderProcessExited(this, status, exit_code); | 2733 observer.RenderProcessExited(this, status, exit_code); |
2743 within_process_died_observer_ = false; | 2734 within_process_died_observer_ = false; |
2744 | 2735 |
2745 message_port_message_filter_ = NULL; | |
2746 | |
2747 RemoveUserData(kSessionStorageHolderKey); | 2736 RemoveUserData(kSessionStorageHolderKey); |
2748 | 2737 |
2749 IDMap<IPC::Listener*>::iterator iter(&listeners_); | 2738 IDMap<IPC::Listener*>::iterator iter(&listeners_); |
2750 while (!iter.IsAtEnd()) { | 2739 while (!iter.IsAtEnd()) { |
2751 iter.GetCurrentValue()->OnMessageReceived(FrameHostMsg_RenderProcessGone( | 2740 iter.GetCurrentValue()->OnMessageReceived(FrameHostMsg_RenderProcessGone( |
2752 iter.GetCurrentKey(), static_cast<int>(status), exit_code)); | 2741 iter.GetCurrentKey(), static_cast<int>(status), exit_code)); |
2753 iter.Advance(); | 2742 iter.Advance(); |
2754 } | 2743 } |
2755 | 2744 |
2756 // Initialize a new ChannelProxy in case this host is re-used for a new | 2745 // Initialize a new ChannelProxy in case this host is re-used for a new |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3073 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; | 3062 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; |
3074 | 3063 |
3075 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. | 3064 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. |
3076 // Capture the error message in a crash key value. | 3065 // Capture the error message in a crash key value. |
3077 base::debug::ScopedCrashKey error_key_value("mojo-message-error", error); | 3066 base::debug::ScopedCrashKey error_key_value("mojo-message-error", error); |
3078 bad_message::ReceivedBadMessage(render_process_id, | 3067 bad_message::ReceivedBadMessage(render_process_id, |
3079 bad_message::RPH_MOJO_PROCESS_ERROR); | 3068 bad_message::RPH_MOJO_PROCESS_ERROR); |
3080 } | 3069 } |
3081 | 3070 |
3082 } // namespace content | 3071 } // namespace content |
OLD | NEW |