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

Side by Side Diff: content/browser/tab_contents/render_view_host_manager.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, 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #include "content/browser/tab_contents/render_view_host_manager.h" 5 #include "content/browser/tab_contents/render_view_host_manager.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/common/chrome_switches.h" 10 #include "chrome/common/chrome_switches.h"
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 // looks for this TabContents based on a render view ID. Instead, we just 208 // looks for this TabContents based on a render view ID. Instead, we just
209 // leave the pending renderer around until the next navigation event 209 // leave the pending renderer around until the next navigation event
210 // (Navigate, DidNavigate, etc), which will clean it up properly. 210 // (Navigate, DidNavigate, etc), which will clean it up properly.
211 // TODO(creis): All of this will go away when we move the cross-site logic 211 // TODO(creis): All of this will go away when we move the cross-site logic
212 // to ResourceDispatcherHost, so that we intercept responses rather than 212 // to ResourceDispatcherHost, so that we intercept responses rather than
213 // navigation events. (That's necessary to support onunload anyway.) Once 213 // navigation events. (That's necessary to support onunload anyway.) Once
214 // we've made that change, we won't create a pending renderer until we know 214 // we've made that change, we won't create a pending renderer until we know
215 // the response is not a download. 215 // the response is not a download.
216 } 216 }
217 217
218 void RenderViewHostManager::RendererProcessClosing(
219 RenderProcessHost* render_process_host) {
220 // TODO(creis): Don't schedule new navigations in RenderViewHosts of this
221 // process. (Part of http://crbug.com/65953.)
222 }
223
218 void RenderViewHostManager::ShouldClosePage(bool for_cross_site_transition, 224 void RenderViewHostManager::ShouldClosePage(bool for_cross_site_transition,
219 bool proceed) { 225 bool proceed) {
220 if (for_cross_site_transition) { 226 if (for_cross_site_transition) {
221 // Ignore if we're not in a cross-site navigation. 227 // Ignore if we're not in a cross-site navigation.
222 if (!cross_navigation_pending_) 228 if (!cross_navigation_pending_)
223 return; 229 return;
224 230
225 if (proceed) { 231 if (proceed) {
226 // Ok to unload the current page, so proceed with the cross-site 232 // Ok to unload the current page, so proceed with the cross-site
227 // navigation. Note that if navigations are not currently suspended, it 233 // navigation. Note that if navigations are not currently suspended, it
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 if (curr_entry) { 462 if (curr_entry) {
457 DCHECK(!curr_entry->content_state().empty()); 463 DCHECK(!curr_entry->content_state().empty());
458 // TODO(creis): Should send a message to the RenderView to let it know 464 // TODO(creis): Should send a message to the RenderView to let it know
459 // we're about to switch away, so that it sends an UpdateState message. 465 // we're about to switch away, so that it sends an UpdateState message.
460 } 466 }
461 467
462 pending_render_view_host_ = RenderViewHostFactory::Create( 468 pending_render_view_host_ = RenderViewHostFactory::Create(
463 instance, render_view_delegate_, MSG_ROUTING_NONE, delegate_-> 469 instance, render_view_delegate_, MSG_ROUTING_NONE, delegate_->
464 GetControllerForRenderManager().session_storage_namespace()); 470 GetControllerForRenderManager().session_storage_namespace());
465 471
472 // Prevent the process from exiting while we're trying to use it.
473 pending_render_view_host_->process()->AddPendingView();
474
466 bool success = InitRenderView(pending_render_view_host_, entry); 475 bool success = InitRenderView(pending_render_view_host_, entry);
467 if (success) { 476 if (success) {
468 // Don't show the view until we get a DidNavigate from it. 477 // Don't show the view until we get a DidNavigate from it.
469 pending_render_view_host_->view()->Hide(); 478 pending_render_view_host_->view()->Hide();
470 } else { 479 } else {
471 CancelPending(); 480 CancelPending();
472 } 481 }
473 return success; 482 return success;
474 } 483 }
475 484
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 // TODO(creis): Get the old RenderViewHost to send us an UpdateState message 528 // TODO(creis): Get the old RenderViewHost to send us an UpdateState message
520 // before we destroy it. 529 // before we destroy it.
521 if (render_view_host_->view()) 530 if (render_view_host_->view())
522 render_view_host_->view()->Hide(); 531 render_view_host_->view()->Hide();
523 RenderViewHost* old_render_view_host = render_view_host_; 532 RenderViewHost* old_render_view_host = render_view_host_;
524 533
525 // Swap in the pending view and make it active. 534 // Swap in the pending view and make it active.
526 render_view_host_ = pending_render_view_host_; 535 render_view_host_ = pending_render_view_host_;
527 pending_render_view_host_ = NULL; 536 pending_render_view_host_ = NULL;
528 537
538 // The process will no longer try to exit, so we can decrement the count.
539 render_view_host_->process()->RemovePendingView();
540
529 // If the view is gone, then this RenderViewHost died while it was hidden. 541 // If the view is gone, then this RenderViewHost died while it was hidden.
530 // We ignored the RenderViewGone call at the time, so we should send it now 542 // We ignored the RenderViewGone call at the time, so we should send it now
531 // to make sure the sad tab shows up, etc. 543 // to make sure the sad tab shows up, etc.
532 if (render_view_host_->view()) 544 if (render_view_host_->view())
533 render_view_host_->view()->Show(); 545 render_view_host_->view()->Show();
534 else 546 else
535 delegate_->RenderViewGoneFromRenderManager(render_view_host_); 547 delegate_->RenderViewGoneFromRenderManager(render_view_host_);
536 548
537 // Make sure the size is up to date. (Fix for bug 1079768.) 549 // Make sure the size is up to date. (Fix for bug 1079768.)
538 delegate_->UpdateRenderViewSizeForRenderManager(); 550 delegate_->UpdateRenderViewSizeForRenderManager();
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 // cross navigating. 668 // cross navigating.
657 DCHECK(!cross_navigation_pending_); 669 DCHECK(!cross_navigation_pending_);
658 return render_view_host_; 670 return render_view_host_;
659 } 671 }
660 672
661 void RenderViewHostManager::CancelPending() { 673 void RenderViewHostManager::CancelPending() {
662 RenderViewHost* pending_render_view_host = pending_render_view_host_; 674 RenderViewHost* pending_render_view_host = pending_render_view_host_;
663 pending_render_view_host_ = NULL; 675 pending_render_view_host_ = NULL;
664 pending_render_view_host->Shutdown(); 676 pending_render_view_host->Shutdown();
665 677
678 // We no longer need to prevent the process from exiting.
679 pending_render_view_host->process()->RemovePendingView();
680
666 pending_web_ui_.reset(); 681 pending_web_ui_.reset();
667 } 682 }
668 683
669 void RenderViewHostManager::RenderViewDeleted(RenderViewHost* rvh) { 684 void RenderViewHostManager::RenderViewDeleted(RenderViewHost* rvh) {
670 // We are doing this in order to work around and to track a crasher 685 // We are doing this in order to work around and to track a crasher
671 // (http://crbug.com/23411) where it seems that pending_render_view_host_ is 686 // (http://crbug.com/23411) where it seems that pending_render_view_host_ is
672 // deleted (not sure from where) but not NULLed. 687 // deleted (not sure from where) but not NULLed.
673 if (rvh == pending_render_view_host_) { 688 if (rvh == pending_render_view_host_) {
674 // If you hit this NOTREACHED, please report it in the following bug 689 // If you hit this NOTREACHED, please report it in the following bug
675 // http://crbug.com/23411 Make sure to include what you were doing when it 690 // http://crbug.com/23411 Make sure to include what you were doing when it
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 Source<NavigationController>(&delegate_->GetControllerForRenderManager()), 735 Source<NavigationController>(&delegate_->GetControllerForRenderManager()),
721 Details<RenderViewHostSwitchedDetails>(&details)); 736 Details<RenderViewHostSwitchedDetails>(&details));
722 737
723 // This will cause the old RenderViewHost to delete itself. 738 // This will cause the old RenderViewHost to delete itself.
724 old_render_view_host->Shutdown(); 739 old_render_view_host->Shutdown();
725 740
726 // Let the task manager know that we've swapped RenderViewHosts, since it 741 // Let the task manager know that we've swapped RenderViewHosts, since it
727 // might need to update its process groupings. 742 // might need to update its process groupings.
728 delegate_->NotifySwappedFromRenderManager(); 743 delegate_->NotifySwappedFromRenderManager();
729 } 744 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698