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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <string> | 10 #include <string> |
(...skipping 855 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
866 | 866 |
867 navigation_rfh = speculative_render_frame_host_.get(); | 867 navigation_rfh = speculative_render_frame_host_.get(); |
868 | 868 |
869 // Check if our current RFH is live. | 869 // Check if our current RFH is live. |
870 if (!render_frame_host_->IsRenderFrameLive()) { | 870 if (!render_frame_host_->IsRenderFrameLive()) { |
871 // The current RFH is not live. There's no reason to sit around with a | 871 // The current RFH is not live. There's no reason to sit around with a |
872 // sad tab or a newly created RFH while we wait for the navigation to | 872 // sad tab or a newly created RFH while we wait for the navigation to |
873 // complete. Just switch to the speculative RFH now and go back to normal. | 873 // complete. Just switch to the speculative RFH now and go back to normal. |
874 // (Note that we don't care about on{before}unload handlers if the current | 874 // (Note that we don't care about on{before}unload handlers if the current |
875 // RFH isn't live.) | 875 // RFH isn't live.) |
| 876 // |
| 877 // If the corresponding RenderFrame is currently associated with a proxy, |
| 878 // send a SwapIn message to ensure that the RenderFrame swaps into the |
| 879 // frame tree and replaces that proxy on the renderer side. Normally |
| 880 // this happens at navigation commit time, but in this case this must be |
| 881 // done earlier to keep browser and renderer state in sync. This is |
| 882 // important to do before CommitPending(), which destroys the |
| 883 // corresponding proxy. See https://crbug.com/487872. |
| 884 if (GetRenderFrameProxyHost(dest_site_instance.get())) { |
| 885 navigation_rfh->Send( |
| 886 new FrameMsg_SwapIn(navigation_rfh->GetRoutingID())); |
| 887 } |
876 CommitPending(); | 888 CommitPending(); |
877 | 889 |
878 // Notify the WebUI about the new RenderFrame if needed (the newly | 890 // Notify the WebUI about the new RenderFrame if needed (the newly |
879 // created WebUI has just been committed by CommitPending, so | 891 // created WebUI has just been committed by CommitPending, so |
880 // GetNavigatingWebUI() below will return false). | 892 // GetNavigatingWebUI() below will return false). |
881 if (notify_webui_of_rf_creation && render_frame_host_->web_ui()) { | 893 if (notify_webui_of_rf_creation && render_frame_host_->web_ui()) { |
882 render_frame_host_->web_ui()->RenderFrameCreated( | 894 render_frame_host_->web_ui()->RenderFrameCreated( |
883 render_frame_host_.get()); | 895 render_frame_host_.get()); |
884 notify_webui_of_rf_creation = false; | 896 notify_webui_of_rf_creation = false; |
885 } | 897 } |
(...skipping 1469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2355 pending_render_frame_host_.get()); | 2367 pending_render_frame_host_.get()); |
2356 } | 2368 } |
2357 | 2369 |
2358 // Check if our current RFH is live before we set up a transition. | 2370 // Check if our current RFH is live before we set up a transition. |
2359 if (!render_frame_host_->IsRenderFrameLive()) { | 2371 if (!render_frame_host_->IsRenderFrameLive()) { |
2360 // The current RFH is not live. There's no reason to sit around with a | 2372 // The current RFH is not live. There's no reason to sit around with a |
2361 // sad tab or a newly created RFH while we wait for the pending RFH to | 2373 // sad tab or a newly created RFH while we wait for the pending RFH to |
2362 // navigate. Just switch to the pending RFH now and go back to normal. | 2374 // navigate. Just switch to the pending RFH now and go back to normal. |
2363 // (Note that we don't care about on{before}unload handlers if the current | 2375 // (Note that we don't care about on{before}unload handlers if the current |
2364 // RFH isn't live.) | 2376 // RFH isn't live.) |
| 2377 // |
| 2378 // If the corresponding RenderFrame is currently associated with a proxy, |
| 2379 // send a SwapIn message to ensure that the RenderFrame swaps into the |
| 2380 // frame tree and replaces that proxy on the renderer side. Normally |
| 2381 // this happens at navigation commit time, but in this case this must be |
| 2382 // done earlier to keep browser and renderer state in sync. This is |
| 2383 // important to do before CommitPending(), which destroys the |
| 2384 // corresponding proxy. See https://crbug.com/487872. |
| 2385 if (GetRenderFrameProxyHost(new_instance.get())) { |
| 2386 pending_render_frame_host_->Send( |
| 2387 new FrameMsg_SwapIn(pending_render_frame_host_->GetRoutingID())); |
| 2388 } |
2365 CommitPending(); | 2389 CommitPending(); |
2366 return render_frame_host_.get(); | 2390 return render_frame_host_.get(); |
2367 } | 2391 } |
2368 // Otherwise, it's safe to treat this as a pending cross-process transition. | 2392 // Otherwise, it's safe to treat this as a pending cross-process transition. |
2369 | 2393 |
2370 bool is_transfer = transferred_request_id != GlobalRequestID(); | 2394 bool is_transfer = transferred_request_id != GlobalRequestID(); |
2371 if (is_transfer) { | 2395 if (is_transfer) { |
2372 // We don't need to stop the old renderer or run beforeunload/unload | 2396 // We don't need to stop the old renderer or run beforeunload/unload |
2373 // handlers, because those have already been done. | 2397 // handlers, because those have already been done. |
2374 DCHECK(transfer_navigation_handle_ && | 2398 DCHECK(transfer_navigation_handle_ && |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2751 resolved_url)) { | 2775 resolved_url)) { |
2752 DCHECK(!dest_instance || | 2776 DCHECK(!dest_instance || |
2753 dest_instance == render_frame_host_->GetSiteInstance()); | 2777 dest_instance == render_frame_host_->GetSiteInstance()); |
2754 return false; | 2778 return false; |
2755 } | 2779 } |
2756 | 2780 |
2757 return true; | 2781 return true; |
2758 } | 2782 } |
2759 | 2783 |
2760 } // namespace content | 2784 } // namespace content |
OLD | NEW |