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 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
527 // no longer on the stack when we send the SwapOut message. | 527 // no longer on the stack when we send the SwapOut message. |
528 delegate_->CancelModalDialogsForRenderManager(); | 528 delegate_->CancelModalDialogsForRenderManager(); |
529 | 529 |
530 // Tell the old renderer it is being swapped out. This will fire the unload | 530 // Tell the old renderer it is being swapped out. This will fire the unload |
531 // handler (without firing the beforeunload handler a second time). When the | 531 // handler (without firing the beforeunload handler a second time). When the |
532 // unload handler finishes and the navigation completes, we will send a | 532 // unload handler finishes and the navigation completes, we will send a |
533 // message to the ResourceDispatcherHost, allowing the pending RVH's response | 533 // message to the ResourceDispatcherHost, allowing the pending RVH's response |
534 // to resume. | 534 // to resume. |
535 // Note: This must be done on the RFH or else we'll swap out the top-level | 535 // Note: This must be done on the RFH or else we'll swap out the top-level |
536 // page when subframes navigate. | 536 // page when subframes navigate. |
537 if (frame_tree_node_->IsMainFrame()) | 537 if (frame_tree_node_->IsMainFrame()) { |
538 render_frame_host_->render_view_host()->SwapOut(); | 538 render_frame_host_->render_view_host()->SwapOut(); |
539 else | 539 } else { |
| 540 // The RenderFrameHost being swapped out becomes the proxy for this |
| 541 // frame in its parent's process. CrossProcessFrameConnector |
| 542 // initialization only needs to happen on an initial cross-process |
| 543 // navigation, when the RenderFrame leaves the same process as its parent. |
| 544 // The same CrossProcessFrameConnector is used for subsequent cross- |
| 545 // process navigations, but it will be destroyed if the Frame is |
| 546 // navigated back to the same site instance as its parent. |
| 547 // TODO(kenrb): This will change when RenderFrameProxyHost is created. |
| 548 if (!cross_process_frame_connector_) { |
| 549 cross_process_frame_connector_ = |
| 550 new CrossProcessFrameConnector(render_frame_host_); |
| 551 } |
540 render_frame_host_->SwapOut(); | 552 render_frame_host_->SwapOut(); |
| 553 } |
541 | 554 |
542 // ResourceDispatcherHost has told us to run the onunload handler, which | 555 // ResourceDispatcherHost has told us to run the onunload handler, which |
543 // means it is not a download or unsafe page, and we are going to perform the | 556 // means it is not a download or unsafe page, and we are going to perform the |
544 // navigation. Thus, we no longer need to remember that the RenderFrameHost | 557 // navigation. Thus, we no longer need to remember that the RenderFrameHost |
545 // is part of a pending cross-site request. | 558 // is part of a pending cross-site request. |
546 if (pending_render_frame_host_) { | 559 if (pending_render_frame_host_) { |
547 pending_render_frame_host_->render_view_host()-> | 560 pending_render_frame_host_->render_view_host()-> |
548 SetHasPendingCrossSiteRequest(false); | 561 SetHasPendingCrossSiteRequest(false); |
549 } | 562 } |
550 } | 563 } |
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
929 delete cross_process_frame_connector_; | 942 delete cross_process_frame_connector_; |
930 cross_process_frame_connector_ = NULL; | 943 cross_process_frame_connector_ = NULL; |
931 } | 944 } |
932 } | 945 } |
933 } else { | 946 } else { |
934 // Create a new RenderFrameHost if we don't find an existing one. | 947 // Create a new RenderFrameHost if we don't find an existing one. |
935 // TODO(creis): Make new_render_frame_host a scoped_ptr. | 948 // TODO(creis): Make new_render_frame_host a scoped_ptr. |
936 new_render_frame_host = CreateRenderFrameHost(instance, MSG_ROUTING_NONE, | 949 new_render_frame_host = CreateRenderFrameHost(instance, MSG_ROUTING_NONE, |
937 MSG_ROUTING_NONE, swapped_out, | 950 MSG_ROUTING_NONE, swapped_out, |
938 hidden); | 951 hidden); |
939 if (parent_node && !cross_process_frame_connector_) { | |
940 // The proxy RenderFrameHost to the parent process is either the current | |
941 // RenderFrameHost, or it has been added to the swapped out list. | |
942 // TODO(kenrb): This will change when RenderFrameProxyHost is created. | |
943 RenderFrameHostImpl* proxy_to_parent = render_frame_host_; | |
944 if (render_frame_host_->render_view_host()->GetSiteInstance() != | |
945 parent_node->render_manager()->current_host()->GetSiteInstance()) { | |
946 GetSwappedOutRenderFrameHost( | |
947 parent_node->render_manager()->current_host()->GetSiteInstance()); | |
948 } | |
949 CHECK(proxy_to_parent); | |
950 cross_process_frame_connector_ = | |
951 new CrossProcessFrameConnector(proxy_to_parent); | |
952 } | |
953 | 952 |
954 // If the new RFH is swapped out already, store it. Otherwise prevent the | 953 // If the new RFH is swapped out already, store it. Otherwise prevent the |
955 // process from exiting while we're trying to navigate in it. | 954 // process from exiting while we're trying to navigate in it. |
956 if (swapped_out) { | 955 if (swapped_out) { |
957 swapped_out_hosts_[instance->GetId()] = new_render_frame_host; | 956 swapped_out_hosts_[instance->GetId()] = new_render_frame_host; |
958 } else { | 957 } else { |
959 new_render_frame_host->GetProcess()->AddPendingView(); | 958 new_render_frame_host->GetProcess()->AddPendingView(); |
960 } | 959 } |
961 | 960 |
962 RenderViewHostImpl* render_view_host = | 961 RenderViewHostImpl* render_view_host = |
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1453 SiteInstance* instance) const { | 1452 SiteInstance* instance) const { |
1454 RenderFrameHostMap::const_iterator iter = | 1453 RenderFrameHostMap::const_iterator iter = |
1455 swapped_out_hosts_.find(instance->GetId()); | 1454 swapped_out_hosts_.find(instance->GetId()); |
1456 if (iter != swapped_out_hosts_.end()) | 1455 if (iter != swapped_out_hosts_.end()) |
1457 return iter->second; | 1456 return iter->second; |
1458 | 1457 |
1459 return NULL; | 1458 return NULL; |
1460 } | 1459 } |
1461 | 1460 |
1462 } // namespace content | 1461 } // namespace content |
OLD | NEW |