Chromium Code Reviews| Index: content/browser/renderer_host/browser_render_process_host.cc |
| diff --git a/content/browser/renderer_host/browser_render_process_host.cc b/content/browser/renderer_host/browser_render_process_host.cc |
| index 7222b096aa1ee70a107f712d16a55ce7e821ea76..d365b68133ceb9a5fd4122c11b08ff4244d8035c 100644 |
| --- a/content/browser/renderer_host/browser_render_process_host.cc |
| +++ b/content/browser/renderer_host/browser_render_process_host.cc |
| @@ -187,6 +187,7 @@ class RendererURLRequestContextSelector |
| BrowserRenderProcessHost::BrowserRenderProcessHost(Profile* profile) |
| : RenderProcessHost(profile), |
| visible_widgets_(0), |
| + pending_views_(0), |
| backgrounded_(true), |
| ALLOW_THIS_IN_INITIALIZER_LIST(cached_dibs_cleaner_( |
| base::TimeDelta::FromSeconds(5), |
| @@ -463,6 +464,15 @@ int BrowserRenderProcessHost::VisibleWidgetCount() const { |
| return visible_widgets_; |
| } |
| +void BrowserRenderProcessHost::AddPendingView() { |
| + pending_views_++; |
| +} |
| + |
| +void BrowserRenderProcessHost::RemovePendingView() { |
| + DCHECK(pending_views_); |
| + pending_views_--; |
|
Matt Perry
2011/05/10 01:14:50
does this need to send a shutdown if pending_views
Charlie Reis
2011/05/10 01:33:09
Nope-- it'll also reach 0 if we commit the view an
|
| +} |
| + |
| void BrowserRenderProcessHost::AppendRendererCommandLine( |
| CommandLine* command_line) const { |
| // Pass the process type first, so it shows first in process listings. |
| @@ -784,6 +794,8 @@ bool BrowserRenderProcessHost::OnMessageReceived(const IPC::Message& msg) { |
| // Dispatch control messages. |
| bool msg_is_ok = true; |
| IPC_BEGIN_MESSAGE_MAP_EX(BrowserRenderProcessHost, msg, msg_is_ok) |
| + IPC_MESSAGE_HANDLER(ChildProcessHostMsg_ShutdownRequest, |
| + OnShutdownRequest) |
| IPC_MESSAGE_HANDLER(ViewHostMsg_UpdatedCacheStats, |
| OnUpdatedCacheStats) |
| IPC_MESSAGE_HANDLER(ViewHostMsg_SuddenTerminationChanged, |
| @@ -823,6 +835,10 @@ void BrowserRenderProcessHost::OnChannelConnected(int32 peer_pid) { |
| Send(new ChildProcessMsg_SetIPCLoggingEnabled( |
| IPC::Logging::GetInstance()->Enabled())); |
| #endif |
| + |
| + // Make sure the child checks with us before exiting, so that we do not try |
| + // to schedule a new navigation in a swapped out and exiting renderer. |
| + Send(new ChildProcessMsg_AskBeforeShutdown()); |
| } |
| void BrowserRenderProcessHost::OnChannelError() { |
| @@ -878,6 +894,20 @@ void BrowserRenderProcessHost::OnChannelError() { |
| // TODO(darin): clean this up |
| } |
| +void BrowserRenderProcessHost::OnShutdownRequest() { |
| + // Don't shutdown if there are pending RenderViews being swapped back in. |
| + if (pending_views_) |
| + return; |
| + |
| + // Notify any tabs that might have swapped out renderers from this process. |
| + // They should not attempt to swap them back in. |
| + NotificationService::current()->Notify( |
| + NotificationType::RENDERER_PROCESS_CLOSING, |
| + Source<RenderProcessHost>(this), NotificationService::NoDetails()); |
| + |
| + Send(new ChildProcessMsg_Shutdown()); |
| +} |
| + |
| void BrowserRenderProcessHost::OnUpdatedCacheStats( |
| const WebCache::UsageStats& stats) { |
| WebCacheManager::GetInstance()->ObserveStats(id(), stats); |