| 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/containers/hash_tables.h" | 8 #include "base/containers/hash_tables.h" |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/metrics/user_metrics_action.h" | 10 #include "base/metrics/user_metrics_action.h" |
| 11 #include "content/browser/child_process_security_policy_impl.h" | 11 #include "content/browser/child_process_security_policy_impl.h" |
| 12 #include "content/browser/frame_host/cross_process_frame_connector.h" | 12 #include "content/browser/frame_host/cross_process_frame_connector.h" |
| 13 #include "content/browser/frame_host/cross_site_transferring_request.h" | 13 #include "content/browser/frame_host/cross_site_transferring_request.h" |
| 14 #include "content/browser/frame_host/frame_tree.h" | 14 #include "content/browser/frame_host/frame_tree.h" |
| 15 #include "content/browser/frame_host/frame_tree_node.h" | 15 #include "content/browser/frame_host/frame_tree_node.h" |
| 16 #include "content/browser/frame_host/navigator.h" | 16 #include "content/browser/frame_host/navigator.h" |
| 17 #include "content/browser/frame_host/render_frame_host_delegate.h" | 17 #include "content/browser/frame_host/render_frame_host_delegate.h" |
| 18 #include "content/browser/frame_host/render_frame_proxy_host.h" |
| 18 #include "content/browser/renderer_host/input/input_router.h" | 19 #include "content/browser/renderer_host/input/input_router.h" |
| 19 #include "content/browser/renderer_host/input/timeout_monitor.h" | 20 #include "content/browser/renderer_host/input/timeout_monitor.h" |
| 20 #include "content/browser/renderer_host/render_view_host_impl.h" | 21 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 21 #include "content/common/desktop_notification_messages.h" | 22 #include "content/common/desktop_notification_messages.h" |
| 22 #include "content/common/frame_messages.h" | 23 #include "content/common/frame_messages.h" |
| 23 #include "content/common/input_messages.h" | 24 #include "content/common/input_messages.h" |
| 24 #include "content/common/inter_process_time_ticks_converter.h" | 25 #include "content/common/inter_process_time_ticks_converter.h" |
| 25 #include "content/common/swapped_out_messages.h" | 26 #include "content/common/swapped_out_messages.h" |
| 26 #include "content/public/browser/browser_thread.h" | 27 #include "content/public/browser/browser_thread.h" |
| 27 #include "content/public/browser/content_browser_client.h" | 28 #include "content/public/browser/content_browser_client.h" |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 RenderFrameHostImpl::RenderFrameHostImpl( | 142 RenderFrameHostImpl::RenderFrameHostImpl( |
| 142 RenderViewHostImpl* render_view_host, | 143 RenderViewHostImpl* render_view_host, |
| 143 RenderFrameHostDelegate* delegate, | 144 RenderFrameHostDelegate* delegate, |
| 144 FrameTree* frame_tree, | 145 FrameTree* frame_tree, |
| 145 FrameTreeNode* frame_tree_node, | 146 FrameTreeNode* frame_tree_node, |
| 146 int routing_id, | 147 int routing_id, |
| 147 bool is_swapped_out) | 148 bool is_swapped_out) |
| 148 : render_view_host_(render_view_host), | 149 : render_view_host_(render_view_host), |
| 149 delegate_(delegate), | 150 delegate_(delegate), |
| 150 cross_process_frame_connector_(NULL), | 151 cross_process_frame_connector_(NULL), |
| 152 render_frame_proxy_host_(NULL), |
| 151 frame_tree_(frame_tree), | 153 frame_tree_(frame_tree), |
| 152 frame_tree_node_(frame_tree_node), | 154 frame_tree_node_(frame_tree_node), |
| 153 routing_id_(routing_id), | 155 routing_id_(routing_id), |
| 154 is_swapped_out_(is_swapped_out), | 156 is_swapped_out_(is_swapped_out), |
| 155 weak_ptr_factory_(this) { | 157 weak_ptr_factory_(this) { |
| 156 frame_tree_->RegisterRenderFrameHost(this); | 158 frame_tree_->RegisterRenderFrameHost(this); |
| 157 GetProcess()->AddRoute(routing_id_, this); | 159 GetProcess()->AddRoute(routing_id_, this); |
| 158 g_routing_id_frame_map.Get().insert(std::make_pair( | 160 g_routing_id_frame_map.Get().insert(std::make_pair( |
| 159 RenderFrameHostID(GetProcess()->GetID(), routing_id_), | 161 RenderFrameHostID(GetProcess()->GetID(), routing_id_), |
| 160 this)); | 162 this)); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 RenderViewHost* RenderFrameHostImpl::GetRenderViewHost() { | 239 RenderViewHost* RenderFrameHostImpl::GetRenderViewHost() { |
| 238 return render_view_host_; | 240 return render_view_host_; |
| 239 } | 241 } |
| 240 | 242 |
| 241 bool RenderFrameHostImpl::Send(IPC::Message* message) { | 243 bool RenderFrameHostImpl::Send(IPC::Message* message) { |
| 242 if (IPC_MESSAGE_ID_CLASS(message->type()) == InputMsgStart) { | 244 if (IPC_MESSAGE_ID_CLASS(message->type()) == InputMsgStart) { |
| 243 return render_view_host_->input_router()->SendInput( | 245 return render_view_host_->input_router()->SendInput( |
| 244 make_scoped_ptr(message)); | 246 make_scoped_ptr(message)); |
| 245 } | 247 } |
| 246 | 248 |
| 249 if (render_view_host_->IsSwappedOut()) { |
| 250 DCHECK(render_frame_proxy_host_); |
| 251 return render_frame_proxy_host_->Send(message); |
| 252 } |
| 253 |
| 247 return GetProcess()->Send(message); | 254 return GetProcess()->Send(message); |
| 248 } | 255 } |
| 249 | 256 |
| 250 bool RenderFrameHostImpl::OnMessageReceived(const IPC::Message &msg) { | 257 bool RenderFrameHostImpl::OnMessageReceived(const IPC::Message &msg) { |
| 251 // Filter out most IPC messages if this renderer is swapped out. | 258 // Filter out most IPC messages if this renderer is swapped out. |
| 252 // We still want to handle certain ACKs to keep our state consistent. | 259 // We still want to handle certain ACKs to keep our state consistent. |
| 253 // TODO(nasko): Only check RenderViewHost state, as this object's own state | 260 // TODO(nasko): Only check RenderViewHost state, as this object's own state |
| 254 // isn't yet properly updated. Transition this check once the swapped out | 261 // isn't yet properly updated. Transition this check once the swapped out |
| 255 // state is correct in RenderFrameHost itself. | 262 // state is correct in RenderFrameHost itself. |
| 256 if (render_view_host_->IsSwappedOut()) { | 263 if (render_view_host_->IsSwappedOut()) { |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 const std::vector<GURL>& transfer_url_chain, | 500 const std::vector<GURL>& transfer_url_chain, |
| 494 const Referrer& referrer, | 501 const Referrer& referrer, |
| 495 PageTransition page_transition, | 502 PageTransition page_transition, |
| 496 bool should_replace_current_entry) { | 503 bool should_replace_current_entry) { |
| 497 frame_tree_node_->render_manager()->OnCrossSiteResponse( | 504 frame_tree_node_->render_manager()->OnCrossSiteResponse( |
| 498 this, global_request_id, cross_site_transferring_request.Pass(), | 505 this, global_request_id, cross_site_transferring_request.Pass(), |
| 499 transfer_url_chain, referrer, page_transition, | 506 transfer_url_chain, referrer, page_transition, |
| 500 should_replace_current_entry); | 507 should_replace_current_entry); |
| 501 } | 508 } |
| 502 | 509 |
| 503 void RenderFrameHostImpl::SwapOut() { | 510 void RenderFrameHostImpl::SwapOut(RenderFrameProxyHost* proxy) { |
| 504 // TODO(creis): Move swapped out state to RFH. Until then, only update it | 511 // TODO(creis): Move swapped out state to RFH. Until then, only update it |
| 505 // when swapping out the main frame. | 512 // when swapping out the main frame. |
| 506 if (!GetParent()) { | 513 if (!GetParent()) { |
| 507 // If this RenderViewHost is not in the default state, it must have already | 514 // If this RenderViewHost is not in the default state, it must have already |
| 508 // gone through this, therefore just return. | 515 // gone through this, therefore just return. |
| 509 if (render_view_host_->rvh_state_ != RenderViewHostImpl::STATE_DEFAULT) | 516 if (render_view_host_->rvh_state_ != RenderViewHostImpl::STATE_DEFAULT) |
| 510 return; | 517 return; |
| 511 | 518 |
| 512 render_view_host_->SetState( | 519 render_view_host_->SetState( |
| 513 RenderViewHostImpl::STATE_WAITING_FOR_UNLOAD_ACK); | 520 RenderViewHostImpl::STATE_WAITING_FOR_UNLOAD_ACK); |
| 514 render_view_host_->unload_event_monitor_timeout_->Start( | 521 render_view_host_->unload_event_monitor_timeout_->Start( |
| 515 base::TimeDelta::FromMilliseconds( | 522 base::TimeDelta::FromMilliseconds( |
| 516 RenderViewHostImpl::kUnloadTimeoutMS)); | 523 RenderViewHostImpl::kUnloadTimeoutMS)); |
| 517 } | 524 } |
| 518 | 525 |
| 526 set_render_frame_proxy_host(proxy); |
| 527 |
| 519 if (render_view_host_->IsRenderViewLive()) | 528 if (render_view_host_->IsRenderViewLive()) |
| 520 Send(new FrameMsg_SwapOut(routing_id_)); | 529 Send(new FrameMsg_SwapOut(routing_id_, proxy->GetRoutingID())); |
| 521 | 530 |
| 522 if (!GetParent()) | 531 if (!GetParent()) |
| 523 delegate_->SwappedOut(this); | 532 delegate_->SwappedOut(this); |
| 524 | 533 |
| 525 // Allow the navigation to proceed. | 534 // Allow the navigation to proceed. |
| 526 frame_tree_node_->render_manager()->SwappedOut(this); | 535 frame_tree_node_->render_manager()->SwappedOut(this); |
| 527 } | 536 } |
| 528 | 537 |
| 529 void RenderFrameHostImpl::OnDidStartLoading(bool to_different_document) { | 538 void RenderFrameHostImpl::OnDidStartLoading(bool to_different_document) { |
| 530 delegate_->DidStartLoading(this, to_different_document); | 539 delegate_->DidStartLoading(this, to_different_document); |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 886 cancel_notification_callbacks_.erase(notification_id); | 895 cancel_notification_callbacks_.erase(notification_id); |
| 887 } | 896 } |
| 888 | 897 |
| 889 void RenderFrameHostImpl::DesktopNotificationPermissionRequestDone( | 898 void RenderFrameHostImpl::DesktopNotificationPermissionRequestDone( |
| 890 int callback_context) { | 899 int callback_context) { |
| 891 Send(new DesktopNotificationMsg_PermissionRequestDone( | 900 Send(new DesktopNotificationMsg_PermissionRequestDone( |
| 892 routing_id_, callback_context)); | 901 routing_id_, callback_context)); |
| 893 } | 902 } |
| 894 | 903 |
| 895 } // namespace content | 904 } // namespace content |
| OLD | NEW |