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_manager.h" | 5 #include "content/browser/frame_host/render_frame_host_manager.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
518 // no longer on the stack when we send the SwapOut message. | 518 // no longer on the stack when we send the SwapOut message. |
519 delegate_->CancelModalDialogsForRenderManager(); | 519 delegate_->CancelModalDialogsForRenderManager(); |
520 | 520 |
521 // Tell the old renderer it is being swapped out. This will fire the unload | 521 // Tell the old renderer it is being swapped out. This will fire the unload |
522 // handler (without firing the beforeunload handler a second time). When the | 522 // handler (without firing the beforeunload handler a second time). When the |
523 // unload handler finishes and the navigation completes, we will send a | 523 // unload handler finishes and the navigation completes, we will send a |
524 // message to the ResourceDispatcherHost, allowing the pending RVH's response | 524 // message to the ResourceDispatcherHost, allowing the pending RVH's response |
525 // to resume. | 525 // to resume. |
526 // Note: This must be done on the RFH or else we'll swap out the top-level | 526 // Note: This must be done on the RFH or else we'll swap out the top-level |
527 // page when subframes navigate. | 527 // page when subframes navigate. |
528 if (frame_tree_node_->IsMainFrame()) | 528 if (frame_tree_node_->IsMainFrame()) { |
529 render_frame_host_->render_view_host()->SwapOut(); | 529 render_frame_host_->render_view_host()->SwapOut(); |
530 else | 530 } else { |
531 // The RenderFrameHost being swapped out becomes the proxy for this | |
532 // frame in its parent's process. | |
Charlie Reis
2014/02/04 20:11:12
I think there's something more to explain in this
kenrb
2014/02/04 21:45:03
Done. Please check if the new comment makes sense
Charlie Reis
2014/02/04 21:52:41
Thanks, that's much better.
| |
533 // TODO(kenrb): This will change when RenderFrameProxyHost is created. | |
534 if (!cross_process_frame_connector_) | |
Charlie Reis
2014/02/04 20:11:12
Style nit: Needs braces.
kenrb
2014/02/04 21:45:03
Done.
| |
535 cross_process_frame_connector_ = | |
536 new CrossProcessFrameConnector(render_frame_host_); | |
531 render_frame_host_->SwapOut(); | 537 render_frame_host_->SwapOut(); |
538 } | |
532 | 539 |
533 // ResourceDispatcherHost has told us to run the onunload handler, which | 540 // ResourceDispatcherHost has told us to run the onunload handler, which |
534 // means it is not a download or unsafe page, and we are going to perform the | 541 // means it is not a download or unsafe page, and we are going to perform the |
535 // navigation. Thus, we no longer need to remember that the RenderFrameHost | 542 // navigation. Thus, we no longer need to remember that the RenderFrameHost |
536 // is part of a pending cross-site request. | 543 // is part of a pending cross-site request. |
537 if (pending_render_frame_host_) { | 544 if (pending_render_frame_host_) { |
538 pending_render_frame_host_->render_view_host()-> | 545 pending_render_frame_host_->render_view_host()-> |
539 SetHasPendingCrossSiteRequest(false); | 546 SetHasPendingCrossSiteRequest(false); |
540 } | 547 } |
541 } | 548 } |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
889 delete cross_process_frame_connector_; | 896 delete cross_process_frame_connector_; |
890 cross_process_frame_connector_ = NULL; | 897 cross_process_frame_connector_ = NULL; |
891 } | 898 } |
892 } | 899 } |
893 } else { | 900 } else { |
894 // Create a new RenderFrameHost if we don't find an existing one. | 901 // Create a new RenderFrameHost if we don't find an existing one. |
895 // TODO(creis): Make new_render_frame_host a scoped_ptr. | 902 // TODO(creis): Make new_render_frame_host a scoped_ptr. |
896 new_render_frame_host = CreateRenderFrameHost(instance, MSG_ROUTING_NONE, | 903 new_render_frame_host = CreateRenderFrameHost(instance, MSG_ROUTING_NONE, |
897 MSG_ROUTING_NONE, swapped_out, | 904 MSG_ROUTING_NONE, swapped_out, |
898 hidden); | 905 hidden); |
899 if (parent_node && !cross_process_frame_connector_) { | |
900 // The proxy RenderFrameHost to the parent process is either the current | |
901 // RenderFrameHost, or it has been added to the swapped out list. | |
902 // TODO(kenrb): This will change when RenderFrameProxyHost is created. | |
903 RenderFrameHostImpl* proxy_to_parent = render_frame_host_; | |
904 if (render_frame_host_->render_view_host()->GetSiteInstance() != | |
905 parent_node->render_manager()->current_host()->GetSiteInstance()) { | |
906 GetSwappedOutRenderFrameHost( | |
907 parent_node->render_manager()->current_host()->GetSiteInstance()); | |
908 } | |
909 CHECK(proxy_to_parent); | |
910 cross_process_frame_connector_ = | |
911 new CrossProcessFrameConnector(proxy_to_parent); | |
912 } | |
913 | 906 |
914 // If the new RFH is swapped out already, store it. Otherwise prevent the | 907 // If the new RFH is swapped out already, store it. Otherwise prevent the |
915 // process from exiting while we're trying to navigate in it. | 908 // process from exiting while we're trying to navigate in it. |
916 if (swapped_out) { | 909 if (swapped_out) { |
917 swapped_out_hosts_[instance->GetId()] = new_render_frame_host; | 910 swapped_out_hosts_[instance->GetId()] = new_render_frame_host; |
918 } else { | 911 } else { |
919 new_render_frame_host->GetProcess()->AddPendingView(); | 912 new_render_frame_host->GetProcess()->AddPendingView(); |
920 } | 913 } |
921 | 914 |
922 RenderViewHostImpl* render_view_host = | 915 RenderViewHostImpl* render_view_host = |
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1389 SiteInstance* instance) const { | 1382 SiteInstance* instance) const { |
1390 RenderFrameHostMap::const_iterator iter = | 1383 RenderFrameHostMap::const_iterator iter = |
1391 swapped_out_hosts_.find(instance->GetId()); | 1384 swapped_out_hosts_.find(instance->GetId()); |
1392 if (iter != swapped_out_hosts_.end()) | 1385 if (iter != swapped_out_hosts_.end()) |
1393 return iter->second; | 1386 return iter->second; |
1394 | 1387 |
1395 return NULL; | 1388 return NULL; |
1396 } | 1389 } |
1397 | 1390 |
1398 } // namespace content | 1391 } // namespace content |
OLD | NEW |