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

Side by Side Diff: content/browser/renderer_host/render_view_host_impl.cc

Issue 464593003: Don't swap out the old RenderFrameHost until the new one commits. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase past PlzNavigate CL Created 6 years, 4 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/renderer_host/render_view_host_impl.h" 5 #include "content/browser/renderer_host/render_view_host_impl.h"
6 6
7 #include <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 132
133 // static 133 // static
134 const int RenderViewHostImpl::kUnloadTimeoutMS = 1000; 134 const int RenderViewHostImpl::kUnloadTimeoutMS = 1000;
135 135
136 /////////////////////////////////////////////////////////////////////////////// 136 ///////////////////////////////////////////////////////////////////////////////
137 // RenderViewHost, public: 137 // RenderViewHost, public:
138 138
139 // static 139 // static
140 bool RenderViewHostImpl::IsRVHStateActive(RenderViewHostImplState rvh_state) { 140 bool RenderViewHostImpl::IsRVHStateActive(RenderViewHostImplState rvh_state) {
141 if (rvh_state == STATE_DEFAULT || 141 if (rvh_state == STATE_DEFAULT ||
142 rvh_state == STATE_WAITING_FOR_UNLOAD_ACK ||
143 rvh_state == STATE_WAITING_FOR_COMMIT ||
144 rvh_state == STATE_WAITING_FOR_CLOSE) 142 rvh_state == STATE_WAITING_FOR_CLOSE)
145 return true; 143 return true;
146 return false; 144 return false;
147 } 145 }
148 146
149 // static 147 // static
150 RenderViewHost* RenderViewHost::FromID(int render_process_id, 148 RenderViewHost* RenderViewHost::FromID(int render_process_id,
151 int render_view_id) { 149 int render_view_id) {
152 return RenderViewHostImpl::FromID(render_process_id, render_view_id); 150 return RenderViewHostImpl::FromID(render_process_id, render_view_id);
153 } 151 }
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 // Log a histogram point to help us diagnose how many of those kills 530 // Log a histogram point to help us diagnose how many of those kills
533 // we have performed. 1 is the enum value for RendererType Normal for 531 // we have performed. 1 is the enum value for RendererType Normal for
534 // the histogram. 532 // the histogram.
535 UMA_HISTOGRAM_PERCENTAGE( 533 UMA_HISTOGRAM_PERCENTAGE(
536 "BrowserRenderProcessHost.ChildKillsUnresponsive", 1); 534 "BrowserRenderProcessHost.ChildKillsUnresponsive", 1);
537 } 535 }
538 } 536 }
539 } 537 }
540 538
541 switch (rvh_state_) { 539 switch (rvh_state_) {
542 case STATE_WAITING_FOR_UNLOAD_ACK:
543 SetState(STATE_WAITING_FOR_COMMIT);
544 break;
545 case STATE_PENDING_SWAP_OUT: 540 case STATE_PENDING_SWAP_OUT:
546 SetState(STATE_SWAPPED_OUT); 541 SetState(STATE_SWAPPED_OUT);
547 break; 542 break;
548 case STATE_PENDING_SHUTDOWN: 543 case STATE_PENDING_SHUTDOWN:
549 DCHECK(!pending_shutdown_on_swap_out_.is_null()); 544 DCHECK(!pending_shutdown_on_swap_out_.is_null());
550 pending_shutdown_on_swap_out_.Run(); 545 pending_shutdown_on_swap_out_.Run();
551 break; 546 break;
552 default: 547 default:
553 NOTREACHED(); 548 NOTREACHED();
554 } 549 }
555 } 550 }
556 551
557 void RenderViewHostImpl::WasSwappedOut(
558 const base::Closure& pending_delete_on_swap_out) {
559 Send(new ViewMsg_WasSwappedOut(GetRoutingID()));
560 if (rvh_state_ == STATE_WAITING_FOR_UNLOAD_ACK) {
561 SetState(STATE_PENDING_SWAP_OUT);
562 if (!instance_->active_view_count())
563 SetPendingShutdown(pending_delete_on_swap_out);
564 } else if (rvh_state_ == STATE_WAITING_FOR_COMMIT) {
565 SetState(STATE_SWAPPED_OUT);
566 } else if (rvh_state_ == STATE_DEFAULT) {
567 // When the RenderView is not live, the RenderFrameHostManager will call
568 // CommitPending directly, without calling SwapOut on the old RVH. This will
569 // cause WasSwappedOut to be called directly on the live old RVH.
570 DCHECK(!IsRenderViewLive());
571 SetState(STATE_SWAPPED_OUT);
572 } else {
573 NOTREACHED();
574 }
575 }
576
577 void RenderViewHostImpl::SetPendingShutdown(const base::Closure& on_swap_out) { 552 void RenderViewHostImpl::SetPendingShutdown(const base::Closure& on_swap_out) {
578 pending_shutdown_on_swap_out_ = on_swap_out; 553 pending_shutdown_on_swap_out_ = on_swap_out;
579 SetState(STATE_PENDING_SHUTDOWN); 554 SetState(STATE_PENDING_SHUTDOWN);
580 } 555 }
581 556
582 void RenderViewHostImpl::ClosePage() { 557 void RenderViewHostImpl::ClosePage() {
583 SetState(STATE_WAITING_FOR_CLOSE); 558 SetState(STATE_WAITING_FOR_CLOSE);
584 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS)); 559 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS));
585 560
586 if (IsRenderViewLive()) { 561 if (IsRenderViewLive()) {
(...skipping 763 matching lines...) Expand 10 before | Expand all | Expand 10 after
1350 void RenderViewHostImpl::DidSelectPopupMenuItem(int selected_index) { 1325 void RenderViewHostImpl::DidSelectPopupMenuItem(int selected_index) {
1351 Send(new ViewMsg_SelectPopupMenuItem(GetRoutingID(), selected_index)); 1326 Send(new ViewMsg_SelectPopupMenuItem(GetRoutingID(), selected_index));
1352 } 1327 }
1353 1328
1354 void RenderViewHostImpl::DidCancelPopupMenu() { 1329 void RenderViewHostImpl::DidCancelPopupMenu() {
1355 Send(new ViewMsg_SelectPopupMenuItem(GetRoutingID(), -1)); 1330 Send(new ViewMsg_SelectPopupMenuItem(GetRoutingID(), -1));
1356 } 1331 }
1357 #endif 1332 #endif
1358 1333
1359 bool RenderViewHostImpl::IsWaitingForUnloadACK() const { 1334 bool RenderViewHostImpl::IsWaitingForUnloadACK() const {
1360 return rvh_state_ == STATE_WAITING_FOR_UNLOAD_ACK || 1335 return rvh_state_ == STATE_WAITING_FOR_CLOSE ||
1361 rvh_state_ == STATE_WAITING_FOR_CLOSE ||
1362 rvh_state_ == STATE_PENDING_SHUTDOWN || 1336 rvh_state_ == STATE_PENDING_SHUTDOWN ||
1363 rvh_state_ == STATE_PENDING_SWAP_OUT; 1337 rvh_state_ == STATE_PENDING_SWAP_OUT;
1364 } 1338 }
1365 1339
1366 void RenderViewHostImpl::OnTextSurroundingSelectionResponse( 1340 void RenderViewHostImpl::OnTextSurroundingSelectionResponse(
1367 const base::string16& content, 1341 const base::string16& content,
1368 size_t start_offset, 1342 size_t start_offset,
1369 size_t end_offset) { 1343 size_t end_offset) {
1370 if (!view_) 1344 if (!view_)
1371 return; 1345 return;
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
1558 FrameTree* frame_tree = delegate_->GetFrameTree(); 1532 FrameTree* frame_tree = delegate_->GetFrameTree();
1559 1533
1560 frame_tree->ResetForMainFrameSwap(); 1534 frame_tree->ResetForMainFrameSwap();
1561 } 1535 }
1562 1536
1563 void RenderViewHostImpl::SelectWordAroundCaret() { 1537 void RenderViewHostImpl::SelectWordAroundCaret() {
1564 Send(new ViewMsg_SelectWordAroundCaret(GetRoutingID())); 1538 Send(new ViewMsg_SelectWordAroundCaret(GetRoutingID()));
1565 } 1539 }
1566 1540
1567 } // namespace content 1541 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_view_host_impl.h ('k') | content/browser/web_contents/web_contents_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698