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 1014 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1116 #elif defined(OS_WIN) | 1115 #elif defined(OS_WIN) |
1117 AddFilter(new DWriteFontProxyMessageFilter()); | 1116 AddFilter(new DWriteFontProxyMessageFilter()); |
1118 | 1117 |
1119 // The FontCacheDispatcher is required only when we're using GDI rendering. | 1118 // The FontCacheDispatcher is required only when we're using GDI rendering. |
1120 // TODO(scottmg): pdf/ppapi still require the renderer to be able to precache | 1119 // TODO(scottmg): pdf/ppapi still require the renderer to be able to precache |
1121 // GDI fonts (http://crbug.com/383227), even when using DirectWrite. This | 1120 // GDI fonts (http://crbug.com/383227), even when using DirectWrite. This |
1122 // should eventually be if (!ShouldUseDirectWrite()) guarded. | 1121 // should eventually be if (!ShouldUseDirectWrite()) guarded. |
1123 channel_->AddFilter(new FontCacheDispatcher()); | 1122 channel_->AddFilter(new FontCacheDispatcher()); |
1124 #endif | 1123 #endif |
1125 | 1124 |
1126 message_port_message_filter_ = new MessagePortMessageFilter( | |
1127 base::Bind(&RenderWidgetHelper::GetNextRoutingID, | |
1128 base::Unretained(widget_helper_.get()))); | |
1129 AddFilter(message_port_message_filter_.get()); | |
1130 | |
1131 scoped_refptr<CacheStorageDispatcherHost> cache_storage_filter = | 1125 scoped_refptr<CacheStorageDispatcherHost> cache_storage_filter = |
1132 new CacheStorageDispatcherHost(); | 1126 new CacheStorageDispatcherHost(); |
1133 cache_storage_filter->Init(storage_partition_impl_->GetCacheStorageContext()); | 1127 cache_storage_filter->Init(storage_partition_impl_->GetCacheStorageContext()); |
1134 AddFilter(cache_storage_filter.get()); | 1128 AddFilter(cache_storage_filter.get()); |
1135 | 1129 |
1136 scoped_refptr<ServiceWorkerDispatcherHost> service_worker_filter = | 1130 scoped_refptr<ServiceWorkerDispatcherHost> service_worker_filter = |
1137 new ServiceWorkerDispatcherHost( | 1131 new ServiceWorkerDispatcherHost(GetID(), resource_context); |
1138 GetID(), message_port_message_filter_.get(), resource_context); | |
1139 service_worker_filter->Init( | 1132 service_worker_filter->Init( |
1140 storage_partition_impl_->GetServiceWorkerContext()); | 1133 storage_partition_impl_->GetServiceWorkerContext()); |
1141 AddFilter(service_worker_filter.get()); | 1134 AddFilter(service_worker_filter.get()); |
1142 | 1135 |
1143 AddFilter(new SharedWorkerMessageFilter( | 1136 AddFilter(new SharedWorkerMessageFilter( |
1144 GetID(), resource_context, | 1137 GetID(), resource_context, |
1145 WorkerStoragePartition( | 1138 WorkerStoragePartition( |
1146 storage_partition_impl_->GetURLRequestContext(), | 1139 storage_partition_impl_->GetURLRequestContext(), |
1147 storage_partition_impl_->GetMediaURLRequestContext(), | 1140 storage_partition_impl_->GetMediaURLRequestContext(), |
1148 storage_partition_impl_->GetAppCacheService(), | 1141 storage_partition_impl_->GetAppCacheService(), |
1149 storage_partition_impl_->GetQuotaManager(), | 1142 storage_partition_impl_->GetQuotaManager(), |
1150 storage_partition_impl_->GetFileSystemContext(), | 1143 storage_partition_impl_->GetFileSystemContext(), |
1151 storage_partition_impl_->GetDatabaseTracker(), | 1144 storage_partition_impl_->GetDatabaseTracker(), |
1152 storage_partition_impl_->GetIndexedDBContext(), | 1145 storage_partition_impl_->GetIndexedDBContext(), |
1153 storage_partition_impl_->GetServiceWorkerContext()), | 1146 storage_partition_impl_->GetServiceWorkerContext()), |
1154 message_port_message_filter_.get())); | 1147 base::Bind(&RenderWidgetHelper::GetNextRoutingID, |
| 1148 base::Unretained(widget_helper_.get())))); |
1155 | 1149 |
1156 #if BUILDFLAG(ENABLE_WEBRTC) | 1150 #if BUILDFLAG(ENABLE_WEBRTC) |
1157 p2p_socket_dispatcher_host_ = new P2PSocketDispatcherHost( | 1151 p2p_socket_dispatcher_host_ = new P2PSocketDispatcherHost( |
1158 resource_context, request_context.get()); | 1152 resource_context, request_context.get()); |
1159 AddFilter(p2p_socket_dispatcher_host_.get()); | 1153 AddFilter(p2p_socket_dispatcher_host_.get()); |
1160 #endif | 1154 #endif |
1161 | 1155 |
1162 AddFilter(new TraceMessageFilter(GetID())); | 1156 AddFilter(new TraceMessageFilter(GetID())); |
1163 AddFilter(new ResolveProxyMsgHelper(request_context.get())); | 1157 AddFilter(new ResolveProxyMsgHelper(request_context.get())); |
1164 AddFilter(new QuotaDispatcherHost( | 1158 AddFilter(new QuotaDispatcherHost( |
(...skipping 1032 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2197 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this); | 2191 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this); |
2198 deleting_soon_ = true; | 2192 deleting_soon_ = true; |
2199 | 2193 |
2200 // It's important not to wait for the DeleteTask to delete the channel | 2194 // It's important not to wait for the DeleteTask to delete the channel |
2201 // proxy. Kill it off now. That way, in case the profile is going away, the | 2195 // proxy. Kill it off now. That way, in case the profile is going away, the |
2202 // rest of the objects attached to this RenderProcessHost start going | 2196 // rest of the objects attached to this RenderProcessHost start going |
2203 // away first, since deleting the channel proxy will post a | 2197 // away first, since deleting the channel proxy will post a |
2204 // OnChannelClosed() to IPC::ChannelProxy::Context on the IO thread. | 2198 // OnChannelClosed() to IPC::ChannelProxy::Context on the IO thread. |
2205 ResetChannelProxy(); | 2199 ResetChannelProxy(); |
2206 | 2200 |
2207 // The following members should be cleared in ProcessDied() as well! | |
2208 message_port_message_filter_ = NULL; | |
2209 | |
2210 // Its important to remove the kSessionStorageHolder after the channel | 2201 // Its important to remove the kSessionStorageHolder after the channel |
2211 // has been reset to avoid deleting the underlying namespaces prior | 2202 // has been reset to avoid deleting the underlying namespaces prior |
2212 // to processing ipcs referring to them. | 2203 // to processing ipcs referring to them. |
2213 DCHECK(!channel_); | 2204 DCHECK(!channel_); |
2214 RemoveUserData(kSessionStorageHolderKey); | 2205 RemoveUserData(kSessionStorageHolderKey); |
2215 | 2206 |
2216 // Remove ourself from the list of renderer processes so that we can't be | 2207 // Remove ourself from the list of renderer processes so that we can't be |
2217 // reused in between now and when the Delete task runs. | 2208 // reused in between now and when the Delete task runs. |
2218 UnregisterHost(GetID()); | 2209 UnregisterHost(GetID()); |
2219 | 2210 |
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2692 DCHECK(!is_process_backgrounded_); | 2683 DCHECK(!is_process_backgrounded_); |
2693 | 2684 |
2694 within_process_died_observer_ = true; | 2685 within_process_died_observer_ = true; |
2695 NotificationService::current()->Notify( | 2686 NotificationService::current()->Notify( |
2696 NOTIFICATION_RENDERER_PROCESS_CLOSED, Source<RenderProcessHost>(this), | 2687 NOTIFICATION_RENDERER_PROCESS_CLOSED, Source<RenderProcessHost>(this), |
2697 Details<RendererClosedDetails>(&details)); | 2688 Details<RendererClosedDetails>(&details)); |
2698 for (auto& observer : observers_) | 2689 for (auto& observer : observers_) |
2699 observer.RenderProcessExited(this, status, exit_code); | 2690 observer.RenderProcessExited(this, status, exit_code); |
2700 within_process_died_observer_ = false; | 2691 within_process_died_observer_ = false; |
2701 | 2692 |
2702 message_port_message_filter_ = NULL; | |
2703 | |
2704 RemoveUserData(kSessionStorageHolderKey); | 2693 RemoveUserData(kSessionStorageHolderKey); |
2705 | 2694 |
2706 IDMap<IPC::Listener*>::iterator iter(&listeners_); | 2695 IDMap<IPC::Listener*>::iterator iter(&listeners_); |
2707 while (!iter.IsAtEnd()) { | 2696 while (!iter.IsAtEnd()) { |
2708 iter.GetCurrentValue()->OnMessageReceived(FrameHostMsg_RenderProcessGone( | 2697 iter.GetCurrentValue()->OnMessageReceived(FrameHostMsg_RenderProcessGone( |
2709 iter.GetCurrentKey(), static_cast<int>(status), exit_code)); | 2698 iter.GetCurrentKey(), static_cast<int>(status), exit_code)); |
2710 iter.Advance(); | 2699 iter.Advance(); |
2711 } | 2700 } |
2712 | 2701 |
2713 // Initialize a new ChannelProxy in case this host is re-used for a new | 2702 // 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... |
3025 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; | 3014 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; |
3026 | 3015 |
3027 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. | 3016 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. |
3028 // Capture the error message in a crash key value. | 3017 // Capture the error message in a crash key value. |
3029 base::debug::ScopedCrashKey error_key_value("mojo-message-error", error); | 3018 base::debug::ScopedCrashKey error_key_value("mojo-message-error", error); |
3030 bad_message::ReceivedBadMessage(render_process_id, | 3019 bad_message::ReceivedBadMessage(render_process_id, |
3031 bad_message::RPH_MOJO_PROCESS_ERROR); | 3020 bad_message::RPH_MOJO_PROCESS_ERROR); |
3032 } | 3021 } |
3033 | 3022 |
3034 } // namespace content | 3023 } // namespace content |
OLD | NEW |