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

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

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

Powered by Google App Engine
This is Rietveld 408576698