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

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: Addressed CR comments, added new hisogram, test and fixes. 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 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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
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): Yes I did read the above comment and I will move this out
558 // of here as soon as I can a) get the information I need through
559 // WebContentsObserver and b) fix the current PlzNavigate implementation so
560 // that the observer methods are actually called.
clamy 2014/09/23 21:54:07 If you don't implement the histograms as an observ
carlosk 2014/09/24 18:35:49 I'll rephrase that to what you suggested. Some no
561 if (details.is_main_frame &&
nasko 2014/09/24 00:48:06 Do we only care about top-level navigations?
carlosk 2014/09/24 18:35:50 Yes, from my talks with Camille. I still can't arg
nasko 2014/09/26 00:10:35 Not yet, but in the not so long distant future the
clamy 2014/09/26 14:48:32 Though not on Android right? Since the delay we ob
carlosk 2014/09/26 15:50:25 Acknowledged.
562 navigation_start_time_.ToInternalValue() != 0
563 && navigation_start_url_ == params.original_request_url) {
564 base::TimeDelta time_to_network =
nasko 2014/09/24 00:48:06 Why is this named "time_to_network"? I don't see m
carlosk 2014/09/24 18:35:50 Done! Bad copy-paste skills! :)
565 base::TimeTicks::Now() - navigation_start_time_;
nasko 2014/09/24 00:48:06 nit: wrong indent
carlosk 2014/09/24 18:35:49 Done! I assumed I was missing an extra couple of s
nasko 2014/09/24 23:11:20 Yes. In general, clang-format is your friend for a
carlosk 2014/09/25 17:26:05 Didn't know about it and I'm having issues trying
566 UMA_HISTOGRAM_TIMES("Navigation.TimeToNavigationFinished", time_to_network);
clamy 2014/09/23 21:54:07 I would rename this Navigation.TimeToCommit.
nasko 2014/09/24 00:48:06 +1. I'd rename the TimeDelta variable also to matc
carlosk 2014/09/24 18:35:50 Done! I had it named that way because this happen
carlosk 2014/09/24 18:35:50 Done.
nasko 2014/09/24 23:11:21 I think you have a bit of a misconception of start
carlosk 2014/09/25 17:26:05 Acknowledged. I'll take your teaching offer! :)
567 navigation_start_time_ = base::TimeTicks();
568 }
569
552 // Run post-commit tasks. 570 // Run post-commit tasks.
553 if (delegate_) { 571 if (delegate_) {
554 if (details.is_main_frame) 572 if (details.is_main_frame)
555 delegate_->DidNavigateMainFramePostCommit(details, params); 573 delegate_->DidNavigateMainFramePostCommit(details, params);
556 574
557 delegate_->DidNavigateAnyFramePostCommit( 575 delegate_->DidNavigateAnyFramePostCommit(
558 render_frame_host, details, params); 576 render_frame_host, details, params);
559 } 577 }
560 } 578 }
561 579
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 delegate_->RequestOpenURL(render_frame_host, params); 681 delegate_->RequestOpenURL(render_frame_host, params);
664 } 682 }
665 683
666 void NavigatorImpl::CommitNavigation( 684 void NavigatorImpl::CommitNavigation(
667 RenderFrameHostImpl* render_frame_host, 685 RenderFrameHostImpl* render_frame_host,
668 const NavigationBeforeCommitInfo& info) { 686 const NavigationBeforeCommitInfo& info) {
669 CheckWebUIRendererDoesNotDisplayNormalURL( 687 CheckWebUIRendererDoesNotDisplayNormalURL(
670 render_frame_host, info.navigation_url); 688 render_frame_host, info.navigation_url);
671 // TODO(clamy): the render_frame_host should now send a commit IPC to the 689 // TODO(clamy): the render_frame_host should now send a commit IPC to the
672 // renderer. 690 // renderer.
691 // TODO(carlosk): when Issue 376015 done (CL 519533002) use the
nasko 2014/09/24 00:48:06 Instead of using "issue XXXXXX", use http://crbug.
carlosk 2014/09/24 18:35:49 Done.
nasko 2014/09/24 23:11:20 And by "done" you mean "I've removed it, so it is
carlosk 2014/09/25 17:26:05 Yes I removed the full comment as it was applicabl
692 // ResourceResponseInfo::request_time that will be made available here as the
693 // time stamp for time-to-network and replace the more convoluted way it's
nasko 2014/09/24 00:48:06 nit: timestamp
carlosk 2014/09/24 18:35:49 Done.
694 // being done right now (through the LogResourceRequestTime call below invoked
695 // from RDHI).
696 }
697
698 void NavigatorImpl::LogResourceRequestTime(
699 base::TimeTicks timestamp, const GURL& url) {
700 if (navigation_start_time_.ToInternalValue() != 0
701 && navigation_start_url_ == url) {
702 base::TimeDelta time_to_network = timestamp - navigation_start_time_;
703 UMA_HISTOGRAM_TIMES("Navigation.TimeToURLJobStart", time_to_network);
704 }
673 } 705 }
674 706
675 void NavigatorImpl::CheckWebUIRendererDoesNotDisplayNormalURL( 707 void NavigatorImpl::CheckWebUIRendererDoesNotDisplayNormalURL(
676 RenderFrameHostImpl* render_frame_host, 708 RenderFrameHostImpl* render_frame_host,
677 const GURL& url) { 709 const GURL& url) {
678 int enabled_bindings = 710 int enabled_bindings =
679 render_frame_host->render_view_host()->GetEnabledBindings(); 711 render_frame_host->render_view_host()->GetEnabledBindings();
680 bool is_allowed_in_web_ui_renderer = 712 bool is_allowed_in_web_ui_renderer =
681 WebUIControllerFactoryRegistry::GetInstance()->IsURLAcceptableForWebUI( 713 WebUIControllerFactoryRegistry::GetInstance()->IsURLAcceptableForWebUI(
682 controller_->GetBrowserContext(), url); 714 controller_->GetBrowserContext(), url);
683 if ((enabled_bindings & BINDINGS_POLICY_WEB_UI) && 715 if ((enabled_bindings & BINDINGS_POLICY_WEB_UI) &&
684 !is_allowed_in_web_ui_renderer) { 716 !is_allowed_in_web_ui_renderer) {
685 // Log the URL to help us diagnose any future failures of this CHECK. 717 // Log the URL to help us diagnose any future failures of this CHECK.
686 GetContentClient()->SetActiveURL(url); 718 GetContentClient()->SetActiveURL(url);
687 CHECK(0); 719 CHECK(0);
688 } 720 }
689 } 721 }
690 722
691 } // namespace content 723 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698