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/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/metrics/histogram.h" |
8 #include "base/time/time.h" | 9 #include "base/time/time.h" |
9 #include "content/browser/frame_host/frame_tree.h" | 10 #include "content/browser/frame_host/frame_tree.h" |
10 #include "content/browser/frame_host/frame_tree_node.h" | 11 #include "content/browser/frame_host/frame_tree_node.h" |
11 #include "content/browser/frame_host/navigation_before_commit_info.h" | 12 #include "content/browser/frame_host/navigation_before_commit_info.h" |
12 #include "content/browser/frame_host/navigation_controller_impl.h" | 13 #include "content/browser/frame_host/navigation_controller_impl.h" |
13 #include "content/browser/frame_host/navigation_entry_impl.h" | 14 #include "content/browser/frame_host/navigation_entry_impl.h" |
14 #include "content/browser/frame_host/navigator_delegate.h" | 15 #include "content/browser/frame_host/navigator_delegate.h" |
15 #include "content/browser/frame_host/render_frame_host_impl.h" | 16 #include "content/browser/frame_host/render_frame_host_impl.h" |
16 #include "content/browser/renderer_host/render_view_host_impl.h" | 17 #include "content/browser/renderer_host/render_view_host_impl.h" |
17 #include "content/browser/site_instance_impl.h" | 18 #include "content/browser/site_instance_impl.h" |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 | 345 |
345 FrameMsg_Navigate_Params navigate_params; | 346 FrameMsg_Navigate_Params navigate_params; |
346 RenderFrameHostManager* manager = | 347 RenderFrameHostManager* manager = |
347 render_frame_host->frame_tree_node()->render_manager(); | 348 render_frame_host->frame_tree_node()->render_manager(); |
348 | 349 |
349 // PlzNavigate: the RenderFrameHosts are no longer asked to navigate. Instead | 350 // PlzNavigate: the RenderFrameHosts are no longer asked to navigate. Instead |
350 // the RenderFrameHostManager handles the navigation requests for that frame | 351 // the RenderFrameHostManager handles the navigation requests for that frame |
351 // node. | 352 // node. |
352 if (CommandLine::ForCurrentProcess()->HasSwitch( | 353 if (CommandLine::ForCurrentProcess()->HasSwitch( |
353 switches::kEnableBrowserSideNavigation)) { | 354 switches::kEnableBrowserSideNavigation)) { |
| 355 navigation_start_time_ = navigation_start; |
| 356 navigation_start_url_ = entry.GetURL(); |
354 // Create the navigation parameters. | 357 // Create the navigation parameters. |
355 MakeNavigateParams( | 358 MakeNavigateParams( |
356 entry, *controller_, reload_type, navigation_start, &navigate_params); | 359 entry, *controller_, reload_type, navigation_start, &navigate_params); |
357 return manager->RequestNavigation(entry, navigate_params); | 360 return manager->RequestNavigation(entry, navigate_params); |
358 } | 361 } |
359 | 362 |
360 RenderFrameHostImpl* dest_render_frame_host = manager->Navigate(entry); | 363 RenderFrameHostImpl* dest_render_frame_host = manager->Navigate(entry); |
361 if (!dest_render_frame_host) | 364 if (!dest_render_frame_host) |
362 return false; // Unable to create the desired RenderFrameHost. | 365 return false; // Unable to create the desired RenderFrameHost. |
363 | 366 |
(...skipping 17 matching lines...) Expand all Loading... |
381 | 384 |
382 // Navigate in the desired RenderFrameHost. | 385 // Navigate in the desired RenderFrameHost. |
383 // We can skip this step in the rare case that this is a transfer navigation | 386 // We can skip this step in the rare case that this is a transfer navigation |
384 // which began in the chosen RenderFrameHost, since the request has already | 387 // which began in the chosen RenderFrameHost, since the request has already |
385 // been issued. In that case, simply resume the response. | 388 // been issued. In that case, simply resume the response. |
386 bool is_transfer_to_same = | 389 bool is_transfer_to_same = |
387 navigate_params.transferred_request_child_id != -1 && | 390 navigate_params.transferred_request_child_id != -1 && |
388 navigate_params.transferred_request_child_id == | 391 navigate_params.transferred_request_child_id == |
389 dest_render_frame_host->GetProcess()->GetID(); | 392 dest_render_frame_host->GetProcess()->GetID(); |
390 if (!is_transfer_to_same) { | 393 if (!is_transfer_to_same) { |
| 394 navigation_start_time_ = navigation_start; |
| 395 navigation_start_url_ = entry.GetURL(); |
391 dest_render_frame_host->Navigate(navigate_params); | 396 dest_render_frame_host->Navigate(navigate_params); |
392 } else { | 397 } else { |
393 // No need to navigate again. Just resume the deferred request. | 398 // No need to navigate again. Just resume the deferred request. |
394 dest_render_frame_host->GetProcess()->ResumeDeferredNavigation( | 399 dest_render_frame_host->GetProcess()->ResumeDeferredNavigation( |
395 GlobalRequestID(navigate_params.transferred_request_child_id, | 400 GlobalRequestID(navigate_params.transferred_request_child_id, |
396 navigate_params.transferred_request_request_id)); | 401 navigate_params.transferred_request_request_id)); |
397 } | 402 } |
398 | 403 |
399 // Make sure no code called via RFH::Navigate clears the pending entry. | 404 // Make sure no code called via RFH::Navigate clears the pending entry. |
400 CHECK_EQ(controller_->GetPendingEntry(), &entry); | 405 CHECK_EQ(controller_->GetPendingEntry(), &entry); |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 } | 547 } |
543 | 548 |
544 if (!did_navigate) | 549 if (!did_navigate) |
545 return; // No navigation happened. | 550 return; // No navigation happened. |
546 | 551 |
547 // DO NOT ADD MORE STUFF TO THIS FUNCTION! Your component should either listen | 552 // DO NOT ADD MORE STUFF TO THIS FUNCTION! Your component should either listen |
548 // for the appropriate notification (best) or you can add it to | 553 // for the appropriate notification (best) or you can add it to |
549 // DidNavigateMainFramePostCommit / DidNavigateAnyFramePostCommit (only if | 554 // DidNavigateMainFramePostCommit / DidNavigateAnyFramePostCommit (only if |
550 // necessary, please). | 555 // necessary, please). |
551 | 556 |
| 557 // TODO(carlosk): Move this out when PlzNavigate implementation properly calls |
| 558 // the observer methods. |
| 559 if (details.is_main_frame && |
| 560 navigation_start_time_.ToInternalValue() != 0 |
| 561 && navigation_start_url_ == params.original_request_url) { |
| 562 base::TimeDelta time_to_commit = |
| 563 base::TimeTicks::Now() - navigation_start_time_; |
| 564 UMA_HISTOGRAM_TIMES("Navigation.TimeToCommit", time_to_commit); |
| 565 navigation_start_time_ = base::TimeTicks(); |
| 566 } |
| 567 |
552 // Run post-commit tasks. | 568 // Run post-commit tasks. |
553 if (delegate_) { | 569 if (delegate_) { |
554 if (details.is_main_frame) | 570 if (details.is_main_frame) |
555 delegate_->DidNavigateMainFramePostCommit(details, params); | 571 delegate_->DidNavigateMainFramePostCommit(details, params); |
556 | 572 |
557 delegate_->DidNavigateAnyFramePostCommit( | 573 delegate_->DidNavigateAnyFramePostCommit( |
558 render_frame_host, details, params); | 574 render_frame_host, details, params); |
559 } | 575 } |
560 } | 576 } |
561 | 577 |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
665 | 681 |
666 void NavigatorImpl::CommitNavigation( | 682 void NavigatorImpl::CommitNavigation( |
667 RenderFrameHostImpl* render_frame_host, | 683 RenderFrameHostImpl* render_frame_host, |
668 const NavigationBeforeCommitInfo& info) { | 684 const NavigationBeforeCommitInfo& info) { |
669 CheckWebUIRendererDoesNotDisplayNormalURL( | 685 CheckWebUIRendererDoesNotDisplayNormalURL( |
670 render_frame_host, info.navigation_url); | 686 render_frame_host, info.navigation_url); |
671 // TODO(clamy): the render_frame_host should now send a commit IPC to the | 687 // TODO(clamy): the render_frame_host should now send a commit IPC to the |
672 // renderer. | 688 // renderer. |
673 } | 689 } |
674 | 690 |
| 691 void NavigatorImpl::LogResourceRequestTime( |
| 692 base::TimeTicks timestamp, const GURL& url) { |
| 693 if (navigation_start_time_.ToInternalValue() != 0 |
| 694 && navigation_start_url_ == url) { |
| 695 base::TimeDelta time_to_network = timestamp - navigation_start_time_; |
| 696 UMA_HISTOGRAM_TIMES("Navigation.TimeToURLJobStart", time_to_network); |
| 697 } |
| 698 } |
| 699 |
675 void NavigatorImpl::CheckWebUIRendererDoesNotDisplayNormalURL( | 700 void NavigatorImpl::CheckWebUIRendererDoesNotDisplayNormalURL( |
676 RenderFrameHostImpl* render_frame_host, | 701 RenderFrameHostImpl* render_frame_host, |
677 const GURL& url) { | 702 const GURL& url) { |
678 int enabled_bindings = | 703 int enabled_bindings = |
679 render_frame_host->render_view_host()->GetEnabledBindings(); | 704 render_frame_host->render_view_host()->GetEnabledBindings(); |
680 bool is_allowed_in_web_ui_renderer = | 705 bool is_allowed_in_web_ui_renderer = |
681 WebUIControllerFactoryRegistry::GetInstance()->IsURLAcceptableForWebUI( | 706 WebUIControllerFactoryRegistry::GetInstance()->IsURLAcceptableForWebUI( |
682 controller_->GetBrowserContext(), url); | 707 controller_->GetBrowserContext(), url); |
683 if ((enabled_bindings & BINDINGS_POLICY_WEB_UI) && | 708 if ((enabled_bindings & BINDINGS_POLICY_WEB_UI) && |
684 !is_allowed_in_web_ui_renderer) { | 709 !is_allowed_in_web_ui_renderer) { |
685 // Log the URL to help us diagnose any future failures of this CHECK. | 710 // Log the URL to help us diagnose any future failures of this CHECK. |
686 GetContentClient()->SetActiveURL(url); | 711 GetContentClient()->SetActiveURL(url); |
687 CHECK(0); | 712 CHECK(0); |
688 } | 713 } |
689 } | 714 } |
690 | 715 |
691 } // namespace content | 716 } // namespace content |
OLD | NEW |