Chromium Code Reviews| Index: content/browser/tab_contents/render_view_host_manager.cc |
| diff --git a/content/browser/tab_contents/render_view_host_manager.cc b/content/browser/tab_contents/render_view_host_manager.cc |
| index d08f6abc332278958a504bf9c038105c8726d455..e7aa7eed538f3adab658542642ed0e6fa89ea172 100644 |
| --- a/content/browser/tab_contents/render_view_host_manager.cc |
| +++ b/content/browser/tab_contents/render_view_host_manager.cc |
| @@ -62,6 +62,10 @@ void RenderViewHostManager::Init(Profile* profile, |
| render_view_host_ = RenderViewHostFactory::Create( |
| site_instance, render_view_delegate_, routing_id, delegate_-> |
| GetControllerForRenderManager().session_storage_namespace()); |
| + |
| + // Keep track of renderer processes as they start to shut down. |
| + registrar_.Add(this, NotificationType::RENDERER_PROCESS_CLOSING, |
| + NotificationService::AllSources()); |
| } |
| RenderWidgetHostView* RenderViewHostManager::GetRenderWidgetHostView() const { |
| @@ -70,6 +74,19 @@ RenderWidgetHostView* RenderViewHostManager::GetRenderWidgetHostView() const { |
| return render_view_host_->view(); |
| } |
| +void RenderViewHostManager::Observe(NotificationType type, |
| + const NotificationSource& source, |
| + const NotificationDetails& details) { |
| + switch (type.value) { |
| + case NotificationType::RENDERER_PROCESS_CLOSING: |
| + RendererProcessClosing(Source<RenderProcessHost>(source).ptr()); |
| + break; |
| + |
| + default: |
| + NOTREACHED(); |
| + } |
| +} |
| + |
| RenderViewHost* RenderViewHostManager::Navigate(const NavigationEntry& entry) { |
| // Create a pending RenderViewHost. It will give us the one we should use |
| RenderViewHost* dest_render_view_host = UpdateRendererStateForNavigate(entry); |
| @@ -215,6 +232,12 @@ void RenderViewHostManager::RendererAbortedProvisionalLoad( |
| // the response is not a download. |
| } |
| +void RenderViewHostManager::RendererProcessClosing( |
| + RenderProcessHost* render_process_host) { |
| + // TODO(creis): Don't schedule new navigations in RenderViewHosts of this |
| + // process. (Part of http://crbug.com/65953.) |
| +} |
| + |
| void RenderViewHostManager::ShouldClosePage(bool for_cross_site_transition, |
| bool proceed) { |
| if (for_cross_site_transition) { |
| @@ -463,6 +486,9 @@ bool RenderViewHostManager::CreatePendingRenderView( |
| instance, render_view_delegate_, MSG_ROUTING_NONE, delegate_-> |
| GetControllerForRenderManager().session_storage_namespace()); |
| + // Prevent the process from exiting while we're trying to use it. |
| + pending_render_view_host_->process()->AddPendingView(); |
| + |
| bool success = InitRenderView(pending_render_view_host_, entry); |
| if (success) { |
| // Don't show the view until we get a DidNavigate from it. |
| @@ -526,6 +552,9 @@ void RenderViewHostManager::CommitPending() { |
| render_view_host_ = pending_render_view_host_; |
| pending_render_view_host_ = NULL; |
| + // The process will no longer try to exit, so we can decrement the count. |
| + render_view_host_->process()->RemovePendingView(); |
| + |
| // If the view is gone, then this RenderViewHost died while it was hidden. |
| // We ignored the RenderViewGone call at the time, so we should send it now |
| // to make sure the sad tab shows up, etc. |
| @@ -663,6 +692,9 @@ void RenderViewHostManager::CancelPending() { |
| pending_render_view_host_ = NULL; |
| pending_render_view_host->Shutdown(); |
| + // We no longer need to prevent the process from exiting. |
| + pending_render_view_host->process()->RemovePendingView(); |
|
Matt Perry
2011/05/10 01:14:02
does it matter if this comes before or after Shutd
Charlie Reis
2011/05/10 01:33:09
That's a good question-- Shutdown doesn't null out
|
| + |
| pending_web_ui_.reset(); |
| } |