| OLD | NEW |
| 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 Loading... |
| 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 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 // Log a histogram point to help us diagnose how many of those kills | 531 // Log a histogram point to help us diagnose how many of those kills |
| 534 // we have performed. 1 is the enum value for RendererType Normal for | 532 // we have performed. 1 is the enum value for RendererType Normal for |
| 535 // the histogram. | 533 // the histogram. |
| 536 UMA_HISTOGRAM_PERCENTAGE( | 534 UMA_HISTOGRAM_PERCENTAGE( |
| 537 "BrowserRenderProcessHost.ChildKillsUnresponsive", 1); | 535 "BrowserRenderProcessHost.ChildKillsUnresponsive", 1); |
| 538 } | 536 } |
| 539 } | 537 } |
| 540 } | 538 } |
| 541 | 539 |
| 542 switch (rvh_state_) { | 540 switch (rvh_state_) { |
| 543 case STATE_WAITING_FOR_UNLOAD_ACK: | |
| 544 SetState(STATE_WAITING_FOR_COMMIT); | |
| 545 break; | |
| 546 case STATE_PENDING_SWAP_OUT: | 541 case STATE_PENDING_SWAP_OUT: |
| 547 SetState(STATE_SWAPPED_OUT); | 542 SetState(STATE_SWAPPED_OUT); |
| 548 break; | 543 break; |
| 549 case STATE_PENDING_SHUTDOWN: | 544 case STATE_PENDING_SHUTDOWN: |
| 550 DCHECK(!pending_shutdown_on_swap_out_.is_null()); | 545 DCHECK(!pending_shutdown_on_swap_out_.is_null()); |
| 551 pending_shutdown_on_swap_out_.Run(); | 546 pending_shutdown_on_swap_out_.Run(); |
| 552 break; | 547 break; |
| 553 default: | 548 default: |
| 554 NOTREACHED(); | 549 NOTREACHED(); |
| 555 } | 550 } |
| 556 } | 551 } |
| 557 | 552 |
| 558 void RenderViewHostImpl::WasSwappedOut( | |
| 559 const base::Closure& pending_delete_on_swap_out) { | |
| 560 Send(new ViewMsg_WasSwappedOut(GetRoutingID())); | |
| 561 if (rvh_state_ == STATE_WAITING_FOR_UNLOAD_ACK) { | |
| 562 SetState(STATE_PENDING_SWAP_OUT); | |
| 563 if (!instance_->active_view_count()) | |
| 564 SetPendingShutdown(pending_delete_on_swap_out); | |
| 565 } else if (rvh_state_ == STATE_WAITING_FOR_COMMIT) { | |
| 566 SetState(STATE_SWAPPED_OUT); | |
| 567 } else if (rvh_state_ == STATE_DEFAULT) { | |
| 568 // When the RenderView is not live, the RenderFrameHostManager will call | |
| 569 // CommitPending directly, without calling SwapOut on the old RVH. This will | |
| 570 // cause WasSwappedOut to be called directly on the live old RVH. | |
| 571 DCHECK(!IsRenderViewLive()); | |
| 572 SetState(STATE_SWAPPED_OUT); | |
| 573 } else { | |
| 574 NOTREACHED(); | |
| 575 } | |
| 576 } | |
| 577 | |
| 578 void RenderViewHostImpl::SetPendingShutdown(const base::Closure& on_swap_out) { | 553 void RenderViewHostImpl::SetPendingShutdown(const base::Closure& on_swap_out) { |
| 579 pending_shutdown_on_swap_out_ = on_swap_out; | 554 pending_shutdown_on_swap_out_ = on_swap_out; |
| 580 SetState(STATE_PENDING_SHUTDOWN); | 555 SetState(STATE_PENDING_SHUTDOWN); |
| 581 } | 556 } |
| 582 | 557 |
| 583 void RenderViewHostImpl::ClosePage() { | 558 void RenderViewHostImpl::ClosePage() { |
| 584 SetState(STATE_WAITING_FOR_CLOSE); | 559 SetState(STATE_WAITING_FOR_CLOSE); |
| 585 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS)); | 560 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS)); |
| 586 | 561 |
| 587 if (IsRenderViewLive()) { | 562 if (IsRenderViewLive()) { |
| (...skipping 772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1360 void RenderViewHostImpl::DidSelectPopupMenuItem(int selected_index) { | 1335 void RenderViewHostImpl::DidSelectPopupMenuItem(int selected_index) { |
| 1361 Send(new ViewMsg_SelectPopupMenuItem(GetRoutingID(), selected_index)); | 1336 Send(new ViewMsg_SelectPopupMenuItem(GetRoutingID(), selected_index)); |
| 1362 } | 1337 } |
| 1363 | 1338 |
| 1364 void RenderViewHostImpl::DidCancelPopupMenu() { | 1339 void RenderViewHostImpl::DidCancelPopupMenu() { |
| 1365 Send(new ViewMsg_SelectPopupMenuItem(GetRoutingID(), -1)); | 1340 Send(new ViewMsg_SelectPopupMenuItem(GetRoutingID(), -1)); |
| 1366 } | 1341 } |
| 1367 #endif | 1342 #endif |
| 1368 | 1343 |
| 1369 bool RenderViewHostImpl::IsWaitingForUnloadACK() const { | 1344 bool RenderViewHostImpl::IsWaitingForUnloadACK() const { |
| 1370 return rvh_state_ == STATE_WAITING_FOR_UNLOAD_ACK || | 1345 return rvh_state_ == STATE_WAITING_FOR_CLOSE || |
| 1371 rvh_state_ == STATE_WAITING_FOR_CLOSE || | |
| 1372 rvh_state_ == STATE_PENDING_SHUTDOWN || | 1346 rvh_state_ == STATE_PENDING_SHUTDOWN || |
| 1373 rvh_state_ == STATE_PENDING_SWAP_OUT; | 1347 rvh_state_ == STATE_PENDING_SWAP_OUT; |
| 1374 } | 1348 } |
| 1375 | 1349 |
| 1376 void RenderViewHostImpl::OnTextSurroundingSelectionResponse( | 1350 void RenderViewHostImpl::OnTextSurroundingSelectionResponse( |
| 1377 const base::string16& content, | 1351 const base::string16& content, |
| 1378 size_t start_offset, | 1352 size_t start_offset, |
| 1379 size_t end_offset) { | 1353 size_t end_offset) { |
| 1380 if (!view_) | 1354 if (!view_) |
| 1381 return; | 1355 return; |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1568 FrameTree* frame_tree = delegate_->GetFrameTree(); | 1542 FrameTree* frame_tree = delegate_->GetFrameTree(); |
| 1569 | 1543 |
| 1570 frame_tree->ResetForMainFrameSwap(); | 1544 frame_tree->ResetForMainFrameSwap(); |
| 1571 } | 1545 } |
| 1572 | 1546 |
| 1573 void RenderViewHostImpl::SelectWordAroundCaret() { | 1547 void RenderViewHostImpl::SelectWordAroundCaret() { |
| 1574 Send(new ViewMsg_SelectWordAroundCaret(GetRoutingID())); | 1548 Send(new ViewMsg_SelectWordAroundCaret(GetRoutingID())); |
| 1575 } | 1549 } |
| 1576 | 1550 |
| 1577 } // namespace content | 1551 } // namespace content |
| OLD | NEW |