| 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 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 LOG(WARNING) << "Refusing to load URL as it exceeds " << kMaxURLChars | 274 LOG(WARNING) << "Refusing to load URL as it exceeds " << kMaxURLChars |
| 275 << " characters."; | 275 << " characters."; |
| 276 return false; | 276 return false; |
| 277 } | 277 } |
| 278 | 278 |
| 279 // This will be used to set the Navigation Timing API navigationStart | 279 // This will be used to set the Navigation Timing API navigationStart |
| 280 // parameter for browser navigations in new tabs (intents, tabs opened through | 280 // parameter for browser navigations in new tabs (intents, tabs opened through |
| 281 // "Open link in new tab"). We need to keep it above RFHM::Navigate() call to | 281 // "Open link in new tab"). We need to keep it above RFHM::Navigate() call to |
| 282 // capture the time needed for the RenderFrameHost initialization. | 282 // capture the time needed for the RenderFrameHost initialization. |
| 283 base::TimeTicks navigation_start = base::TimeTicks::Now(); | 283 base::TimeTicks navigation_start = base::TimeTicks::Now(); |
| 284 | 284 TRACE_EVENT_INSTANT_WITH_TIMESTAMP0( |
| 285 RenderFrameHostManager* manager = frame_tree_node->render_manager(); | 285 "navigation", "NavigationTiming navigationStart", |
| 286 TRACE_EVENT_SCOPE_GLOBAL, navigation_start.ToInternalValue()); |
| 286 | 287 |
| 287 // PlzNavigate: the RenderFrameHosts are no longer asked to navigate. | 288 // PlzNavigate: the RenderFrameHosts are no longer asked to navigate. |
| 288 if (IsBrowserSideNavigationEnabled()) { | 289 if (IsBrowserSideNavigationEnabled()) { |
| 289 navigation_data_.reset(new NavigationMetricsData(navigation_start, dest_url, | 290 navigation_data_.reset(new NavigationMetricsData(navigation_start, dest_url, |
| 290 entry.restore_type())); | 291 entry.restore_type())); |
| 291 RequestNavigation(frame_tree_node, dest_url, dest_referrer, frame_entry, | 292 RequestNavigation(frame_tree_node, dest_url, dest_referrer, frame_entry, |
| 292 entry, reload_type, is_same_document_history_load, | 293 entry, reload_type, is_same_document_history_load, |
| 293 navigation_start); | 294 navigation_start); |
| 295 if (frame_tree_node->IsMainFrame() && |
| 296 frame_tree_node->navigation_request()) { |
| 297 // TODO(carlosk): extend these traces to support subframes and |
| 298 // non-PlzNavigate navigations. |
| 299 // For these traces below we're using the navigation handle as the async |
| 300 // trace id, |navigation_start| as the timestamp and reporting the |
| 301 // FrameTreeNode id as a parameter. For navigations where no network |
| 302 // request is made (data URLs, JavaScript URLs, etc) there is no handle |
| 303 // and so no tracing is done. |
| 304 TRACE_EVENT_ASYNC_BEGIN_WITH_TIMESTAMP1( |
| 305 "navigation", "Navigation timeToNetworkStack", |
| 306 frame_tree_node->navigation_request()->navigation_handle(), |
| 307 navigation_start.ToInternalValue(), |
| 308 "FrameTreeNode id", frame_tree_node->frame_tree_node_id()); |
| 309 TRACE_EVENT_ASYNC_BEGIN_WITH_TIMESTAMP1( |
| 310 "navigation", "Navigation timeToCommit", |
| 311 frame_tree_node->navigation_request()->navigation_handle(), |
| 312 navigation_start.ToInternalValue(), |
| 313 "FrameTreeNode id", frame_tree_node->frame_tree_node_id()); |
| 314 } |
| 294 | 315 |
| 295 // Notify observers about navigation if this is for the pending entry. | 316 // Notify observers about navigation if this is for the pending entry. |
| 296 if (delegate_ && is_pending_entry) | 317 if (delegate_ && is_pending_entry) |
| 297 delegate_->DidStartNavigationToPendingEntry(dest_url, reload_type); | 318 delegate_->DidStartNavigationToPendingEntry(dest_url, reload_type); |
| 298 | 319 |
| 299 return true; | 320 return true; |
| 300 } | 321 } |
| 301 | 322 |
| 302 RenderFrameHostImpl* dest_render_frame_host = | 323 RenderFrameHostImpl* dest_render_frame_host = |
| 303 manager->Navigate(dest_url, frame_entry, entry); | 324 frame_tree_node->render_manager()->Navigate(dest_url, frame_entry, entry); |
| 304 if (!dest_render_frame_host) | 325 if (!dest_render_frame_host) |
| 305 return false; // Unable to create the desired RenderFrameHost. | 326 return false; // Unable to create the desired RenderFrameHost. |
| 306 | 327 |
| 307 // Make sure no code called via RFHM::Navigate clears the pending entry. | 328 // Make sure no code called via RFHM::Navigate clears the pending entry. |
| 308 if (is_pending_entry) | 329 if (is_pending_entry) |
| 309 CHECK_EQ(controller_->GetPendingEntry(), &entry); | 330 CHECK_EQ(controller_->GetPendingEntry(), &entry); |
| 310 | 331 |
| 311 // For security, we should never send non-Web-UI URLs to a Web UI renderer. | 332 // For security, we should never send non-Web-UI URLs to a Web UI renderer. |
| 312 // Double check that here. | 333 // Double check that here. |
| 313 CheckWebUIRendererDoesNotDisplayNormalURL(dest_render_frame_host, dest_url); | 334 CheckWebUIRendererDoesNotDisplayNormalURL(dest_render_frame_host, dest_url); |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 if (ui::PageTransitionIsMainFrame(params.transition) && delegate_) | 505 if (ui::PageTransitionIsMainFrame(params.transition) && delegate_) |
| 485 delegate_->SetMainFrameMimeType(params.contents_mime_type); | 506 delegate_->SetMainFrameMimeType(params.contents_mime_type); |
| 486 | 507 |
| 487 LoadCommittedDetails details; | 508 LoadCommittedDetails details; |
| 488 bool did_navigate = controller_->RendererDidNavigate(render_frame_host, | 509 bool did_navigate = controller_->RendererDidNavigate(render_frame_host, |
| 489 params, &details); | 510 params, &details); |
| 490 | 511 |
| 491 // Keep track of each frame's URL in its FrameTreeNode. | 512 // Keep track of each frame's URL in its FrameTreeNode. |
| 492 render_frame_host->frame_tree_node()->SetCurrentURL(params.url); | 513 render_frame_host->frame_tree_node()->SetCurrentURL(params.url); |
| 493 | 514 |
| 515 if (did_navigate && render_frame_host->frame_tree_node()->IsMainFrame() && |
| 516 IsBrowserSideNavigationEnabled()) { |
| 517 TRACE_EVENT_ASYNC_END0("navigation", "Navigation timeToCommit", |
| 518 render_frame_host->navigation_handle()); |
| 519 } |
| 520 |
| 494 // Send notification about committed provisional loads. This notification is | 521 // Send notification about committed provisional loads. This notification is |
| 495 // different from the NAV_ENTRY_COMMITTED notification which doesn't include | 522 // different from the NAV_ENTRY_COMMITTED notification which doesn't include |
| 496 // the actual URL navigated to and isn't sent for AUTO_SUBFRAME navigations. | 523 // the actual URL navigated to and isn't sent for AUTO_SUBFRAME navigations. |
| 497 if (details.type != NAVIGATION_TYPE_NAV_IGNORE && delegate_) { | 524 if (details.type != NAVIGATION_TYPE_NAV_IGNORE && delegate_) { |
| 498 DCHECK_EQ(!render_frame_host->GetParent(), | 525 DCHECK_EQ(!render_frame_host->GetParent(), |
| 499 did_navigate ? details.is_main_frame : false); | 526 did_navigate ? details.is_main_frame : false); |
| 500 ui::PageTransition transition_type = params.transition; | 527 ui::PageTransition transition_type = params.transition; |
| 501 // Whether or not a page transition was triggered by going backward or | 528 // Whether or not a page transition was triggered by going backward or |
| 502 // forward in the history is only stored in the navigation controller's | 529 // forward in the history is only stored in the navigation controller's |
| 503 // entry list. | 530 // entry list. |
| (...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1013 entry->set_should_replace_entry(pending_entry->should_replace_entry()); | 1040 entry->set_should_replace_entry(pending_entry->should_replace_entry()); |
| 1014 entry->SetRedirectChain(pending_entry->GetRedirectChain()); | 1041 entry->SetRedirectChain(pending_entry->GetRedirectChain()); |
| 1015 } | 1042 } |
| 1016 controller_->SetPendingEntry(entry.Pass()); | 1043 controller_->SetPendingEntry(entry.Pass()); |
| 1017 if (delegate_) | 1044 if (delegate_) |
| 1018 delegate_->NotifyChangedNavigationState(content::INVALIDATE_TYPE_URL); | 1045 delegate_->NotifyChangedNavigationState(content::INVALIDATE_TYPE_URL); |
| 1019 } | 1046 } |
| 1020 } | 1047 } |
| 1021 | 1048 |
| 1022 } // namespace content | 1049 } // namespace content |
| OLD | NEW |