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

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

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

Powered by Google App Engine
This is Rietveld 408576698