| 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 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 569 // Clear any state if a pending navigation is canceled or pre-empted. | 569 // Clear any state if a pending navigation is canceled or pre-empted. |
| 570 if (suspended_nav_params_) | 570 if (suspended_nav_params_) |
| 571 suspended_nav_params_.reset(); | 571 suspended_nav_params_.reset(); |
| 572 navigations_suspended_ = false; | 572 navigations_suspended_ = false; |
| 573 } | 573 } |
| 574 | 574 |
| 575 void RenderViewHostImpl::SuppressDialogsUntilSwapOut() { | 575 void RenderViewHostImpl::SuppressDialogsUntilSwapOut() { |
| 576 Send(new ViewMsg_SuppressDialogsUntilSwapOut(GetRoutingID())); | 576 Send(new ViewMsg_SuppressDialogsUntilSwapOut(GetRoutingID())); |
| 577 } | 577 } |
| 578 | 578 |
| 579 void RenderViewHostImpl::SwapOut() { | |
| 580 // If this RenderViewHost is not in the default state, it must have already | |
| 581 // gone through this, therefore just return. | |
| 582 if (rvh_state_ != STATE_DEFAULT) | |
| 583 return; | |
| 584 | |
| 585 SetState(STATE_WAITING_FOR_UNLOAD_ACK); | |
| 586 unload_event_monitor_timeout_->Start( | |
| 587 base::TimeDelta::FromMilliseconds(kUnloadTimeoutMS)); | |
| 588 | |
| 589 if (IsRenderViewLive()) { | |
| 590 Send(new ViewMsg_SwapOut(GetRoutingID())); | |
| 591 } | |
| 592 delegate_->SwappedOut(this); | |
| 593 } | |
| 594 | |
| 595 void RenderViewHostImpl::OnSwapOutACK() { | |
| 596 OnSwappedOut(false); | |
| 597 } | |
| 598 | |
| 599 void RenderViewHostImpl::OnSwappedOut(bool timed_out) { | 579 void RenderViewHostImpl::OnSwappedOut(bool timed_out) { |
| 600 // Ignore spurious swap out ack. | 580 // Ignore spurious swap out ack. |
| 601 if (!IsWaitingForUnloadACK()) | 581 if (!IsWaitingForUnloadACK()) |
| 602 return; | 582 return; |
| 603 unload_event_monitor_timeout_->Stop(); | 583 unload_event_monitor_timeout_->Stop(); |
| 604 if (timed_out) { | 584 if (timed_out) { |
| 605 base::ProcessHandle process_handle = GetProcess()->GetHandle(); | 585 base::ProcessHandle process_handle = GetProcess()->GetHandle(); |
| 606 int views = 0; | 586 int views = 0; |
| 607 | 587 |
| 608 // Count the number of active widget hosts for the process, which | 588 // Count the number of active widget hosts for the process, which |
| (...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1142 OnRunJavaScriptMessage) | 1122 OnRunJavaScriptMessage) |
| 1143 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_RunBeforeUnloadConfirm, | 1123 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_RunBeforeUnloadConfirm, |
| 1144 OnRunBeforeUnloadConfirm) | 1124 OnRunBeforeUnloadConfirm) |
| 1145 IPC_MESSAGE_HANDLER(DragHostMsg_StartDragging, OnStartDragging) | 1125 IPC_MESSAGE_HANDLER(DragHostMsg_StartDragging, OnStartDragging) |
| 1146 IPC_MESSAGE_HANDLER(DragHostMsg_UpdateDragCursor, OnUpdateDragCursor) | 1126 IPC_MESSAGE_HANDLER(DragHostMsg_UpdateDragCursor, OnUpdateDragCursor) |
| 1147 IPC_MESSAGE_HANDLER(DragHostMsg_TargetDrop_ACK, OnTargetDropACK) | 1127 IPC_MESSAGE_HANDLER(DragHostMsg_TargetDrop_ACK, OnTargetDropACK) |
| 1148 IPC_MESSAGE_HANDLER(ViewHostMsg_TakeFocus, OnTakeFocus) | 1128 IPC_MESSAGE_HANDLER(ViewHostMsg_TakeFocus, OnTakeFocus) |
| 1149 IPC_MESSAGE_HANDLER(ViewHostMsg_FocusedNodeChanged, OnFocusedNodeChanged) | 1129 IPC_MESSAGE_HANDLER(ViewHostMsg_FocusedNodeChanged, OnFocusedNodeChanged) |
| 1150 IPC_MESSAGE_HANDLER(ViewHostMsg_AddMessageToConsole, OnAddMessageToConsole) | 1130 IPC_MESSAGE_HANDLER(ViewHostMsg_AddMessageToConsole, OnAddMessageToConsole) |
| 1151 IPC_MESSAGE_HANDLER(ViewHostMsg_ClosePage_ACK, OnClosePageACK) | 1131 IPC_MESSAGE_HANDLER(ViewHostMsg_ClosePage_ACK, OnClosePageACK) |
| 1152 IPC_MESSAGE_HANDLER(ViewHostMsg_SwapOut_ACK, OnSwapOutACK) | |
| 1153 #if defined(OS_ANDROID) | 1132 #if defined(OS_ANDROID) |
| 1154 IPC_MESSAGE_HANDLER(ViewHostMsg_SelectionRootBoundsChanged, | 1133 IPC_MESSAGE_HANDLER(ViewHostMsg_SelectionRootBoundsChanged, |
| 1155 OnSelectionRootBoundsChanged) | 1134 OnSelectionRootBoundsChanged) |
| 1156 #endif | 1135 #endif |
| 1157 IPC_MESSAGE_HANDLER(ViewHostMsg_ScriptEvalResponse, OnScriptEvalResponse) | 1136 IPC_MESSAGE_HANDLER(ViewHostMsg_ScriptEvalResponse, OnScriptEvalResponse) |
| 1158 IPC_MESSAGE_HANDLER(ViewHostMsg_DidZoomURL, OnDidZoomURL) | 1137 IPC_MESSAGE_HANDLER(ViewHostMsg_DidZoomURL, OnDidZoomURL) |
| 1159 IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_RequestPermission, | 1138 IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_RequestPermission, |
| 1160 OnRequestDesktopNotificationPermission) | 1139 OnRequestDesktopNotificationPermission) |
| 1161 IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_Show, | 1140 IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_Show, |
| 1162 OnShowDesktopNotification) | 1141 OnShowDesktopNotification) |
| (...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1948 return true; | 1927 return true; |
| 1949 } | 1928 } |
| 1950 | 1929 |
| 1951 void RenderViewHostImpl::AttachToFrameTree() { | 1930 void RenderViewHostImpl::AttachToFrameTree() { |
| 1952 FrameTree* frame_tree = delegate_->GetFrameTree(); | 1931 FrameTree* frame_tree = delegate_->GetFrameTree(); |
| 1953 | 1932 |
| 1954 frame_tree->ResetForMainFrameSwap(); | 1933 frame_tree->ResetForMainFrameSwap(); |
| 1955 } | 1934 } |
| 1956 | 1935 |
| 1957 } // namespace content | 1936 } // namespace content |
| OLD | NEW |