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

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: histogram.xml Created 6 years, 3 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 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 LOG(WARNING) << "Refusing to load URL as it exceeds " << GetMaxURLChars() 335 LOG(WARNING) << "Refusing to load URL as it exceeds " << GetMaxURLChars()
335 << " characters."; 336 << " characters.";
336 return false; 337 return false;
337 } 338 }
338 339
339 // This will be used to set the Navigation Timing API navigationStart 340 // This will be used to set the Navigation Timing API navigationStart
340 // parameter for browser navigations in new tabs (intents, tabs opened through 341 // parameter for browser navigations in new tabs (intents, tabs opened through
341 // "Open link in new tab"). We need to keep it above RFHM::Navigate() call to 342 // "Open link in new tab"). We need to keep it above RFHM::Navigate() call to
342 // capture the time needed for the RenderFrameHost initialization. 343 // capture the time needed for the RenderFrameHost initialization.
343 base::TimeTicks navigation_start = base::TimeTicks::Now(); 344 base::TimeTicks navigation_start = base::TimeTicks::Now();
344
clamy 2014/09/19 14:56:03 Did you remove the line on purpose? I think it is
carlosk 2014/09/23 17:02:56 Done. It was not on purpose: I did changes in this
345 FrameMsg_Navigate_Params navigate_params; 345 FrameMsg_Navigate_Params navigate_params;
346 RenderFrameHostManager* manager = 346 RenderFrameHostManager* manager =
347 render_frame_host->frame_tree_node()->render_manager(); 347 render_frame_host->frame_tree_node()->render_manager();
348 348
349 // PlzNavigate: the RenderFrameHosts are no longer asked to navigate. Instead 349 // PlzNavigate: the RenderFrameHosts are no longer asked to navigate. Instead
350 // the RenderFrameHostManager handles the navigation requests for that frame 350 // the RenderFrameHostManager handles the navigation requests for that frame
351 // node. 351 // node.
352 if (CommandLine::ForCurrentProcess()->HasSwitch( 352 if (CommandLine::ForCurrentProcess()->HasSwitch(
353 switches::kEnableBrowserSideNavigation)) { 353 switches::kEnableBrowserSideNavigation)) {
354 navigation_start_time_ = navigation_start;
355 navigation_start_url_ = entry.GetURL();
354 // Create the navigation parameters. 356 // Create the navigation parameters.
355 MakeNavigateParams( 357 MakeNavigateParams(
356 entry, *controller_, reload_type, navigation_start, &navigate_params); 358 entry, *controller_, reload_type, navigation_start, &navigate_params);
357 return manager->RequestNavigation(entry, navigate_params); 359 return manager->RequestNavigation(entry, navigate_params);
358 } 360 }
359 361
360 RenderFrameHostImpl* dest_render_frame_host = manager->Navigate(entry); 362 RenderFrameHostImpl* dest_render_frame_host = manager->Navigate(entry);
361 if (!dest_render_frame_host) 363 if (!dest_render_frame_host)
362 return false; // Unable to create the desired RenderFrameHost. 364 return false; // Unable to create the desired RenderFrameHost.
363 365
(...skipping 17 matching lines...) Expand all
381 383
382 // Navigate in the desired RenderFrameHost. 384 // Navigate in the desired RenderFrameHost.
383 // We can skip this step in the rare case that this is a transfer navigation 385 // 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 386 // which began in the chosen RenderFrameHost, since the request has already
385 // been issued. In that case, simply resume the response. 387 // been issued. In that case, simply resume the response.
386 bool is_transfer_to_same = 388 bool is_transfer_to_same =
387 navigate_params.transferred_request_child_id != -1 && 389 navigate_params.transferred_request_child_id != -1 &&
388 navigate_params.transferred_request_child_id == 390 navigate_params.transferred_request_child_id ==
389 dest_render_frame_host->GetProcess()->GetID(); 391 dest_render_frame_host->GetProcess()->GetID();
390 if (!is_transfer_to_same) { 392 if (!is_transfer_to_same) {
393 navigation_start_time_ = navigation_start;
394 navigation_start_url_ = entry.GetURL();
391 dest_render_frame_host->Navigate(navigate_params); 395 dest_render_frame_host->Navigate(navigate_params);
392 } else { 396 } else {
393 // No need to navigate again. Just resume the deferred request. 397 // No need to navigate again. Just resume the deferred request.
394 dest_render_frame_host->GetProcess()->ResumeDeferredNavigation( 398 dest_render_frame_host->GetProcess()->ResumeDeferredNavigation(
395 GlobalRequestID(navigate_params.transferred_request_child_id, 399 GlobalRequestID(navigate_params.transferred_request_child_id,
396 navigate_params.transferred_request_request_id)); 400 navigate_params.transferred_request_request_id));
397 } 401 }
398 402
399 // Make sure no code called via RFH::Navigate clears the pending entry. 403 // Make sure no code called via RFH::Navigate clears the pending entry.
400 CHECK_EQ(controller_->GetPendingEntry(), &entry); 404 CHECK_EQ(controller_->GetPendingEntry(), &entry);
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 663
660 void NavigatorImpl::CommitNavigation( 664 void NavigatorImpl::CommitNavigation(
661 RenderFrameHostImpl* render_frame_host, 665 RenderFrameHostImpl* render_frame_host,
662 const NavigationBeforeCommitInfo& info) { 666 const NavigationBeforeCommitInfo& info) {
663 CheckWebUIRendererDoesNotDisplayNormalURL( 667 CheckWebUIRendererDoesNotDisplayNormalURL(
664 render_frame_host, info.navigation_url); 668 render_frame_host, info.navigation_url);
665 // TODO(clamy): the render_frame_host should now send a commit IPC to the 669 // TODO(clamy): the render_frame_host should now send a commit IPC to the
666 // renderer. 670 // renderer.
667 } 671 }
668 672
673 void NavigatorImpl::LogResourceRequestTime(
674 base::TimeTicks timestamp, GURL url) {
675 if (navigation_start_url_ == url) {
davidben 2014/09/19 21:52:45 This is slightly racy, but there's not really much
carlosk 2014/09/23 17:02:57 Yes! I was from the start looking for a "request_i
676 base::TimeDelta time_to_network = timestamp - navigation_start_time_;
677 LOCAL_HISTOGRAM_TIMES("PlzNavigate.TimeToNetworkRequest", time_to_network);
clamy 2014/09/19 14:56:03 You want a UMA_HISTOGRAM_TIMES, otherwise we will
carlosk 2014/09/23 17:02:56 Done! My bad!
678 }
679 }
680
669 void NavigatorImpl::CheckWebUIRendererDoesNotDisplayNormalURL( 681 void NavigatorImpl::CheckWebUIRendererDoesNotDisplayNormalURL(
670 RenderFrameHostImpl* render_frame_host, 682 RenderFrameHostImpl* render_frame_host,
671 const GURL& url) { 683 const GURL& url) {
672 int enabled_bindings = 684 int enabled_bindings =
673 render_frame_host->render_view_host()->GetEnabledBindings(); 685 render_frame_host->render_view_host()->GetEnabledBindings();
674 bool is_allowed_in_web_ui_renderer = 686 bool is_allowed_in_web_ui_renderer =
675 WebUIControllerFactoryRegistry::GetInstance()->IsURLAcceptableForWebUI( 687 WebUIControllerFactoryRegistry::GetInstance()->IsURLAcceptableForWebUI(
676 controller_->GetBrowserContext(), url); 688 controller_->GetBrowserContext(), url);
677 if ((enabled_bindings & BINDINGS_POLICY_WEB_UI) && 689 if ((enabled_bindings & BINDINGS_POLICY_WEB_UI) &&
678 !is_allowed_in_web_ui_renderer) { 690 !is_allowed_in_web_ui_renderer) {
679 // Log the URL to help us diagnose any future failures of this CHECK. 691 // Log the URL to help us diagnose any future failures of this CHECK.
680 GetContentClient()->SetActiveURL(url); 692 GetContentClient()->SetActiveURL(url);
681 CHECK(0); 693 CHECK(0);
682 } 694 }
683 } 695 }
684 696
685 } // namespace content 697 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698