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"); | 191 TRACE_EVENT1("navigation", "RenderFrameHostManager:Navigate", |
| 192 "FrameTreeNode id", frame_tree_node_->frame_tree_node_id()); |
192 // Create a pending RenderFrameHost to use for the navigation. | 193 // Create a pending RenderFrameHost to use for the navigation. |
193 RenderFrameHostImpl* dest_render_frame_host = UpdateStateForNavigate(entry); | 194 RenderFrameHostImpl* dest_render_frame_host = UpdateStateForNavigate(entry); |
194 if (!dest_render_frame_host) | 195 if (!dest_render_frame_host) |
195 return NULL; // We weren't able to create a pending render frame host. | 196 return NULL; // We weren't able to create a pending render frame host. |
196 | 197 |
197 // If the current render_frame_host_ isn't live, we should create it so | 198 // 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 | 199 // that we don't show a sad tab while the dest_render_frame_host fetches |
199 // its first page. (Bug 1145340) | 200 // its first page. (Bug 1145340) |
200 if (dest_render_frame_host != render_frame_host_ && | 201 if (dest_render_frame_host != render_frame_host_ && |
201 !render_frame_host_->render_view_host()->IsRenderViewLive()) { | 202 !render_frame_host_->render_view_host()->IsRenderViewLive()) { |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
491 // Now delete them. | 492 // Now delete them. |
492 while (!ids_to_remove.empty()) { | 493 while (!ids_to_remove.empty()) { |
493 delete proxy_hosts_[ids_to_remove.back()]; | 494 delete proxy_hosts_[ids_to_remove.back()]; |
494 proxy_hosts_.erase(ids_to_remove.back()); | 495 proxy_hosts_.erase(ids_to_remove.back()); |
495 ids_to_remove.pop_back(); | 496 ids_to_remove.pop_back(); |
496 } | 497 } |
497 } | 498 } |
498 | 499 |
499 void RenderFrameHostManager::SwapOutOldPage( | 500 void RenderFrameHostManager::SwapOutOldPage( |
500 RenderFrameHostImpl* old_render_frame_host) { | 501 RenderFrameHostImpl* old_render_frame_host) { |
| 502 TRACE_EVENT1("navigation", "RenderFrameHostManager::SwapOutOldPage", |
| 503 "FrameTreeNode id", frame_tree_node_->frame_tree_node_id()); |
501 // Should only see this while we have a pending renderer. | 504 // Should only see this while we have a pending renderer. |
502 CHECK(cross_navigation_pending_); | 505 CHECK(cross_navigation_pending_); |
503 | 506 |
504 // Tell the renderer to suppress any further modal dialogs so that we can swap | 507 // 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 | 508 // it out. This must be done before canceling any current dialog, in case |
506 // there is a loop creating additional dialogs. | 509 // there is a loop creating additional dialogs. |
507 // TODO(creis): Handle modal dialogs in subframe processes. | 510 // TODO(creis): Handle modal dialogs in subframe processes. |
508 old_render_frame_host->render_view_host()->SuppressDialogsUntilSwapOut(); | 511 old_render_frame_host->render_view_host()->SuppressDialogsUntilSwapOut(); |
509 | 512 |
510 // Now close any modal dialogs that would prevent us from swapping out. This | 513 // 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 | 1217 |
1215 RenderFrameProxyHostMap::iterator iter = | 1218 RenderFrameProxyHostMap::iterator iter = |
1216 proxy_hosts_.find(site_instance->GetId()); | 1219 proxy_hosts_.find(site_instance->GetId()); |
1217 if (iter != proxy_hosts_.end()) | 1220 if (iter != proxy_hosts_.end()) |
1218 return iter->second->GetRoutingID(); | 1221 return iter->second->GetRoutingID(); |
1219 | 1222 |
1220 return MSG_ROUTING_NONE; | 1223 return MSG_ROUTING_NONE; |
1221 } | 1224 } |
1222 | 1225 |
1223 void RenderFrameHostManager::CommitPending() { | 1226 void RenderFrameHostManager::CommitPending() { |
| 1227 TRACE_EVENT1("navigation", "RenderFrameHostManager::CommitPending", |
| 1228 "FrameTreeNode id", frame_tree_node_->frame_tree_node_id()); |
1224 // First check whether we're going to want to focus the location bar after | 1229 // 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 | 1230 // 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 | 1231 // 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. | 1232 // this triggers won't be able to figure out what's going on. |
1228 bool will_focus_location_bar = delegate_->FocusLocationBarByDefault(); | 1233 bool will_focus_location_bar = delegate_->FocusLocationBarByDefault(); |
1229 | 1234 |
1230 // Next commit the Web UI, if any. Either replace |web_ui_| with | 1235 // 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 | 1236 // |pending_web_ui_|, or clear |web_ui_| if there is no pending WebUI, or |
1232 // leave |web_ui_| as is if reusing it. | 1237 // leave |web_ui_| as is if reusing it. |
1233 DCHECK(!(pending_web_ui_.get() && pending_and_current_web_ui_.get())); | 1238 DCHECK(!(pending_web_ui_.get() && pending_and_current_web_ui_.get())); |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1433 entry.GetURL(), | 1438 entry.GetURL(), |
1434 entry.site_instance(), | 1439 entry.site_instance(), |
1435 entry.GetTransitionType(), | 1440 entry.GetTransitionType(), |
1436 entry.restore_type() != NavigationEntryImpl::RESTORE_NONE, | 1441 entry.restore_type() != NavigationEntryImpl::RESTORE_NONE, |
1437 entry.IsViewSourceMode()); | 1442 entry.IsViewSourceMode()); |
1438 | 1443 |
1439 const NavigationEntry* current_entry = | 1444 const NavigationEntry* current_entry = |
1440 delegate_->GetLastCommittedNavigationEntryForRenderManager(); | 1445 delegate_->GetLastCommittedNavigationEntryForRenderManager(); |
1441 | 1446 |
1442 if (new_instance.get() != current_instance) { | 1447 if (new_instance.get() != current_instance) { |
| 1448 TRACE_EVENT_INSTANT2( |
| 1449 "navigation", |
| 1450 "RenderFrameHostManager::UpdateStateForNavigate:New SiteInstance", |
| 1451 TRACE_EVENT_SCOPE_THREAD, |
| 1452 "current_instance id", current_instance->GetId(), |
| 1453 "new_instance id", new_instance->GetId()); |
| 1454 |
1443 // New SiteInstance: create a pending RFH to navigate. | 1455 // New SiteInstance: create a pending RFH to navigate. |
1444 DCHECK(!cross_navigation_pending_); | 1456 DCHECK(!cross_navigation_pending_); |
1445 | 1457 |
1446 // This will possibly create (set to NULL) a Web UI object for the pending | 1458 // 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 | 1459 // 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. | 1460 // 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(), | 1461 // It must also happen after the above conditional call to CancelPending(), |
1450 // otherwise CancelPending may clear the pending_web_ui_ and the page will | 1462 // otherwise CancelPending may clear the pending_web_ui_ and the page will |
1451 // not have its bindings set appropriately. | 1463 // not have its bindings set appropriately. |
1452 SetPendingWebUI(entry); | 1464 SetPendingWebUI(entry); |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1546 if (entry.IsViewSourceMode()) { | 1558 if (entry.IsViewSourceMode()) { |
1547 render_frame_host_->render_view_host()->Send( | 1559 render_frame_host_->render_view_host()->Send( |
1548 new ViewMsg_EnableViewSourceMode( | 1560 new ViewMsg_EnableViewSourceMode( |
1549 render_frame_host_->render_view_host()->GetRoutingID())); | 1561 render_frame_host_->render_view_host()->GetRoutingID())); |
1550 } | 1562 } |
1551 | 1563 |
1552 return render_frame_host_.get(); | 1564 return render_frame_host_.get(); |
1553 } | 1565 } |
1554 | 1566 |
1555 void RenderFrameHostManager::CancelPending() { | 1567 void RenderFrameHostManager::CancelPending() { |
| 1568 TRACE_EVENT1("navigation", "RenderFrameHostManager::CancelPending", |
| 1569 "FrameTreeNode id", frame_tree_node_->frame_tree_node_id()); |
1556 scoped_ptr<RenderFrameHostImpl> pending_render_frame_host = | 1570 scoped_ptr<RenderFrameHostImpl> pending_render_frame_host = |
1557 pending_render_frame_host_.Pass(); | 1571 pending_render_frame_host_.Pass(); |
1558 | 1572 |
1559 RenderViewDevToolsAgentHost::OnCancelPendingNavigation( | 1573 RenderViewDevToolsAgentHost::OnCancelPendingNavigation( |
1560 pending_render_frame_host->render_view_host(), | 1574 pending_render_frame_host->render_view_host(), |
1561 render_frame_host_->render_view_host()); | 1575 render_frame_host_->render_view_host()); |
1562 | 1576 |
1563 // We no longer need to prevent the process from exiting. | 1577 // We no longer need to prevent the process from exiting. |
1564 pending_render_frame_host->GetProcess()->RemovePendingView(); | 1578 pending_render_frame_host->GetProcess()->RemovePendingView(); |
1565 | 1579 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1658 void RenderFrameHostManager::DeleteRenderFrameProxyHost( | 1672 void RenderFrameHostManager::DeleteRenderFrameProxyHost( |
1659 SiteInstance* instance) { | 1673 SiteInstance* instance) { |
1660 RenderFrameProxyHostMap::iterator iter = proxy_hosts_.find(instance->GetId()); | 1674 RenderFrameProxyHostMap::iterator iter = proxy_hosts_.find(instance->GetId()); |
1661 if (iter != proxy_hosts_.end()) { | 1675 if (iter != proxy_hosts_.end()) { |
1662 delete iter->second; | 1676 delete iter->second; |
1663 proxy_hosts_.erase(iter); | 1677 proxy_hosts_.erase(iter); |
1664 } | 1678 } |
1665 } | 1679 } |
1666 | 1680 |
1667 } // namespace content | 1681 } // namespace content |
OLD | NEW |