Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(107)

Side by Side Diff: content/browser/frame_host/navigator_impl.cc

Issue 577963002: Add time-to-network histogram considering browser side navigation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing new build issues Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 } // namespace 75 } // namespace
75 76
76 77
77 NavigatorImpl::NavigatorImpl( 78 NavigatorImpl::NavigatorImpl(
78 NavigationControllerImpl* navigation_controller, 79 NavigationControllerImpl* navigation_controller,
79 NavigatorDelegate* delegate) 80 NavigatorDelegate* delegate)
80 : controller_(navigation_controller), 81 : controller_(navigation_controller),
81 delegate_(delegate) { 82 delegate_(delegate) {
82 } 83 }
83 84
85 NavigatorImpl::~NavigatorImpl() {
86 }
87
84 // static. 88 // static.
85 void NavigatorImpl::MakeNavigateParams( 89 void NavigatorImpl::MakeNavigateParams(
86 const NavigationEntryImpl& entry, 90 const NavigationEntryImpl& entry,
87 const NavigationControllerImpl& controller, 91 const NavigationControllerImpl& controller,
88 NavigationController::ReloadType reload_type, 92 NavigationController::ReloadType reload_type,
89 base::TimeTicks navigation_start, 93 base::TimeTicks navigation_start,
90 FrameMsg_Navigate_Params* params) { 94 FrameMsg_Navigate_Params* params) {
91 params->page_id = entry.GetPageID(); 95 params->page_id = entry.GetPageID();
92 params->should_clear_history_list = entry.should_clear_history_list(); 96 params->should_clear_history_list = entry.should_clear_history_list();
93 params->should_replace_current_entry = entry.should_replace_entry(); 97 params->should_replace_current_entry = entry.should_replace_entry();
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 319
316 FrameMsg_Navigate_Params navigate_params; 320 FrameMsg_Navigate_Params navigate_params;
317 RenderFrameHostManager* manager = 321 RenderFrameHostManager* manager =
318 render_frame_host->frame_tree_node()->render_manager(); 322 render_frame_host->frame_tree_node()->render_manager();
319 323
320 // PlzNavigate: the RenderFrameHosts are no longer asked to navigate. Instead 324 // PlzNavigate: the RenderFrameHosts are no longer asked to navigate. Instead
321 // the RenderFrameHostManager handles the navigation requests for that frame 325 // the RenderFrameHostManager handles the navigation requests for that frame
322 // node. 326 // node.
323 if (CommandLine::ForCurrentProcess()->HasSwitch( 327 if (CommandLine::ForCurrentProcess()->HasSwitch(
324 switches::kEnableBrowserSideNavigation)) { 328 switches::kEnableBrowserSideNavigation)) {
329 navigation_start_time_and_url = MakeTuple(navigation_start, entry.GetURL());
325 // Create the navigation parameters. 330 // Create the navigation parameters.
326 MakeNavigateParams( 331 MakeNavigateParams(
327 entry, *controller_, reload_type, navigation_start, &navigate_params); 332 entry, *controller_, reload_type, navigation_start, &navigate_params);
328 return manager->RequestNavigation(entry, navigate_params); 333 return manager->RequestNavigation(entry, navigate_params);
329 } 334 }
330 335
331 RenderFrameHostImpl* dest_render_frame_host = manager->Navigate(entry); 336 RenderFrameHostImpl* dest_render_frame_host = manager->Navigate(entry);
332 if (!dest_render_frame_host) 337 if (!dest_render_frame_host)
333 return false; // Unable to create the desired RenderFrameHost. 338 return false; // Unable to create the desired RenderFrameHost.
334 339
(...skipping 17 matching lines...) Expand all
352 357
353 // Navigate in the desired RenderFrameHost. 358 // Navigate in the desired RenderFrameHost.
354 // We can skip this step in the rare case that this is a transfer navigation 359 // We can skip this step in the rare case that this is a transfer navigation
355 // which began in the chosen RenderFrameHost, since the request has already 360 // which began in the chosen RenderFrameHost, since the request has already
356 // been issued. In that case, simply resume the response. 361 // been issued. In that case, simply resume the response.
357 bool is_transfer_to_same = 362 bool is_transfer_to_same =
358 navigate_params.transferred_request_child_id != -1 && 363 navigate_params.transferred_request_child_id != -1 &&
359 navigate_params.transferred_request_child_id == 364 navigate_params.transferred_request_child_id ==
360 dest_render_frame_host->GetProcess()->GetID(); 365 dest_render_frame_host->GetProcess()->GetID();
361 if (!is_transfer_to_same) { 366 if (!is_transfer_to_same) {
367 navigation_start_time_and_url = MakeTuple(navigation_start, entry.GetURL());
362 dest_render_frame_host->Navigate(navigate_params); 368 dest_render_frame_host->Navigate(navigate_params);
363 } else { 369 } else {
364 // No need to navigate again. Just resume the deferred request. 370 // No need to navigate again. Just resume the deferred request.
365 dest_render_frame_host->GetProcess()->ResumeDeferredNavigation( 371 dest_render_frame_host->GetProcess()->ResumeDeferredNavigation(
366 GlobalRequestID(navigate_params.transferred_request_child_id, 372 GlobalRequestID(navigate_params.transferred_request_child_id,
367 navigate_params.transferred_request_request_id)); 373 navigate_params.transferred_request_request_id));
368 } 374 }
369 375
370 // Make sure no code called via RFH::Navigate clears the pending entry. 376 // Make sure no code called via RFH::Navigate clears the pending entry.
371 CHECK_EQ(controller_->GetPendingEntry(), &entry); 377 CHECK_EQ(controller_->GetPendingEntry(), &entry);
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 } 519 }
514 520
515 if (!did_navigate) 521 if (!did_navigate)
516 return; // No navigation happened. 522 return; // No navigation happened.
517 523
518 // DO NOT ADD MORE STUFF TO THIS FUNCTION! Your component should either listen 524 // DO NOT ADD MORE STUFF TO THIS FUNCTION! Your component should either listen
519 // for the appropriate notification (best) or you can add it to 525 // for the appropriate notification (best) or you can add it to
520 // DidNavigateMainFramePostCommit / DidNavigateAnyFramePostCommit (only if 526 // DidNavigateMainFramePostCommit / DidNavigateAnyFramePostCommit (only if
521 // necessary, please). 527 // necessary, please).
522 528
529 // TODO(carlosk): Move this out when PlzNavigate implementation properly calls
530 // the observer methods.
531 if (details.is_main_frame &&
532 navigation_start_time_and_url.a.ToInternalValue() != 0
533 && navigation_start_time_and_url.b == params.original_request_url) {
534 base::TimeDelta time_to_commit =
535 base::TimeTicks::Now() - navigation_start_time_and_url.a;
536 UMA_HISTOGRAM_TIMES("Navigation.TimeToCommit", time_to_commit);
537 navigation_start_time_and_url = MakeTuple(base::TimeTicks(), GURL());
538 }
539
523 // Run post-commit tasks. 540 // Run post-commit tasks.
524 if (delegate_) { 541 if (delegate_) {
525 if (details.is_main_frame) 542 if (details.is_main_frame)
526 delegate_->DidNavigateMainFramePostCommit(details, params); 543 delegate_->DidNavigateMainFramePostCommit(details, params);
527 544
528 delegate_->DidNavigateAnyFramePostCommit( 545 delegate_->DidNavigateAnyFramePostCommit(
529 render_frame_host, details, params); 546 render_frame_host, details, params);
530 } 547 }
531 } 548 }
532 549
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 654
638 void NavigatorImpl::CommitNavigation( 655 void NavigatorImpl::CommitNavigation(
639 RenderFrameHostImpl* render_frame_host, 656 RenderFrameHostImpl* render_frame_host,
640 const NavigationBeforeCommitInfo& info) { 657 const NavigationBeforeCommitInfo& info) {
641 CheckWebUIRendererDoesNotDisplayNormalURL( 658 CheckWebUIRendererDoesNotDisplayNormalURL(
642 render_frame_host, info.navigation_url); 659 render_frame_host, info.navigation_url);
643 // TODO(clamy): the render_frame_host should now send a commit IPC to the 660 // TODO(clamy): the render_frame_host should now send a commit IPC to the
644 // renderer. 661 // renderer.
645 } 662 }
646 663
664 void NavigatorImpl::LogResourceRequestTime(
665 base::TimeTicks timestamp, const GURL& url) {
666 if (navigation_start_time_and_url.a.ToInternalValue() != 0
667 && navigation_start_time_and_url.b == url) {
668 base::TimeDelta time_to_network =
669 timestamp - navigation_start_time_and_url.a;
670 UMA_HISTOGRAM_TIMES("Navigation.TimeToURLJobStart", time_to_network);
671 }
672 }
673
647 void NavigatorImpl::CheckWebUIRendererDoesNotDisplayNormalURL( 674 void NavigatorImpl::CheckWebUIRendererDoesNotDisplayNormalURL(
648 RenderFrameHostImpl* render_frame_host, 675 RenderFrameHostImpl* render_frame_host,
649 const GURL& url) { 676 const GURL& url) {
650 int enabled_bindings = 677 int enabled_bindings =
651 render_frame_host->render_view_host()->GetEnabledBindings(); 678 render_frame_host->render_view_host()->GetEnabledBindings();
652 bool is_allowed_in_web_ui_renderer = 679 bool is_allowed_in_web_ui_renderer =
653 WebUIControllerFactoryRegistry::GetInstance()->IsURLAcceptableForWebUI( 680 WebUIControllerFactoryRegistry::GetInstance()->IsURLAcceptableForWebUI(
654 controller_->GetBrowserContext(), url); 681 controller_->GetBrowserContext(), url);
655 if ((enabled_bindings & BINDINGS_POLICY_WEB_UI) && 682 if ((enabled_bindings & BINDINGS_POLICY_WEB_UI) &&
656 !is_allowed_in_web_ui_renderer) { 683 !is_allowed_in_web_ui_renderer) {
657 // Log the URL to help us diagnose any future failures of this CHECK. 684 // Log the URL to help us diagnose any future failures of this CHECK.
658 GetContentClient()->SetActiveURL(url); 685 GetContentClient()->SetActiveURL(url);
659 CHECK(0); 686 CHECK(0);
660 } 687 }
661 } 688 }
662 689
663 } // namespace content 690 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/navigator_impl.h ('k') | content/browser/frame_host/render_frame_host_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698