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

Unified Diff: content/browser/renderer_host/browser_render_process_host.cc

Issue 6927014: Avoid exiting the renderer process if it has a pending render view. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix pre-render issue. Created 9 years, 8 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 side-by-side diff with in-line comments
Download patch
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 d422775d001d16a8c16ebd85926d622598de230d..3a54abf6092da36b04696f050c5e337a6ce09b06 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,19 @@ int BrowserRenderProcessHost::VisibleWidgetCount() const {
return visible_widgets_;
}
+void BrowserRenderProcessHost::AddPendingView() {
+ pending_views_++;
+}
+
+void BrowserRenderProcessHost::RemovePendingView() {
+ DCHECK(pending_views_);
+ pending_views_--;
+}
+
+int BrowserRenderProcessHost::PendingViewCount() const {
+ return pending_views_;
+}
+
void BrowserRenderProcessHost::AppendRendererCommandLine(
CommandLine* command_line) const {
// Pass the process type first, so it shows first in process listings.
@@ -777,6 +791,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,
@@ -816,6 +832,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() {
@@ -871,6 +891,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
+ // on the swapped out list. 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);

Powered by Google App Engine
This is Rietveld 408576698