Chromium Code Reviews| 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/navigator_impl.h" | 5 #include "content/browser/frame_host/navigator_impl.h" |
| 6 | 6 |
| 7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
| 8 #include "base/time/time.h" | 8 #include "base/time/time.h" |
| 9 #include "content/browser/frame_host/frame_tree.h" | 9 #include "content/browser/frame_host/frame_tree.h" |
| 10 #include "content/browser/frame_host/frame_tree_node.h" | 10 #include "content/browser/frame_host/frame_tree_node.h" |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 281 LOG(WARNING) << "Refusing to load URL as it exceeds " << kMaxURLChars | 281 LOG(WARNING) << "Refusing to load URL as it exceeds " << kMaxURLChars |
| 282 << " characters."; | 282 << " characters."; |
| 283 return false; | 283 return false; |
| 284 } | 284 } |
| 285 | 285 |
| 286 // This will be used to set the Navigation Timing API navigationStart | 286 // This will be used to set the Navigation Timing API navigationStart |
| 287 // parameter for browser navigations in new tabs (intents, tabs opened through | 287 // parameter for browser navigations in new tabs (intents, tabs opened through |
| 288 // "Open link in new tab"). We need to keep it above RFHM::Navigate() call to | 288 // "Open link in new tab"). We need to keep it above RFHM::Navigate() call to |
| 289 // capture the time needed for the RenderFrameHost initialization. | 289 // capture the time needed for the RenderFrameHost initialization. |
| 290 base::TimeTicks navigation_start = base::TimeTicks::Now(); | 290 base::TimeTicks navigation_start = base::TimeTicks::Now(); |
| 291 | 291 TRACE_EVENT_INSTANT_WITH_TIMESTAMP0( |
| 292 RenderFrameHostManager* manager = frame_tree_node->render_manager(); | 292 "navigation", "NavigationTiming navigationStart", |
| 293 TRACE_EVENT_SCOPE_GLOBAL, navigation_start.ToInternalValue()); | |
| 293 | 294 |
| 294 // PlzNavigate: the RenderFrameHosts are no longer asked to navigate. | 295 // PlzNavigate: the RenderFrameHosts are no longer asked to navigate. |
| 295 if (IsBrowserSideNavigationEnabled()) { | 296 if (IsBrowserSideNavigationEnabled()) { |
| 296 navigation_data_.reset(new NavigationMetricsData(navigation_start, dest_url, | 297 navigation_data_.reset(new NavigationMetricsData(navigation_start, dest_url, |
| 297 entry.restore_type())); | 298 entry.restore_type())); |
| 298 RequestNavigation(frame_tree_node, dest_url, dest_referrer, frame_entry, | 299 RequestNavigation(frame_tree_node, dest_url, dest_referrer, frame_entry, |
| 299 entry, reload_type, is_same_document_history_load, | 300 entry, reload_type, is_same_document_history_load, |
| 300 navigation_start); | 301 navigation_start); |
| 302 if (frame_tree_node->IsMainFrame()) { | |
| 303 TRACE_EVENT_ASYNC_BEGIN_WITH_TIMESTAMP1( | |
|
clamy
2015/12/18 15:42:11
Maybe add a comment about what the handle and the
carlosk
2015/12/18 17:23:21
Done.
clamy
2015/12/21 10:43:32
I'd rather have the comment all packed together th
carlosk
2015/12/21 11:19:25
Done.
| |
| 304 "navigation", "Navigation timeToIOStart", | |
| 305 frame_tree_node->navigation_request()->navigation_handle(), | |
| 306 navigation_start.ToInternalValue(), "FrameTreeNode id", | |
| 307 frame_tree_node->frame_tree_node_id()); | |
| 308 TRACE_EVENT_ASYNC_BEGIN_WITH_TIMESTAMP1( | |
| 309 "navigation", "Navigation timeToCommit", | |
| 310 frame_tree_node->navigation_request()->navigation_handle(), | |
| 311 navigation_start.ToInternalValue(), "FrameTreeNode id", | |
| 312 frame_tree_node->frame_tree_node_id()); | |
| 313 } | |
| 301 | 314 |
| 302 // Notify observers about navigation if this is for the pending entry. | 315 // Notify observers about navigation if this is for the pending entry. |
| 303 if (delegate_ && is_pending_entry) | 316 if (delegate_ && is_pending_entry) |
| 304 delegate_->DidStartNavigationToPendingEntry(dest_url, reload_type); | 317 delegate_->DidStartNavigationToPendingEntry(dest_url, reload_type); |
| 305 | 318 |
| 306 return true; | 319 return true; |
| 307 } | 320 } |
| 308 | 321 |
| 309 RenderFrameHostImpl* dest_render_frame_host = | 322 RenderFrameHostImpl* dest_render_frame_host = |
| 310 manager->Navigate(dest_url, frame_entry, entry); | 323 frame_tree_node->render_manager()->Navigate(dest_url, frame_entry, entry); |
| 311 if (!dest_render_frame_host) | 324 if (!dest_render_frame_host) |
| 312 return false; // Unable to create the desired RenderFrameHost. | 325 return false; // Unable to create the desired RenderFrameHost. |
| 313 | 326 |
| 314 // Make sure no code called via RFHM::Navigate clears the pending entry. | 327 // Make sure no code called via RFHM::Navigate clears the pending entry. |
| 315 if (is_pending_entry) | 328 if (is_pending_entry) |
| 316 CHECK_EQ(controller_->GetPendingEntry(), &entry); | 329 CHECK_EQ(controller_->GetPendingEntry(), &entry); |
| 317 | 330 |
| 318 // For security, we should never send non-Web-UI URLs to a Web UI renderer. | 331 // For security, we should never send non-Web-UI URLs to a Web UI renderer. |
| 319 // Double check that here. | 332 // Double check that here. |
| 320 CheckWebUIRendererDoesNotDisplayNormalURL(dest_render_frame_host, dest_url); | 333 CheckWebUIRendererDoesNotDisplayNormalURL(dest_render_frame_host, dest_url); |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 488 if (ui::PageTransitionIsMainFrame(params.transition) && delegate_) | 501 if (ui::PageTransitionIsMainFrame(params.transition) && delegate_) |
| 489 delegate_->SetMainFrameMimeType(params.contents_mime_type); | 502 delegate_->SetMainFrameMimeType(params.contents_mime_type); |
| 490 | 503 |
| 491 LoadCommittedDetails details; | 504 LoadCommittedDetails details; |
| 492 bool did_navigate = controller_->RendererDidNavigate(render_frame_host, | 505 bool did_navigate = controller_->RendererDidNavigate(render_frame_host, |
| 493 params, &details); | 506 params, &details); |
| 494 | 507 |
| 495 // Keep track of each frame's URL in its FrameTreeNode. | 508 // Keep track of each frame's URL in its FrameTreeNode. |
| 496 render_frame_host->frame_tree_node()->SetCurrentURL(params.url); | 509 render_frame_host->frame_tree_node()->SetCurrentURL(params.url); |
| 497 | 510 |
| 511 if (did_navigate && render_frame_host->frame_tree_node()->IsMainFrame() && | |
| 512 IsBrowserSideNavigationEnabled()) { | |
| 513 TRACE_EVENT_ASYNC_END0("navigation", "Navigation timeToCommit", | |
| 514 render_frame_host->navigation_handle()); | |
| 515 } | |
| 516 | |
| 498 // Send notification about committed provisional loads. This notification is | 517 // Send notification about committed provisional loads. This notification is |
| 499 // different from the NAV_ENTRY_COMMITTED notification which doesn't include | 518 // different from the NAV_ENTRY_COMMITTED notification which doesn't include |
| 500 // the actual URL navigated to and isn't sent for AUTO_SUBFRAME navigations. | 519 // the actual URL navigated to and isn't sent for AUTO_SUBFRAME navigations. |
| 501 if (details.type != NAVIGATION_TYPE_NAV_IGNORE && delegate_) { | 520 if (details.type != NAVIGATION_TYPE_NAV_IGNORE && delegate_) { |
| 502 DCHECK_EQ(!render_frame_host->GetParent(), | 521 DCHECK_EQ(!render_frame_host->GetParent(), |
| 503 did_navigate ? details.is_main_frame : false); | 522 did_navigate ? details.is_main_frame : false); |
| 504 ui::PageTransition transition_type = params.transition; | 523 ui::PageTransition transition_type = params.transition; |
| 505 // Whether or not a page transition was triggered by going backward or | 524 // Whether or not a page transition was triggered by going backward or |
| 506 // forward in the history is only stored in the navigation controller's | 525 // forward in the history is only stored in the navigation controller's |
| 507 // entry list. | 526 // entry list. |
| (...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1011 entry->set_should_replace_entry(pending_entry->should_replace_entry()); | 1030 entry->set_should_replace_entry(pending_entry->should_replace_entry()); |
| 1012 entry->SetRedirectChain(pending_entry->GetRedirectChain()); | 1031 entry->SetRedirectChain(pending_entry->GetRedirectChain()); |
| 1013 } | 1032 } |
| 1014 controller_->SetPendingEntry(entry.Pass()); | 1033 controller_->SetPendingEntry(entry.Pass()); |
| 1015 if (delegate_) | 1034 if (delegate_) |
| 1016 delegate_->NotifyChangedNavigationState(content::INVALIDATE_TYPE_URL); | 1035 delegate_->NotifyChangedNavigationState(content::INVALIDATE_TYPE_URL); |
| 1017 } | 1036 } |
| 1018 } | 1037 } |
| 1019 | 1038 |
| 1020 } // namespace content | 1039 } // namespace content |
| OLD | NEW |