OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/web_contents/render_view_host_manager.h" | 5 #include "content/browser/web_contents/render_view_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/logging.h" | 10 #include "base/logging.h" |
(...skipping 814 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
825 // handlers if the current RVH isn't live.) | 825 // handlers if the current RVH isn't live.) |
826 CommitPending(); | 826 CommitPending(); |
827 return render_view_host_; | 827 return render_view_host_; |
828 } else { | 828 } else { |
829 NOTREACHED(); | 829 NOTREACHED(); |
830 return render_view_host_; | 830 return render_view_host_; |
831 } | 831 } |
832 } | 832 } |
833 // Otherwise, it's safe to treat this as a pending cross-site transition. | 833 // Otherwise, it's safe to treat this as a pending cross-site transition. |
834 | 834 |
835 // Make sure the old render view stops, in case a load is in progress. | |
836 render_view_host_->Send( | |
837 new ViewMsg_Stop(render_view_host_->GetRoutingID())); | |
838 | |
839 // We need to wait until the beforeunload handler has run, unless we are | 835 // We need to wait until the beforeunload handler has run, unless we are |
840 // transferring an existing request (in which case it has already run). | 836 // transferring an existing request (in which case it has already run). |
841 // Suspend the new render view (i.e., don't let it send the cross-site | 837 // Suspend the new render view (i.e., don't let it send the cross-site |
842 // Navigate message) until we hear back from the old renderer's | 838 // Navigate message) until we hear back from the old renderer's |
843 // beforeunload handler. If the handler returns false, we'll have to | 839 // beforeunload handler. If the handler returns false, we'll have to |
844 // cancel the request. | 840 // cancel the request. |
845 DCHECK(!pending_render_view_host_->are_navigations_suspended()); | 841 DCHECK(!pending_render_view_host_->are_navigations_suspended()); |
846 bool is_transfer = | 842 bool is_transfer = |
847 entry.transferred_global_request_id() != GlobalRequestID(); | 843 entry.transferred_global_request_id() != GlobalRequestID(); |
848 if (!is_transfer) { | 844 if (!is_transfer) { |
| 845 // Also make sure the old render view stops, in case a load is in |
| 846 // progress. (We don't want to do this for transfers, since it will |
| 847 // interrupt the transfer with an unexpected DidStopLoading.) |
| 848 render_view_host_->Send( |
| 849 new ViewMsg_Stop(render_view_host_->GetRoutingID())); |
| 850 |
849 pending_render_view_host_->SetNavigationsSuspended(true, | 851 pending_render_view_host_->SetNavigationsSuspended(true, |
850 base::TimeTicks()); | 852 base::TimeTicks()); |
851 } | 853 } |
852 | 854 |
853 // Tell the CrossSiteRequestManager that this RVH has a pending cross-site | 855 // Tell the CrossSiteRequestManager that this RVH has a pending cross-site |
854 // request, so that ResourceDispatcherHost will know to tell us to run the | 856 // request, so that ResourceDispatcherHost will know to tell us to run the |
855 // old page's unload handler before it sends the response. | 857 // old page's unload handler before it sends the response. |
856 pending_render_view_host_->SetHasPendingCrossSiteRequest(true, -1); | 858 pending_render_view_host_->SetHasPendingCrossSiteRequest(true, -1); |
857 | 859 |
858 // We now have a pending RVH. | 860 // We now have a pending RVH. |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
970 RenderViewHostImpl* RenderViewHostManager::GetSwappedOutRenderViewHost( | 972 RenderViewHostImpl* RenderViewHostManager::GetSwappedOutRenderViewHost( |
971 SiteInstance* instance) { | 973 SiteInstance* instance) { |
972 RenderViewHostMap::iterator iter = swapped_out_hosts_.find(instance->GetId()); | 974 RenderViewHostMap::iterator iter = swapped_out_hosts_.find(instance->GetId()); |
973 if (iter != swapped_out_hosts_.end()) | 975 if (iter != swapped_out_hosts_.end()) |
974 return iter->second; | 976 return iter->second; |
975 | 977 |
976 return NULL; | 978 return NULL; |
977 } | 979 } |
978 | 980 |
979 } // namespace content | 981 } // namespace content |
OLD | NEW |