| 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( |
| 304 // category and name |
| 305 "navigation", "Navigation timeToIOStartBeforeThrottles", |
| 306 // use the NavigationHandle as the async trace id |
| 307 frame_tree_node->navigation_request()->navigation_handle(), |
| 308 // timestamp |
| 309 navigation_start.ToInternalValue(), |
| 310 // add tree node id as a parameter |
| 311 "FrameTreeNode id", frame_tree_node->frame_tree_node_id()); |
| 312 TRACE_EVENT_ASYNC_BEGIN_WITH_TIMESTAMP1( |
| 313 // category and name |
| 314 "navigation", "Navigation timeToCommit", |
| 315 // use the NavigationHandle as the async trace id |
| 316 frame_tree_node->navigation_request()->navigation_handle(), |
| 317 // timestamp |
| 318 navigation_start.ToInternalValue(), |
| 319 // add tree node id as a parameter |
| 320 "FrameTreeNode id", frame_tree_node->frame_tree_node_id()); |
| 321 } |
| 301 | 322 |
| 302 // Notify observers about navigation if this is for the pending entry. | 323 // Notify observers about navigation if this is for the pending entry. |
| 303 if (delegate_ && is_pending_entry) | 324 if (delegate_ && is_pending_entry) |
| 304 delegate_->DidStartNavigationToPendingEntry(dest_url, reload_type); | 325 delegate_->DidStartNavigationToPendingEntry(dest_url, reload_type); |
| 305 | 326 |
| 306 return true; | 327 return true; |
| 307 } | 328 } |
| 308 | 329 |
| 309 RenderFrameHostImpl* dest_render_frame_host = | 330 RenderFrameHostImpl* dest_render_frame_host = |
| 310 manager->Navigate(dest_url, frame_entry, entry); | 331 frame_tree_node->render_manager()->Navigate(dest_url, frame_entry, entry); |
| 311 if (!dest_render_frame_host) | 332 if (!dest_render_frame_host) |
| 312 return false; // Unable to create the desired RenderFrameHost. | 333 return false; // Unable to create the desired RenderFrameHost. |
| 313 | 334 |
| 314 // Make sure no code called via RFHM::Navigate clears the pending entry. | 335 // Make sure no code called via RFHM::Navigate clears the pending entry. |
| 315 if (is_pending_entry) | 336 if (is_pending_entry) |
| 316 CHECK_EQ(controller_->GetPendingEntry(), &entry); | 337 CHECK_EQ(controller_->GetPendingEntry(), &entry); |
| 317 | 338 |
| 318 // For security, we should never send non-Web-UI URLs to a Web UI renderer. | 339 // For security, we should never send non-Web-UI URLs to a Web UI renderer. |
| 319 // Double check that here. | 340 // Double check that here. |
| 320 CheckWebUIRendererDoesNotDisplayNormalURL(dest_render_frame_host, dest_url); | 341 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_) | 509 if (ui::PageTransitionIsMainFrame(params.transition) && delegate_) |
| 489 delegate_->SetMainFrameMimeType(params.contents_mime_type); | 510 delegate_->SetMainFrameMimeType(params.contents_mime_type); |
| 490 | 511 |
| 491 LoadCommittedDetails details; | 512 LoadCommittedDetails details; |
| 492 bool did_navigate = controller_->RendererDidNavigate(render_frame_host, | 513 bool did_navigate = controller_->RendererDidNavigate(render_frame_host, |
| 493 params, &details); | 514 params, &details); |
| 494 | 515 |
| 495 // Keep track of each frame's URL in its FrameTreeNode. | 516 // Keep track of each frame's URL in its FrameTreeNode. |
| 496 render_frame_host->frame_tree_node()->SetCurrentURL(params.url); | 517 render_frame_host->frame_tree_node()->SetCurrentURL(params.url); |
| 497 | 518 |
| 519 if (did_navigate && render_frame_host->frame_tree_node()->IsMainFrame() && |
| 520 IsBrowserSideNavigationEnabled()) { |
| 521 TRACE_EVENT_ASYNC_END0("navigation", "Navigation timeToCommit", |
| 522 render_frame_host->navigation_handle()); |
| 523 } |
| 524 |
| 498 // Send notification about committed provisional loads. This notification is | 525 // Send notification about committed provisional loads. This notification is |
| 499 // different from the NAV_ENTRY_COMMITTED notification which doesn't include | 526 // 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. | 527 // the actual URL navigated to and isn't sent for AUTO_SUBFRAME navigations. |
| 501 if (details.type != NAVIGATION_TYPE_NAV_IGNORE && delegate_) { | 528 if (details.type != NAVIGATION_TYPE_NAV_IGNORE && delegate_) { |
| 502 DCHECK_EQ(!render_frame_host->GetParent(), | 529 DCHECK_EQ(!render_frame_host->GetParent(), |
| 503 did_navigate ? details.is_main_frame : false); | 530 did_navigate ? details.is_main_frame : false); |
| 504 ui::PageTransition transition_type = params.transition; | 531 ui::PageTransition transition_type = params.transition; |
| 505 // Whether or not a page transition was triggered by going backward or | 532 // 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 | 533 // forward in the history is only stored in the navigation controller's |
| 507 // entry list. | 534 // 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()); | 1038 entry->set_should_replace_entry(pending_entry->should_replace_entry()); |
| 1012 entry->SetRedirectChain(pending_entry->GetRedirectChain()); | 1039 entry->SetRedirectChain(pending_entry->GetRedirectChain()); |
| 1013 } | 1040 } |
| 1014 controller_->SetPendingEntry(entry.Pass()); | 1041 controller_->SetPendingEntry(entry.Pass()); |
| 1015 if (delegate_) | 1042 if (delegate_) |
| 1016 delegate_->NotifyChangedNavigationState(content::INVALIDATE_TYPE_URL); | 1043 delegate_->NotifyChangedNavigationState(content::INVALIDATE_TYPE_URL); |
| 1017 } | 1044 } |
| 1018 } | 1045 } |
| 1019 | 1046 |
| 1020 } // namespace content | 1047 } // namespace content |
| OLD | NEW |