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

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: Now I can get RFHs... But maybe not the right ones. :( 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 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 TRACE_EVENT0("browser,navigation", "NavigatorImpl::NavigateToEntry"); 330 TRACE_EVENT0("browser,navigation", "NavigatorImpl::NavigateToEntry");
330 331
331 // The renderer will reject IPC messages with URLs longer than 332 // The renderer will reject IPC messages with URLs longer than
332 // this limit, so don't attempt to navigate with a longer URL. 333 // this limit, so don't attempt to navigate with a longer URL.
333 if (entry.GetURL().spec().size() > GetMaxURLChars()) { 334 if (entry.GetURL().spec().size() > GetMaxURLChars()) {
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 time 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 navigation_start_time_ = base::TimeTicks::Now();
345 LOG(WARNING) << "###########################";
346 LOG(WARNING) << "NAVIGATION STARTED AT " << navigation_start_time_.ToInternalV alue();
347 LOG(WARNING) << "process_id / child_id = " << render_frame_host->GetProcess()- >GetID();
348 LOG(WARNING) << "routing_id / render_frame_host = " << render_frame_host->rout ing_id();
clamy 2014/09/17 21:12:39 You cannot use the id values for this render_frame
carlosk 2014/09/18 15:00:52 Acknowledged.
349 LOG(WARNING) << "URL = " << entry.GetURL();
344 350
345 FrameMsg_Navigate_Params navigate_params; 351 FrameMsg_Navigate_Params navigate_params;
346 RenderFrameHostManager* manager = 352 RenderFrameHostManager* manager =
347 render_frame_host->frame_tree_node()->render_manager(); 353 render_frame_host->frame_tree_node()->render_manager();
348 354
349 // PlzNavigate: the RenderFrameHosts are no longer asked to navigate. Instead 355 // PlzNavigate: the RenderFrameHosts are no longer asked to navigate. Instead
350 // the RenderFrameHostManager handles the navigation requests for that frame 356 // the RenderFrameHostManager handles the navigation requests for that frame
351 // node. 357 // node.
352 if (CommandLine::ForCurrentProcess()->HasSwitch( 358 if (CommandLine::ForCurrentProcess()->HasSwitch(
353 switches::kEnableBrowserSideNavigation)) { 359 switches::kEnableBrowserSideNavigation)) {
354 // Create the navigation parameters. 360 // Create the navigation parameters.
355 MakeNavigateParams( 361 MakeNavigateParams(
356 entry, *controller_, reload_type, navigation_start, &navigate_params); 362 entry, *controller_, reload_type, navigation_start_time_, &navigate_para ms);
357 return manager->RequestNavigation(entry, navigate_params); 363 return manager->RequestNavigation(entry, navigate_params);
358 } 364 }
359 365
360 RenderFrameHostImpl* dest_render_frame_host = manager->Navigate(entry); 366 RenderFrameHostImpl* dest_render_frame_host = manager->Navigate(entry);
clamy 2014/09/17 21:12:39 We pick here the RFH that is going to navigate. It
carlosk 2014/09/18 15:00:52 Acknowledged.
361 if (!dest_render_frame_host) 367 if (!dest_render_frame_host)
362 return false; // Unable to create the desired RenderFrameHost. 368 return false; // Unable to create the desired RenderFrameHost.
363 369
364 // Make sure no code called via RFHM::Navigate clears the pending entry. 370 // Make sure no code called via RFHM::Navigate clears the pending entry.
365 CHECK_EQ(controller_->GetPendingEntry(), &entry); 371 CHECK_EQ(controller_->GetPendingEntry(), &entry);
366 372
367 // For security, we should never send non-Web-UI URLs to a Web UI renderer. 373 // For security, we should never send non-Web-UI URLs to a Web UI renderer.
368 // Double check that here. 374 // Double check that here.
369 CheckWebUIRendererDoesNotDisplayNormalURL( 375 CheckWebUIRendererDoesNotDisplayNormalURL(
370 dest_render_frame_host, entry.GetURL()); 376 dest_render_frame_host, entry.GetURL());
371 377
372 // Notify observers that we will navigate in this RenderFrame. 378 // Notify observers that we will navigate in this RenderFrame.
373 if (delegate_) 379 if (delegate_)
374 delegate_->AboutToNavigateRenderFrame(dest_render_frame_host); 380 delegate_->AboutToNavigateRenderFrame(dest_render_frame_host);
375 381
376 // Create the navigation parameters. 382 // Create the navigation parameters.
377 // TODO(vitalybuka): Move this before AboutToNavigateRenderFrame once 383 // TODO(vitalybuka): Move this before AboutToNavigateRenderFrame once
378 // http://crbug.com/408684 is fixed. 384 // http://crbug.com/408684 is fixed.
379 MakeNavigateParams( 385 MakeNavigateParams(
380 entry, *controller_, reload_type, navigation_start, &navigate_params); 386 entry, *controller_, reload_type, navigation_start_time_, &navigate_params );
381 387
382 // Navigate in the desired RenderFrameHost. 388 // Navigate in the desired RenderFrameHost.
383 // We can skip this step in the rare case that this is a transfer navigation 389 // 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 390 // which began in the chosen RenderFrameHost, since the request has already
385 // been issued. In that case, simply resume the response. 391 // been issued. In that case, simply resume the response.
386 bool is_transfer_to_same = 392 bool is_transfer_to_same =
387 navigate_params.transferred_request_child_id != -1 && 393 navigate_params.transferred_request_child_id != -1 &&
388 navigate_params.transferred_request_child_id == 394 navigate_params.transferred_request_child_id ==
389 dest_render_frame_host->GetProcess()->GetID(); 395 dest_render_frame_host->GetProcess()->GetID();
390 if (!is_transfer_to_same) { 396 if (!is_transfer_to_same) {
391 dest_render_frame_host->Navigate(navigate_params); 397 dest_render_frame_host->Navigate(navigate_params);
clamy 2014/09/17 21:12:39 And we have it navigate here...
carlosk 2014/09/18 15:00:52 So you mean that it's only here -- right before th
392 } else { 398 } else {
393 // No need to navigate again. Just resume the deferred request. 399 // No need to navigate again. Just resume the deferred request.
394 dest_render_frame_host->GetProcess()->ResumeDeferredNavigation( 400 dest_render_frame_host->GetProcess()->ResumeDeferredNavigation(
395 GlobalRequestID(navigate_params.transferred_request_child_id, 401 GlobalRequestID(navigate_params.transferred_request_child_id,
396 navigate_params.transferred_request_request_id)); 402 navigate_params.transferred_request_request_id));
397 } 403 }
398 404
399 // Make sure no code called via RFH::Navigate clears the pending entry. 405 // Make sure no code called via RFH::Navigate clears the pending entry.
400 CHECK_EQ(controller_->GetPendingEntry(), &entry); 406 CHECK_EQ(controller_->GetPendingEntry(), &entry);
401 407
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 params.transition | PAGE_TRANSITION_FORWARD_BACK); 542 params.transition | PAGE_TRANSITION_FORWARD_BACK);
537 } 543 }
538 544
539 delegate_->DidCommitProvisionalLoad(render_frame_host, 545 delegate_->DidCommitProvisionalLoad(render_frame_host,
540 params.url, 546 params.url,
541 transition_type); 547 transition_type);
542 } 548 }
543 549
544 if (!did_navigate) 550 if (!did_navigate)
545 return; // No navigation happened. 551 return; // No navigation happened.
546 552
carlosk 2014/09/18 15:00:52 As there's this "no navigation happened" comment h
547 // DO NOT ADD MORE STUFF TO THIS FUNCTION! Your component should either listen 553 // 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 554 // for the appropriate notification (best) or you can add it to
549 // DidNavigateMainFramePostCommit / DidNavigateAnyFramePostCommit (only if 555 // DidNavigateMainFramePostCommit / DidNavigateAnyFramePostCommit (only if
550 // necessary, please). 556 // necessary, please).
551 557
carlosk 2014/09/18 15:00:52 But it's said here nothing should be added to this
552 // Run post-commit tasks. 558 // Run post-commit tasks.
553 if (delegate_) { 559 if (delegate_) {
554 if (details.is_main_frame) 560 if (details.is_main_frame)
555 delegate_->DidNavigateMainFramePostCommit(details, params); 561 delegate_->DidNavigateMainFramePostCommit(details, params);
556 562
557 delegate_->DidNavigateAnyFramePostCommit( 563 delegate_->DidNavigateAnyFramePostCommit(
558 render_frame_host, details, params); 564 render_frame_host, details, params);
559 } 565 }
560 } 566 }
561 567
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 665
660 void NavigatorImpl::CommitNavigation( 666 void NavigatorImpl::CommitNavigation(
661 RenderFrameHostImpl* render_frame_host, 667 RenderFrameHostImpl* render_frame_host,
662 const NavigationBeforeCommitInfo& info) { 668 const NavigationBeforeCommitInfo& info) {
663 CheckWebUIRendererDoesNotDisplayNormalURL( 669 CheckWebUIRendererDoesNotDisplayNormalURL(
664 render_frame_host, info.navigation_url); 670 render_frame_host, info.navigation_url);
665 // TODO(clamy): the render_frame_host should now send a commit IPC to the 671 // TODO(clamy): the render_frame_host should now send a commit IPC to the
666 // renderer. 672 // renderer.
667 } 673 }
668 674
675 void NavigatorImpl::LogResourceRequestTime(base::TimeTicks timestamp) {
676 base::TimeDelta time_to_network = base::TimeTicks::Now() - timestamp;
clamy 2014/09/17 21:12:40 This should be timestamp - navigation_start_time_.
carlosk 2014/09/18 15:00:52 Yes, of course! Done!
677 LOG(WARNING) << "=======================";
678 LOG(WARNING) << "Time to network request: " << time_to_network.InMilliseconds( );
679 LOCAL_HISTOGRAM_TIMES("PlzNavigate.TimeToNetworkRequest", time_to_network);
680 }
681
669 void NavigatorImpl::CheckWebUIRendererDoesNotDisplayNormalURL( 682 void NavigatorImpl::CheckWebUIRendererDoesNotDisplayNormalURL(
670 RenderFrameHostImpl* render_frame_host, 683 RenderFrameHostImpl* render_frame_host,
671 const GURL& url) { 684 const GURL& url) {
672 int enabled_bindings = 685 int enabled_bindings =
673 render_frame_host->render_view_host()->GetEnabledBindings(); 686 render_frame_host->render_view_host()->GetEnabledBindings();
674 bool is_allowed_in_web_ui_renderer = 687 bool is_allowed_in_web_ui_renderer =
675 WebUIControllerFactoryRegistry::GetInstance()->IsURLAcceptableForWebUI( 688 WebUIControllerFactoryRegistry::GetInstance()->IsURLAcceptableForWebUI(
676 controller_->GetBrowserContext(), url); 689 controller_->GetBrowserContext(), url);
677 if ((enabled_bindings & BINDINGS_POLICY_WEB_UI) && 690 if ((enabled_bindings & BINDINGS_POLICY_WEB_UI) &&
678 !is_allowed_in_web_ui_renderer) { 691 !is_allowed_in_web_ui_renderer) {
679 // Log the URL to help us diagnose any future failures of this CHECK. 692 // Log the URL to help us diagnose any future failures of this CHECK.
680 GetContentClient()->SetActiveURL(url); 693 GetContentClient()->SetActiveURL(url);
681 CHECK(0); 694 CHECK(0);
682 } 695 }
683 } 696 }
684 697
685 } // namespace content 698 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/navigator_impl.h ('k') | content/browser/loader/resource_dispatcher_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698