| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/tab_contents/render_view_host_manager.h" | 5 #include "content/browser/tab_contents/render_view_host_manager.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "content/browser/debugger/devtools_manager.h" | 9 #include "content/browser/debugger/devtools_manager.h" |
| 10 #include "content/browser/renderer_host/render_view_host.h" | 10 #include "content/browser/renderer_host/render_view_host.h" |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 pending_render_view_host_->SetNavigationsSuspended(false); | 160 pending_render_view_host_->SetNavigationsSuspended(false); |
| 161 } else { | 161 } else { |
| 162 // The request has been started and paused while we're waiting for the | 162 // The request has been started and paused while we're waiting for the |
| 163 // unload handler to finish. We'll pretend that it did, by notifying the | 163 // unload handler to finish. We'll pretend that it did, by notifying the |
| 164 // IO thread to let the response continue. The pending renderer will then | 164 // IO thread to let the response continue. The pending renderer will then |
| 165 // be swapped in as part of the usual DidNavigate logic. (If the unload | 165 // be swapped in as part of the usual DidNavigate logic. (If the unload |
| 166 // handler later finishes, this call will be ignored because the state in | 166 // handler later finishes, this call will be ignored because the state in |
| 167 // CrossSiteResourceHandler will already be cleaned up.) | 167 // CrossSiteResourceHandler will already be cleaned up.) |
| 168 ViewMsg_SwapOut_Params params; | 168 ViewMsg_SwapOut_Params params; |
| 169 params.new_render_process_host_id = | 169 params.new_render_process_host_id = |
| 170 pending_render_view_host_->process()->id(); | 170 pending_render_view_host_->process()->GetID(); |
| 171 params.new_request_id = pending_request_id; | 171 params.new_request_id = pending_request_id; |
| 172 current_host()->process()->CrossSiteSwapOutACK(params); | 172 current_host()->process()->CrossSiteSwapOutACK(params); |
| 173 } | 173 } |
| 174 return false; | 174 return false; |
| 175 } | 175 } |
| 176 | 176 |
| 177 void RenderViewHostManager::DidNavigateMainFrame( | 177 void RenderViewHostManager::DidNavigateMainFrame( |
| 178 RenderViewHost* render_view_host) { | 178 RenderViewHost* render_view_host) { |
| 179 if (!cross_navigation_pending_) { | 179 if (!cross_navigation_pending_) { |
| 180 DCHECK(!pending_render_view_host_); | 180 DCHECK(!pending_render_view_host_); |
| 181 | 181 |
| 182 // We should only hear this from our current renderer. | 182 // We should only hear this from our current renderer. |
| 183 DCHECK(render_view_host == render_view_host_); | 183 DCHECK(render_view_host == render_view_host_); |
| 184 | 184 |
| 185 // Even when there is no pending RVH, there may be a pending Web UI. | 185 // Even when there is no pending RVH, there may be a pending Web UI. |
| 186 if (pending_web_ui_.get()) | 186 if (pending_web_ui_.get()) |
| 187 CommitPending(); | 187 CommitPending(); |
| 188 return; | 188 return; |
| 189 } | 189 } |
| 190 | 190 |
| 191 if (render_view_host == pending_render_view_host_) { | 191 if (render_view_host == pending_render_view_host_) { |
| 192 // The pending cross-site navigation completed, so show the renderer. | 192 // The pending cross-site navigation completed, so show the renderer. |
| 193 // If it committed without sending network requests (e.g., data URLs), | 193 // If it committed without sending network requests (e.g., data URLs), |
| 194 // then we still need to swap out the old RVH first and run its unload | 194 // then we still need to swap out the old RVH first and run its unload |
| 195 // handler. OK for that to happen in the background. | 195 // handler. OK for that to happen in the background. |
| 196 if (pending_render_view_host_->GetPendingRequestId() == -1) { | 196 if (pending_render_view_host_->GetPendingRequestId() == -1) { |
| 197 OnCrossSiteResponse(pending_render_view_host_->process()->id(), | 197 OnCrossSiteResponse(pending_render_view_host_->process()->GetID(), |
| 198 pending_render_view_host_->routing_id()); | 198 pending_render_view_host_->routing_id()); |
| 199 } | 199 } |
| 200 | 200 |
| 201 CommitPending(); | 201 CommitPending(); |
| 202 cross_navigation_pending_ = false; | 202 cross_navigation_pending_ = false; |
| 203 } else if (render_view_host == render_view_host_) { | 203 } else if (render_view_host == render_view_host_) { |
| 204 // A navigation in the original page has taken place. Cancel the pending | 204 // A navigation in the original page has taken place. Cancel the pending |
| 205 // one. | 205 // one. |
| 206 CancelPending(); | 206 CancelPending(); |
| 207 cross_navigation_pending_ = false; | 207 cross_navigation_pending_ = false; |
| (...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 803 } | 803 } |
| 804 } | 804 } |
| 805 | 805 |
| 806 bool RenderViewHostManager::IsSwappedOut(RenderViewHost* rvh) { | 806 bool RenderViewHostManager::IsSwappedOut(RenderViewHost* rvh) { |
| 807 if (!rvh->site_instance()) | 807 if (!rvh->site_instance()) |
| 808 return false; | 808 return false; |
| 809 | 809 |
| 810 return swapped_out_hosts_.find(rvh->site_instance()->id()) != | 810 return swapped_out_hosts_.find(rvh->site_instance()->id()) != |
| 811 swapped_out_hosts_.end(); | 811 swapped_out_hosts_.end(); |
| 812 } | 812 } |
| OLD | NEW |