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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
181 entry.bindings() != NavigationEntryImpl::kInvalidBindings && | 181 entry.bindings() != NavigationEntryImpl::kInvalidBindings && |
182 pending_web_ui_->GetBindings() != entry.bindings()) { | 182 pending_web_ui_->GetBindings() != entry.bindings()) { |
183 RecordAction( | 183 RecordAction( |
184 base::UserMetricsAction("ProcessSwapBindingsMismatch_RVHM")); | 184 base::UserMetricsAction("ProcessSwapBindingsMismatch_RVHM")); |
185 pending_web_ui_.reset(); | 185 pending_web_ui_.reset(); |
186 } | 186 } |
187 } | 187 } |
188 | 188 |
189 RenderFrameHostImpl* RenderFrameHostManager::Navigate( | 189 RenderFrameHostImpl* RenderFrameHostManager::Navigate( |
190 const NavigationEntryImpl& entry) { | 190 const NavigationEntryImpl& entry) { |
191 TRACE_EVENT0("browser", "RenderFrameHostManager:Navigate"); | |
Charlie Reis
2014/08/27 22:05:13
I think it's better to keep this one than UpdateSt
nasko
2014/08/27 23:30:01
Done.
| |
192 // Create a pending RenderFrameHost to use for the navigation. | 191 // Create a pending RenderFrameHost to use for the navigation. |
193 RenderFrameHostImpl* dest_render_frame_host = UpdateStateForNavigate(entry); | 192 RenderFrameHostImpl* dest_render_frame_host = UpdateStateForNavigate(entry); |
194 if (!dest_render_frame_host) | 193 if (!dest_render_frame_host) |
195 return NULL; // We weren't able to create a pending render frame host. | 194 return NULL; // We weren't able to create a pending render frame host. |
196 | 195 |
197 // If the current render_frame_host_ isn't live, we should create it so | 196 // If the current render_frame_host_ isn't live, we should create it so |
198 // that we don't show a sad tab while the dest_render_frame_host fetches | 197 // that we don't show a sad tab while the dest_render_frame_host fetches |
199 // its first page. (Bug 1145340) | 198 // its first page. (Bug 1145340) |
200 if (dest_render_frame_host != render_frame_host_ && | 199 if (dest_render_frame_host != render_frame_host_ && |
201 !render_frame_host_->render_view_host()->IsRenderViewLive()) { | 200 !render_frame_host_->render_view_host()->IsRenderViewLive()) { |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
491 // Now delete them. | 490 // Now delete them. |
492 while (!ids_to_remove.empty()) { | 491 while (!ids_to_remove.empty()) { |
493 delete proxy_hosts_[ids_to_remove.back()]; | 492 delete proxy_hosts_[ids_to_remove.back()]; |
494 proxy_hosts_.erase(ids_to_remove.back()); | 493 proxy_hosts_.erase(ids_to_remove.back()); |
495 ids_to_remove.pop_back(); | 494 ids_to_remove.pop_back(); |
496 } | 495 } |
497 } | 496 } |
498 | 497 |
499 void RenderFrameHostManager::SwapOutOldPage( | 498 void RenderFrameHostManager::SwapOutOldPage( |
500 RenderFrameHostImpl* old_render_frame_host) { | 499 RenderFrameHostImpl* old_render_frame_host) { |
500 TRACE_EVENT1("navigation", "RenderFrameHostManager::SwapOutOldPage", | |
501 "FrameTreeNode id", frame_tree_node_->frame_tree_node_id()); | |
501 // Should only see this while we have a pending renderer. | 502 // Should only see this while we have a pending renderer. |
502 CHECK(cross_navigation_pending_); | 503 CHECK(cross_navigation_pending_); |
503 | 504 |
504 // Tell the renderer to suppress any further modal dialogs so that we can swap | 505 // Tell the renderer to suppress any further modal dialogs so that we can swap |
505 // it out. This must be done before canceling any current dialog, in case | 506 // it out. This must be done before canceling any current dialog, in case |
506 // there is a loop creating additional dialogs. | 507 // there is a loop creating additional dialogs. |
507 // TODO(creis): Handle modal dialogs in subframe processes. | 508 // TODO(creis): Handle modal dialogs in subframe processes. |
508 old_render_frame_host->render_view_host()->SuppressDialogsUntilSwapOut(); | 509 old_render_frame_host->render_view_host()->SuppressDialogsUntilSwapOut(); |
509 | 510 |
510 // Now close any modal dialogs that would prevent us from swapping out. This | 511 // Now close any modal dialogs that would prevent us from swapping out. This |
(...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1214 | 1215 |
1215 RenderFrameProxyHostMap::iterator iter = | 1216 RenderFrameProxyHostMap::iterator iter = |
1216 proxy_hosts_.find(site_instance->GetId()); | 1217 proxy_hosts_.find(site_instance->GetId()); |
1217 if (iter != proxy_hosts_.end()) | 1218 if (iter != proxy_hosts_.end()) |
1218 return iter->second->GetRoutingID(); | 1219 return iter->second->GetRoutingID(); |
1219 | 1220 |
1220 return MSG_ROUTING_NONE; | 1221 return MSG_ROUTING_NONE; |
1221 } | 1222 } |
1222 | 1223 |
1223 void RenderFrameHostManager::CommitPending() { | 1224 void RenderFrameHostManager::CommitPending() { |
1225 TRACE_EVENT1("navigation", "RenderFrameHostManager::CommitPending", | |
1226 "FrameTreeNode id", frame_tree_node_->frame_tree_node_id()); | |
1224 // First check whether we're going to want to focus the location bar after | 1227 // First check whether we're going to want to focus the location bar after |
1225 // this commit. We do this now because the navigation hasn't formally | 1228 // this commit. We do this now because the navigation hasn't formally |
1226 // committed yet, so if we've already cleared |pending_web_ui_| the call chain | 1229 // committed yet, so if we've already cleared |pending_web_ui_| the call chain |
1227 // this triggers won't be able to figure out what's going on. | 1230 // this triggers won't be able to figure out what's going on. |
1228 bool will_focus_location_bar = delegate_->FocusLocationBarByDefault(); | 1231 bool will_focus_location_bar = delegate_->FocusLocationBarByDefault(); |
1229 | 1232 |
1230 // Next commit the Web UI, if any. Either replace |web_ui_| with | 1233 // Next commit the Web UI, if any. Either replace |web_ui_| with |
1231 // |pending_web_ui_|, or clear |web_ui_| if there is no pending WebUI, or | 1234 // |pending_web_ui_|, or clear |web_ui_| if there is no pending WebUI, or |
1232 // leave |web_ui_| as is if reusing it. | 1235 // leave |web_ui_| as is if reusing it. |
1233 DCHECK(!(pending_web_ui_.get() && pending_and_current_web_ui_.get())); | 1236 DCHECK(!(pending_web_ui_.get() && pending_and_current_web_ui_.get())); |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1412 FrameTree* tree = rvh->GetDelegate()->GetFrameTree(); | 1415 FrameTree* tree = rvh->GetDelegate()->GetFrameTree(); |
1413 tree->ForEach(base::Bind( | 1416 tree->ForEach(base::Bind( |
1414 &RenderFrameHostManager::ClearProxiesInSiteInstance, | 1417 &RenderFrameHostManager::ClearProxiesInSiteInstance, |
1415 site_instance_id)); | 1418 site_instance_id)); |
1416 } | 1419 } |
1417 } | 1420 } |
1418 } | 1421 } |
1419 | 1422 |
1420 RenderFrameHostImpl* RenderFrameHostManager::UpdateStateForNavigate( | 1423 RenderFrameHostImpl* RenderFrameHostManager::UpdateStateForNavigate( |
1421 const NavigationEntryImpl& entry) { | 1424 const NavigationEntryImpl& entry) { |
1425 TRACE_EVENT1("navigation", | |
1426 "RenderFrameHostManager::UpdateStateForNavigate", | |
1427 "FrameTreeNode id", frame_tree_node_->frame_tree_node_id()); | |
1422 // If we are currently navigating cross-process, we want to get back to normal | 1428 // If we are currently navigating cross-process, we want to get back to normal |
1423 // and then navigate as usual. | 1429 // and then navigate as usual. |
1424 if (cross_navigation_pending_) { | 1430 if (cross_navigation_pending_) { |
1425 if (pending_render_frame_host_) | 1431 if (pending_render_frame_host_) |
1426 CancelPending(); | 1432 CancelPending(); |
1427 cross_navigation_pending_ = false; | 1433 cross_navigation_pending_ = false; |
1428 } | 1434 } |
1429 | 1435 |
1430 SiteInstance* current_instance = render_frame_host_->GetSiteInstance(); | 1436 SiteInstance* current_instance = render_frame_host_->GetSiteInstance(); |
1431 scoped_refptr<SiteInstance> new_instance = | 1437 scoped_refptr<SiteInstance> new_instance = |
1432 GetSiteInstanceForNavigation( | 1438 GetSiteInstanceForNavigation( |
1433 entry.GetURL(), | 1439 entry.GetURL(), |
1434 entry.site_instance(), | 1440 entry.site_instance(), |
1435 entry.GetTransitionType(), | 1441 entry.GetTransitionType(), |
1436 entry.restore_type() != NavigationEntryImpl::RESTORE_NONE, | 1442 entry.restore_type() != NavigationEntryImpl::RESTORE_NONE, |
1437 entry.IsViewSourceMode()); | 1443 entry.IsViewSourceMode()); |
1438 | 1444 |
1439 const NavigationEntry* current_entry = | 1445 const NavigationEntry* current_entry = |
1440 delegate_->GetLastCommittedNavigationEntryForRenderManager(); | 1446 delegate_->GetLastCommittedNavigationEntryForRenderManager(); |
1441 | 1447 |
1442 if (new_instance.get() != current_instance) { | 1448 if (new_instance.get() != current_instance) { |
1449 TRACE_EVENT_INSTANT2( | |
1450 "navigation", | |
1451 "RenderFrameHostManager::UpdateStateForNavigate:New SiteInstance", | |
Charlie Reis
2014/08/27 22:05:13
Is this just so that we mark the cases that we hav
nasko
2014/08/27 23:30:01
Yes. Also to log the new SiteInstance ID, in case
| |
1452 TRACE_EVENT_SCOPE_THREAD, | |
1453 "current_instance id", current_instance->GetId(), | |
1454 "new_instance id", new_instance->GetId()); | |
1455 | |
1443 // New SiteInstance: create a pending RFH to navigate. | 1456 // New SiteInstance: create a pending RFH to navigate. |
1444 DCHECK(!cross_navigation_pending_); | 1457 DCHECK(!cross_navigation_pending_); |
1445 | 1458 |
1446 // This will possibly create (set to NULL) a Web UI object for the pending | 1459 // This will possibly create (set to NULL) a Web UI object for the pending |
1447 // page. We'll use this later to give the page special access. This must | 1460 // page. We'll use this later to give the page special access. This must |
1448 // happen before the new renderer is created below so it will get bindings. | 1461 // happen before the new renderer is created below so it will get bindings. |
1449 // It must also happen after the above conditional call to CancelPending(), | 1462 // It must also happen after the above conditional call to CancelPending(), |
1450 // otherwise CancelPending may clear the pending_web_ui_ and the page will | 1463 // otherwise CancelPending may clear the pending_web_ui_ and the page will |
1451 // not have its bindings set appropriately. | 1464 // not have its bindings set appropriately. |
1452 SetPendingWebUI(entry); | 1465 SetPendingWebUI(entry); |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1546 if (entry.IsViewSourceMode()) { | 1559 if (entry.IsViewSourceMode()) { |
1547 render_frame_host_->render_view_host()->Send( | 1560 render_frame_host_->render_view_host()->Send( |
1548 new ViewMsg_EnableViewSourceMode( | 1561 new ViewMsg_EnableViewSourceMode( |
1549 render_frame_host_->render_view_host()->GetRoutingID())); | 1562 render_frame_host_->render_view_host()->GetRoutingID())); |
1550 } | 1563 } |
1551 | 1564 |
1552 return render_frame_host_.get(); | 1565 return render_frame_host_.get(); |
1553 } | 1566 } |
1554 | 1567 |
1555 void RenderFrameHostManager::CancelPending() { | 1568 void RenderFrameHostManager::CancelPending() { |
1569 TRACE_EVENT1("navigation", "RenderFrameHostManager::CancelPending", | |
1570 "FrameTreeNode id", frame_tree_node_->frame_tree_node_id()); | |
1556 scoped_ptr<RenderFrameHostImpl> pending_render_frame_host = | 1571 scoped_ptr<RenderFrameHostImpl> pending_render_frame_host = |
1557 pending_render_frame_host_.Pass(); | 1572 pending_render_frame_host_.Pass(); |
1558 | 1573 |
1559 RenderViewDevToolsAgentHost::OnCancelPendingNavigation( | 1574 RenderViewDevToolsAgentHost::OnCancelPendingNavigation( |
1560 pending_render_frame_host->render_view_host(), | 1575 pending_render_frame_host->render_view_host(), |
1561 render_frame_host_->render_view_host()); | 1576 render_frame_host_->render_view_host()); |
1562 | 1577 |
1563 // We no longer need to prevent the process from exiting. | 1578 // We no longer need to prevent the process from exiting. |
1564 pending_render_frame_host->GetProcess()->RemovePendingView(); | 1579 pending_render_frame_host->GetProcess()->RemovePendingView(); |
1565 | 1580 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1658 void RenderFrameHostManager::DeleteRenderFrameProxyHost( | 1673 void RenderFrameHostManager::DeleteRenderFrameProxyHost( |
1659 SiteInstance* instance) { | 1674 SiteInstance* instance) { |
1660 RenderFrameProxyHostMap::iterator iter = proxy_hosts_.find(instance->GetId()); | 1675 RenderFrameProxyHostMap::iterator iter = proxy_hosts_.find(instance->GetId()); |
1661 if (iter != proxy_hosts_.end()) { | 1676 if (iter != proxy_hosts_.end()) { |
1662 delete iter->second; | 1677 delete iter->second; |
1663 proxy_hosts_.erase(iter); | 1678 proxy_hosts_.erase(iter); |
1664 } | 1679 } |
1665 } | 1680 } |
1666 | 1681 |
1667 } // namespace content | 1682 } // namespace content |
OLD | NEW |