Index: content/browser/renderer_host/render_process_host_impl.cc |
diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc |
index 2492461c853d1053ddc2f58ebf0c95e767fab692..b5cb610559c5c21cfd82f2d5b9ab3deb229d11f9 100644 |
--- a/content/browser/renderer_host/render_process_host_impl.cc |
+++ b/content/browser/renderer_host/render_process_host_impl.cc |
@@ -928,6 +928,11 @@ bool RenderProcessHostImpl::Init() { |
return true; |
} |
+void RenderProcessHostImpl::EnableSendQueue() { |
+ if (!channel_) |
+ InitializeChannelProxy(); |
+} |
+ |
void RenderProcessHostImpl::InitializeChannelProxy() { |
// Generate a token used to identify the new child process. |
child_token_ = mojo::edk::GenerateRandomToken(); |
@@ -972,15 +977,7 @@ void RenderProcessHostImpl::InitializeChannelProxy() { |
IPC::ChannelMojo::CreateServerFactory( |
bootstrap.PassInterface().PassHandle(), io_task_runner); |
-#if USE_ATTACHMENT_BROKER |
- if (channel_) { |
- IPC::AttachmentBroker::GetGlobal()->DeregisterCommunicationChannel( |
- channel_.get()); |
- } |
-#endif |
- |
- channel_.reset(); |
- channel_connected_ = false; |
+ ResetChannelProxy(); |
// Do NOT expand ifdef or run time condition checks here! Synchronous |
// IPCs from browser process are banned. It is only narrowly allowed |
@@ -1023,6 +1020,18 @@ void RenderProcessHostImpl::InitializeChannelProxy() { |
channel_->Pause(); |
} |
+void RenderProcessHostImpl::ResetChannelProxy() { |
+ if (!channel_) |
+ return; |
+ |
+#if USE_ATTACHMENT_BROKER |
+ IPC::AttachmentBroker::GetGlobal()->DeregisterCommunicationChannel( |
+ channel_.get()); |
+#endif |
+ channel_.reset(); |
+ channel_connected_ = false; |
+} |
+ |
void RenderProcessHostImpl::CreateMessageFilters() { |
DCHECK_CURRENTLY_ON(BrowserThread::UI); |
AddFilter(new ResourceSchedulerFilter(GetID())); |
@@ -2166,17 +2175,12 @@ void RenderProcessHostImpl::Cleanup() { |
base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this); |
deleting_soon_ = true; |
-#if USE_ATTACHMENT_BROKER |
- IPC::AttachmentBroker::GetGlobal()->DeregisterCommunicationChannel( |
- channel_.get()); |
-#endif |
- |
// It's important not to wait for the DeleteTask to delete the channel |
// proxy. Kill it off now. That way, in case the profile is going away, the |
// rest of the objects attached to this RenderProcessHost start going |
// away first, since deleting the channel proxy will post a |
// OnChannelClosed() to IPC::ChannelProxy::Context on the IO thread. |
- channel_.reset(); |
+ ResetChannelProxy(); |
// The following members should be cleared in ProcessDied() as well! |
message_port_message_filter_ = NULL; |
@@ -2663,11 +2667,7 @@ void RenderProcessHostImpl::ProcessDied(bool already_dead, |
child_process_launcher_.reset(); |
is_dead_ = true; |
- |
- // Clear all cached associated interface proxies as well, since these are |
- // effectively bound to the lifetime of the Channel. |
- remote_route_provider_.reset(); |
- renderer_interface_.reset(); |
+ ResetChannelProxy(); |
UpdateProcessPriority(); |
DCHECK(!is_process_backgrounded_); |
@@ -2694,7 +2694,9 @@ void RenderProcessHostImpl::ProcessDied(bool already_dead, |
// Initialize a new ChannelProxy in case this host is re-used for a new |
// process. This ensures that new messages can be sent on the host ASAP (even |
// before Init()) and they'll eventually reach the new process. |
- InitializeChannelProxy(); |
+ // |
+ // Note that this may have already been called by one of the above observers |
+ EnableSendQueue(); |
// It's possible that one of the calls out to the observers might have caused |
// this object to be no longer needed. |