| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/frame_host/render_frame_host_impl.h" | 5 #include "content/browser/frame_host/render_frame_host_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 if (is_active()) | 268 if (is_active()) |
| 269 GetSiteInstance()->DecrementActiveFrameCount(); | 269 GetSiteInstance()->DecrementActiveFrameCount(); |
| 270 | 270 |
| 271 // If this RenderFrameHost is swapping with a RenderFrameProxyHost, the | 271 // If this RenderFrameHost is swapping with a RenderFrameProxyHost, the |
| 272 // RenderFrame will already be deleted in the renderer process. Main frame | 272 // RenderFrame will already be deleted in the renderer process. Main frame |
| 273 // RenderFrames will be cleaned up as part of deleting its RenderView. In all | 273 // RenderFrames will be cleaned up as part of deleting its RenderView. In all |
| 274 // other cases, the RenderFrame should be cleaned up (if it exists). | 274 // other cases, the RenderFrame should be cleaned up (if it exists). |
| 275 if (is_active() && !frame_tree_node_->IsMainFrame() && render_frame_created_) | 275 if (is_active() && !frame_tree_node_->IsMainFrame() && render_frame_created_) |
| 276 Send(new FrameMsg_Delete(routing_id_)); | 276 Send(new FrameMsg_Delete(routing_id_)); |
| 277 | 277 |
| 278 // NULL out the swapout timer; in crash dumps this member will be null only if | 278 // Null out the swapout timer; in crash dumps this member will be null only if |
| 279 // the dtor has run. | 279 // the dtor has run. (It may also be null in tests.) |
| 280 swapout_event_monitor_timeout_.reset(); | 280 swapout_event_monitor_timeout_.reset(); |
| 281 | 281 |
| 282 for (const auto& iter: visual_state_callbacks_) { | 282 for (const auto& iter: visual_state_callbacks_) { |
| 283 iter.second.Run(false); | 283 iter.second.Run(false); |
| 284 } | 284 } |
| 285 | 285 |
| 286 if (render_widget_host_ && | 286 if (render_widget_host_ && |
| 287 render_widget_host_->owned_by_render_frame_host()) { | 287 render_widget_host_->owned_by_render_frame_host()) { |
| 288 // Shutdown causes the RenderWidgetHost to delete itself. | 288 // Shutdown causes the RenderWidgetHost to delete itself. |
| 289 render_widget_host_->ShutdownAndDestroyWidget(true); | 289 render_widget_host_->ShutdownAndDestroyWidget(true); |
| (...skipping 884 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1174 // to be fixed when RenderViewHostImpl::OnSwapOut moves to RenderFrameHost. | 1174 // to be fixed when RenderViewHostImpl::OnSwapOut moves to RenderFrameHost. |
| 1175 TRACE_EVENT_ASYNC_BEGIN0("navigation", "RenderFrameHostImpl::SwapOut", this); | 1175 TRACE_EVENT_ASYNC_BEGIN0("navigation", "RenderFrameHostImpl::SwapOut", this); |
| 1176 | 1176 |
| 1177 // If this RenderFrameHost is already pending deletion, it must have already | 1177 // If this RenderFrameHost is already pending deletion, it must have already |
| 1178 // gone through this, therefore just return. | 1178 // gone through this, therefore just return. |
| 1179 if (!is_active()) { | 1179 if (!is_active()) { |
| 1180 NOTREACHED() << "RFH should be in default state when calling SwapOut."; | 1180 NOTREACHED() << "RFH should be in default state when calling SwapOut."; |
| 1181 return; | 1181 return; |
| 1182 } | 1182 } |
| 1183 | 1183 |
| 1184 swapout_event_monitor_timeout_->Start( | 1184 if (swapout_event_monitor_timeout_) { |
| 1185 base::TimeDelta::FromMilliseconds(RenderViewHostImpl::kUnloadTimeoutMS)); | 1185 swapout_event_monitor_timeout_->Start(base::TimeDelta::FromMilliseconds( |
| 1186 RenderViewHostImpl::kUnloadTimeoutMS)); |
| 1187 } |
| 1186 | 1188 |
| 1187 // There may be no proxy if there are no active views in the process. | 1189 // There may be no proxy if there are no active views in the process. |
| 1188 int proxy_routing_id = MSG_ROUTING_NONE; | 1190 int proxy_routing_id = MSG_ROUTING_NONE; |
| 1189 FrameReplicationState replication_state; | 1191 FrameReplicationState replication_state; |
| 1190 if (proxy) { | 1192 if (proxy) { |
| 1191 set_render_frame_proxy_host(proxy); | 1193 set_render_frame_proxy_host(proxy); |
| 1192 proxy_routing_id = proxy->GetRoutingID(); | 1194 proxy_routing_id = proxy->GetRoutingID(); |
| 1193 replication_state = proxy->frame_tree_node()->current_replication_state(); | 1195 replication_state = proxy->frame_tree_node()->current_replication_state(); |
| 1194 } | 1196 } |
| 1195 | 1197 |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1348 // |this| may be deleted. Any additional cleanup should happen before | 1350 // |this| may be deleted. Any additional cleanup should happen before |
| 1349 // the last block of code here. | 1351 // the last block of code here. |
| 1350 } | 1352 } |
| 1351 | 1353 |
| 1352 void RenderFrameHostImpl::OnSwappedOut() { | 1354 void RenderFrameHostImpl::OnSwappedOut() { |
| 1353 // Ignore spurious swap out ack. | 1355 // Ignore spurious swap out ack. |
| 1354 if (!is_waiting_for_swapout_ack_) | 1356 if (!is_waiting_for_swapout_ack_) |
| 1355 return; | 1357 return; |
| 1356 | 1358 |
| 1357 TRACE_EVENT_ASYNC_END0("navigation", "RenderFrameHostImpl::SwapOut", this); | 1359 TRACE_EVENT_ASYNC_END0("navigation", "RenderFrameHostImpl::SwapOut", this); |
| 1358 swapout_event_monitor_timeout_->Stop(); | 1360 if (swapout_event_monitor_timeout_) |
| 1361 swapout_event_monitor_timeout_->Stop(); |
| 1359 | 1362 |
| 1360 ClearAllWebUI(); | 1363 ClearAllWebUI(); |
| 1361 | 1364 |
| 1362 // If this is a main frame RFH that's about to be deleted, update its RVH's | 1365 // If this is a main frame RFH that's about to be deleted, update its RVH's |
| 1363 // swapped-out state here. https://crbug.com/505887 | 1366 // swapped-out state here. https://crbug.com/505887 |
| 1364 if (frame_tree_node_->IsMainFrame()) { | 1367 if (frame_tree_node_->IsMainFrame()) { |
| 1365 render_view_host_->set_is_active(false); | 1368 render_view_host_->set_is_active(false); |
| 1366 render_view_host_->set_is_swapped_out(true); | 1369 render_view_host_->set_is_swapped_out(true); |
| 1367 } | 1370 } |
| 1368 | 1371 |
| 1369 bool deleted = | 1372 bool deleted = |
| 1370 frame_tree_node_->render_manager()->DeleteFromPendingList(this); | 1373 frame_tree_node_->render_manager()->DeleteFromPendingList(this); |
| 1371 CHECK(deleted); | 1374 CHECK(deleted); |
| 1372 } | 1375 } |
| 1373 | 1376 |
| 1374 void RenderFrameHostImpl::ResetSwapOutTimerForTesting() { | 1377 void RenderFrameHostImpl::DisableSwapOutTimerForTesting() { |
| 1375 swapout_event_monitor_timeout_->Stop(); | 1378 swapout_event_monitor_timeout_.reset(); |
| 1376 } | 1379 } |
| 1377 | 1380 |
| 1378 void RenderFrameHostImpl::OnContextMenu(const ContextMenuParams& params) { | 1381 void RenderFrameHostImpl::OnContextMenu(const ContextMenuParams& params) { |
| 1379 // Validate the URLs in |params|. If the renderer can't request the URLs | 1382 // Validate the URLs in |params|. If the renderer can't request the URLs |
| 1380 // directly, don't show them in the context menu. | 1383 // directly, don't show them in the context menu. |
| 1381 ContextMenuParams validated_params(params); | 1384 ContextMenuParams validated_params(params); |
| 1382 RenderProcessHost* process = GetProcess(); | 1385 RenderProcessHost* process = GetProcess(); |
| 1383 | 1386 |
| 1384 // We don't validate |unfiltered_link_url| so that this field can be used | 1387 // We don't validate |unfiltered_link_url| so that this field can be used |
| 1385 // when users want to copy the original link URL. | 1388 // when users want to copy the original link URL. |
| (...skipping 1355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2741 } | 2744 } |
| 2742 | 2745 |
| 2743 void RenderFrameHostImpl::CreateWebBluetoothService( | 2746 void RenderFrameHostImpl::CreateWebBluetoothService( |
| 2744 blink::mojom::WebBluetoothServiceRequest request) { | 2747 blink::mojom::WebBluetoothServiceRequest request) { |
| 2745 DCHECK(!web_bluetooth_service_); | 2748 DCHECK(!web_bluetooth_service_); |
| 2746 web_bluetooth_service_.reset( | 2749 web_bluetooth_service_.reset( |
| 2747 new WebBluetoothServiceImpl(this, std::move(request))); | 2750 new WebBluetoothServiceImpl(this, std::move(request))); |
| 2748 } | 2751 } |
| 2749 | 2752 |
| 2750 } // namespace content | 2753 } // namespace content |
| OLD | NEW |