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

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

Issue 2422793002: HTML MessagePort as mojo::MessagePipeHandle (Closed)
Patch Set: Rebase Created 3 years, 11 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 1018 matching lines...) Expand 10 before | Expand all | Expand 10 after
1120 #elif defined(OS_WIN) 1119 #elif defined(OS_WIN)
1121 AddFilter(new DWriteFontProxyMessageFilter()); 1120 AddFilter(new DWriteFontProxyMessageFilter());
1122 1121
1123 // The FontCacheDispatcher is required only when we're using GDI rendering. 1122 // The FontCacheDispatcher is required only when we're using GDI rendering.
1124 // TODO(scottmg): pdf/ppapi still require the renderer to be able to precache 1123 // TODO(scottmg): pdf/ppapi still require the renderer to be able to precache
1125 // GDI fonts (http://crbug.com/383227), even when using DirectWrite. This 1124 // GDI fonts (http://crbug.com/383227), even when using DirectWrite. This
1126 // should eventually be if (!ShouldUseDirectWrite()) guarded. 1125 // should eventually be if (!ShouldUseDirectWrite()) guarded.
1127 channel_->AddFilter(new FontCacheDispatcher()); 1126 channel_->AddFilter(new FontCacheDispatcher());
1128 #endif 1127 #endif
1129 1128
1130 message_port_message_filter_ = new MessagePortMessageFilter(
1131 base::Bind(&RenderWidgetHelper::GetNextRoutingID,
1132 base::Unretained(widget_helper_.get())));
1133 AddFilter(message_port_message_filter_.get());
1134
1135 scoped_refptr<CacheStorageDispatcherHost> cache_storage_filter = 1129 scoped_refptr<CacheStorageDispatcherHost> cache_storage_filter =
1136 new CacheStorageDispatcherHost(); 1130 new CacheStorageDispatcherHost();
1137 cache_storage_filter->Init(storage_partition_impl_->GetCacheStorageContext()); 1131 cache_storage_filter->Init(storage_partition_impl_->GetCacheStorageContext());
1138 AddFilter(cache_storage_filter.get()); 1132 AddFilter(cache_storage_filter.get());
1139 1133
1140 scoped_refptr<ServiceWorkerDispatcherHost> service_worker_filter = 1134 scoped_refptr<ServiceWorkerDispatcherHost> service_worker_filter =
1141 new ServiceWorkerDispatcherHost( 1135 new ServiceWorkerDispatcherHost(GetID(), resource_context);
1142 GetID(), message_port_message_filter_.get(), resource_context);
1143 service_worker_filter->Init( 1136 service_worker_filter->Init(
1144 storage_partition_impl_->GetServiceWorkerContext()); 1137 storage_partition_impl_->GetServiceWorkerContext());
1145 AddFilter(service_worker_filter.get()); 1138 AddFilter(service_worker_filter.get());
1146 1139
1147 AddFilter(new SharedWorkerMessageFilter( 1140 AddFilter(new SharedWorkerMessageFilter(
1148 GetID(), resource_context, 1141 GetID(), resource_context,
1149 WorkerStoragePartition( 1142 WorkerStoragePartition(
1150 storage_partition_impl_->GetURLRequestContext(), 1143 storage_partition_impl_->GetURLRequestContext(),
1151 storage_partition_impl_->GetMediaURLRequestContext(), 1144 storage_partition_impl_->GetMediaURLRequestContext(),
1152 storage_partition_impl_->GetAppCacheService(), 1145 storage_partition_impl_->GetAppCacheService(),
1153 storage_partition_impl_->GetQuotaManager(), 1146 storage_partition_impl_->GetQuotaManager(),
1154 storage_partition_impl_->GetFileSystemContext(), 1147 storage_partition_impl_->GetFileSystemContext(),
1155 storage_partition_impl_->GetDatabaseTracker(), 1148 storage_partition_impl_->GetDatabaseTracker(),
1156 storage_partition_impl_->GetIndexedDBContext(), 1149 storage_partition_impl_->GetIndexedDBContext(),
1157 storage_partition_impl_->GetServiceWorkerContext()), 1150 storage_partition_impl_->GetServiceWorkerContext()),
1158 message_port_message_filter_.get())); 1151 base::Bind(&RenderWidgetHelper::GetNextRoutingID,
1152 base::Unretained(widget_helper_.get()))));
1159 1153
1160 #if BUILDFLAG(ENABLE_WEBRTC) 1154 #if BUILDFLAG(ENABLE_WEBRTC)
1161 p2p_socket_dispatcher_host_ = new P2PSocketDispatcherHost( 1155 p2p_socket_dispatcher_host_ = new P2PSocketDispatcherHost(
1162 resource_context, request_context.get()); 1156 resource_context, request_context.get());
1163 AddFilter(p2p_socket_dispatcher_host_.get()); 1157 AddFilter(p2p_socket_dispatcher_host_.get());
1164 #endif 1158 #endif
1165 1159
1166 AddFilter(new TraceMessageFilter(GetID())); 1160 AddFilter(new TraceMessageFilter(GetID()));
1167 AddFilter(new ResolveProxyMsgHelper(request_context.get())); 1161 AddFilter(new ResolveProxyMsgHelper(request_context.get()));
1168 AddFilter(new QuotaDispatcherHost( 1162 AddFilter(new QuotaDispatcherHost(
(...skipping 1060 matching lines...) Expand 10 before | Expand all | Expand 10 after
2229 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this); 2223 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this);
2230 deleting_soon_ = true; 2224 deleting_soon_ = true;
2231 2225
2232 // It's important not to wait for the DeleteTask to delete the channel 2226 // It's important not to wait for the DeleteTask to delete the channel
2233 // proxy. Kill it off now. That way, in case the profile is going away, the 2227 // proxy. Kill it off now. That way, in case the profile is going away, the
2234 // rest of the objects attached to this RenderProcessHost start going 2228 // rest of the objects attached to this RenderProcessHost start going
2235 // away first, since deleting the channel proxy will post a 2229 // away first, since deleting the channel proxy will post a
2236 // OnChannelClosed() to IPC::ChannelProxy::Context on the IO thread. 2230 // OnChannelClosed() to IPC::ChannelProxy::Context on the IO thread.
2237 ResetChannelProxy(); 2231 ResetChannelProxy();
2238 2232
2239 // The following members should be cleared in ProcessDied() as well!
2240 message_port_message_filter_ = NULL;
2241
2242 // Its important to remove the kSessionStorageHolder after the channel 2233 // Its important to remove the kSessionStorageHolder after the channel
2243 // has been reset to avoid deleting the underlying namespaces prior 2234 // has been reset to avoid deleting the underlying namespaces prior
2244 // to processing ipcs referring to them. 2235 // to processing ipcs referring to them.
2245 DCHECK(!channel_); 2236 DCHECK(!channel_);
2246 RemoveUserData(kSessionStorageHolderKey); 2237 RemoveUserData(kSessionStorageHolderKey);
2247 2238
2248 // Remove ourself from the list of renderer processes so that we can't be 2239 // Remove ourself from the list of renderer processes so that we can't be
2249 // reused in between now and when the Delete task runs. 2240 // reused in between now and when the Delete task runs.
2250 UnregisterHost(GetID()); 2241 UnregisterHost(GetID());
2251 2242
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
2719 DCHECK(!is_process_backgrounded_); 2710 DCHECK(!is_process_backgrounded_);
2720 2711
2721 within_process_died_observer_ = true; 2712 within_process_died_observer_ = true;
2722 NotificationService::current()->Notify( 2713 NotificationService::current()->Notify(
2723 NOTIFICATION_RENDERER_PROCESS_CLOSED, Source<RenderProcessHost>(this), 2714 NOTIFICATION_RENDERER_PROCESS_CLOSED, Source<RenderProcessHost>(this),
2724 Details<RendererClosedDetails>(&details)); 2715 Details<RendererClosedDetails>(&details));
2725 for (auto& observer : observers_) 2716 for (auto& observer : observers_)
2726 observer.RenderProcessExited(this, status, exit_code); 2717 observer.RenderProcessExited(this, status, exit_code);
2727 within_process_died_observer_ = false; 2718 within_process_died_observer_ = false;
2728 2719
2729 message_port_message_filter_ = NULL;
2730
2731 RemoveUserData(kSessionStorageHolderKey); 2720 RemoveUserData(kSessionStorageHolderKey);
2732 2721
2733 IDMap<IPC::Listener*>::iterator iter(&listeners_); 2722 IDMap<IPC::Listener*>::iterator iter(&listeners_);
2734 while (!iter.IsAtEnd()) { 2723 while (!iter.IsAtEnd()) {
2735 iter.GetCurrentValue()->OnMessageReceived(FrameHostMsg_RenderProcessGone( 2724 iter.GetCurrentValue()->OnMessageReceived(FrameHostMsg_RenderProcessGone(
2736 iter.GetCurrentKey(), static_cast<int>(status), exit_code)); 2725 iter.GetCurrentKey(), static_cast<int>(status), exit_code));
2737 iter.Advance(); 2726 iter.Advance();
2738 } 2727 }
2739 2728
2740 // Initialize a new ChannelProxy in case this host is re-used for a new 2729 // 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
3052 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; 3041 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error;
3053 3042
3054 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. 3043 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing.
3055 // Capture the error message in a crash key value. 3044 // Capture the error message in a crash key value.
3056 base::debug::ScopedCrashKey error_key_value("mojo-message-error", error); 3045 base::debug::ScopedCrashKey error_key_value("mojo-message-error", error);
3057 bad_message::ReceivedBadMessage(render_process_id, 3046 bad_message::ReceivedBadMessage(render_process_id,
3058 bad_message::RPH_MOJO_PROCESS_ERROR); 3047 bad_message::RPH_MOJO_PROCESS_ERROR);
3059 } 3048 }
3060 3049
3061 } // namespace content 3050 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698