Chromium Code Reviews| 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()) { | |
|
ncarter (slow)
2014/05/15 20:49:45
What guarantees that all frames sharing a RVH are
nasko
2014/05/15 20:53:45
Prior to frame tree replication, we always have on
| |
| 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 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 501 const std::vector<GURL>& transfer_url_chain, | 508 const std::vector<GURL>& transfer_url_chain, |
| 502 const Referrer& referrer, | 509 const Referrer& referrer, |
| 503 PageTransition page_transition, | 510 PageTransition page_transition, |
| 504 bool should_replace_current_entry) { | 511 bool should_replace_current_entry) { |
| 505 frame_tree_node_->render_manager()->OnCrossSiteResponse( | 512 frame_tree_node_->render_manager()->OnCrossSiteResponse( |
| 506 this, global_request_id, cross_site_transferring_request.Pass(), | 513 this, global_request_id, cross_site_transferring_request.Pass(), |
| 507 transfer_url_chain, referrer, page_transition, | 514 transfer_url_chain, referrer, page_transition, |
| 508 should_replace_current_entry); | 515 should_replace_current_entry); |
| 509 } | 516 } |
| 510 | 517 |
| 511 void RenderFrameHostImpl::SwapOut() { | 518 void RenderFrameHostImpl::SwapOut(RenderFrameProxyHost* proxy) { |
| 512 // TODO(creis): Move swapped out state to RFH. Until then, only update it | 519 // TODO(creis): Move swapped out state to RFH. Until then, only update it |
| 513 // when swapping out the main frame. | 520 // when swapping out the main frame. |
| 514 if (!GetParent()) { | 521 if (!GetParent()) { |
| 515 // If this RenderViewHost is not in the default state, it must have already | 522 // If this RenderViewHost is not in the default state, it must have already |
| 516 // gone through this, therefore just return. | 523 // gone through this, therefore just return. |
| 517 if (render_view_host_->rvh_state_ != RenderViewHostImpl::STATE_DEFAULT) | 524 if (render_view_host_->rvh_state_ != RenderViewHostImpl::STATE_DEFAULT) |
| 518 return; | 525 return; |
| 519 | 526 |
| 520 render_view_host_->SetState( | 527 render_view_host_->SetState( |
| 521 RenderViewHostImpl::STATE_WAITING_FOR_UNLOAD_ACK); | 528 RenderViewHostImpl::STATE_WAITING_FOR_UNLOAD_ACK); |
| 522 render_view_host_->unload_event_monitor_timeout_->Start( | 529 render_view_host_->unload_event_monitor_timeout_->Start( |
| 523 base::TimeDelta::FromMilliseconds( | 530 base::TimeDelta::FromMilliseconds( |
| 524 RenderViewHostImpl::kUnloadTimeoutMS)); | 531 RenderViewHostImpl::kUnloadTimeoutMS)); |
| 525 } | 532 } |
| 526 | 533 |
| 534 set_render_frame_proxy_host(proxy); | |
| 535 | |
| 527 if (render_view_host_->IsRenderViewLive()) | 536 if (render_view_host_->IsRenderViewLive()) |
| 528 Send(new FrameMsg_SwapOut(routing_id_)); | 537 Send(new FrameMsg_SwapOut(routing_id_, proxy->GetRoutingID())); |
| 529 | 538 |
| 530 if (!GetParent()) | 539 if (!GetParent()) |
| 531 delegate_->SwappedOut(this); | 540 delegate_->SwappedOut(this); |
| 532 | 541 |
| 533 // Allow the navigation to proceed. | 542 // Allow the navigation to proceed. |
| 534 frame_tree_node_->render_manager()->SwappedOut(this); | 543 frame_tree_node_->render_manager()->SwappedOut(this); |
| 535 } | 544 } |
| 536 | 545 |
| 537 void RenderFrameHostImpl::OnDidStartLoading(bool to_different_document) { | 546 void RenderFrameHostImpl::OnDidStartLoading(bool to_different_document) { |
| 538 delegate_->DidStartLoading(this, to_different_document); | 547 delegate_->DidStartLoading(this, to_different_document); |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 894 cancel_notification_callbacks_.erase(notification_id); | 903 cancel_notification_callbacks_.erase(notification_id); |
| 895 } | 904 } |
| 896 | 905 |
| 897 void RenderFrameHostImpl::DesktopNotificationPermissionRequestDone( | 906 void RenderFrameHostImpl::DesktopNotificationPermissionRequestDone( |
| 898 int callback_context) { | 907 int callback_context) { |
| 899 Send(new DesktopNotificationMsg_PermissionRequestDone( | 908 Send(new DesktopNotificationMsg_PermissionRequestDone( |
| 900 routing_id_, callback_context)); | 909 routing_id_, callback_context)); |
| 901 } | 910 } |
| 902 | 911 |
| 903 } // namespace content | 912 } // namespace content |
| OLD | NEW |