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

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

Issue 339573003: NavigationTiming: set navigationStart for navigations in new tabs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: DCHECK that browser_navigation_start is always present. Created 6 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | content/common/frame_messages.h » ('j') | content/common/frame_messages.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "content/browser/frame_host/frame_tree.h" 8 #include "content/browser/frame_host/frame_tree.h"
9 #include "content/browser/frame_host/frame_tree_node.h" 9 #include "content/browser/frame_host/frame_tree_node.h"
10 #include "content/browser/frame_host/navigation_controller_impl.h" 10 #include "content/browser/frame_host/navigation_controller_impl.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 return FrameMsg_Navigate_Type::RESTORE_WITH_POST; 57 return FrameMsg_Navigate_Type::RESTORE_WITH_POST;
58 return FrameMsg_Navigate_Type::RESTORE; 58 return FrameMsg_Navigate_Type::RESTORE;
59 } 59 }
60 60
61 return FrameMsg_Navigate_Type::NORMAL; 61 return FrameMsg_Navigate_Type::NORMAL;
62 } 62 }
63 63
64 void MakeNavigateParams(const NavigationEntryImpl& entry, 64 void MakeNavigateParams(const NavigationEntryImpl& entry,
65 const NavigationControllerImpl& controller, 65 const NavigationControllerImpl& controller,
66 NavigationController::ReloadType reload_type, 66 NavigationController::ReloadType reload_type,
67 base::TimeTicks navigation_start,
67 FrameMsg_Navigate_Params* params) { 68 FrameMsg_Navigate_Params* params) {
68 params->page_id = entry.GetPageID(); 69 params->page_id = entry.GetPageID();
69 params->should_clear_history_list = entry.should_clear_history_list(); 70 params->should_clear_history_list = entry.should_clear_history_list();
70 params->should_replace_current_entry = entry.should_replace_entry(); 71 params->should_replace_current_entry = entry.should_replace_entry();
71 if (entry.should_clear_history_list()) { 72 if (entry.should_clear_history_list()) {
72 // Set the history list related parameters to the same values a 73 // Set the history list related parameters to the same values a
73 // NavigationController would return before its first navigation. This will 74 // NavigationController would return before its first navigation. This will
74 // fully clear the RenderView's view of the session history. 75 // fully clear the RenderView's view of the session history.
75 params->pending_history_list_offset = -1; 76 params->pending_history_list_offset = -1;
76 params->current_history_list_offset = -1; 77 params->current_history_list_offset = -1;
77 params->current_history_list_length = 0; 78 params->current_history_list_length = 0;
78 } else { 79 } else {
79 params->pending_history_list_offset = controller.GetIndexOfEntry(&entry); 80 params->pending_history_list_offset = controller.GetIndexOfEntry(&entry);
80 params->current_history_list_offset = 81 params->current_history_list_offset =
81 controller.GetLastCommittedEntryIndex(); 82 controller.GetLastCommittedEntryIndex();
82 params->current_history_list_length = controller.GetEntryCount(); 83 params->current_history_list_length = controller.GetEntryCount();
83 } 84 }
84 params->url = entry.GetURL(); 85 params->url = entry.GetURL();
85 if (!entry.GetBaseURLForDataURL().is_empty()) { 86 if (!entry.GetBaseURLForDataURL().is_empty()) {
86 params->base_url_for_data_url = entry.GetBaseURLForDataURL(); 87 params->base_url_for_data_url = entry.GetBaseURLForDataURL();
87 params->history_url_for_data_url = entry.GetVirtualURL(); 88 params->history_url_for_data_url = entry.GetVirtualURL();
88 } 89 }
89 params->referrer = entry.GetReferrer(); 90 params->referrer = entry.GetReferrer();
90 params->transition = entry.GetTransitionType(); 91 params->transition = entry.GetTransitionType();
91 params->page_state = entry.GetPageState(); 92 params->page_state = entry.GetPageState();
92 params->navigation_type = 93 params->navigation_type =
93 GetNavigationType(controller.GetBrowserContext(), entry, reload_type); 94 GetNavigationType(controller.GetBrowserContext(), entry, reload_type);
95 // This is used by the old performance infrastructure to set up DocumentState
96 // associated with the RenderView. TODO(ppi): make it go away.
nasko 2014/06/27 23:10:54 nit: TODO on new line.
ppi 2014/07/01 18:40:13 Done.
94 params->request_time = base::Time::Now(); 97 params->request_time = base::Time::Now();
95 params->extra_headers = entry.extra_headers(); 98 params->extra_headers = entry.extra_headers();
96 params->transferred_request_child_id = 99 params->transferred_request_child_id =
97 entry.transferred_global_request_id().child_id; 100 entry.transferred_global_request_id().child_id;
98 params->transferred_request_request_id = 101 params->transferred_request_request_id =
99 entry.transferred_global_request_id().request_id; 102 entry.transferred_global_request_id().request_id;
100 params->is_overriding_user_agent = entry.GetIsOverridingUserAgent(); 103 params->is_overriding_user_agent = entry.GetIsOverridingUserAgent();
101 // Avoid downloading when in view-source mode. 104 // Avoid downloading when in view-source mode.
102 params->allow_download = !entry.IsViewSourceMode(); 105 params->allow_download = !entry.IsViewSourceMode();
103 params->is_post = entry.GetHasPostData(); 106 params->is_post = entry.GetHasPostData();
104 if (entry.GetBrowserInitiatedPostData()) { 107 if (entry.GetBrowserInitiatedPostData()) {
105 params->browser_initiated_post_data.assign( 108 params->browser_initiated_post_data.assign(
106 entry.GetBrowserInitiatedPostData()->front(), 109 entry.GetBrowserInitiatedPostData()->front(),
107 entry.GetBrowserInitiatedPostData()->front() + 110 entry.GetBrowserInitiatedPostData()->front() +
108 entry.GetBrowserInitiatedPostData()->size()); 111 entry.GetBrowserInitiatedPostData()->size());
109 } 112 }
110 113
111 // Set the redirect chain to the navigation's redirects, unless we are 114 // Set the redirect chain to the navigation's redirects, unless we are
112 // returning to a completed navigation (whose previous redirects don't apply). 115 // returning to a completed navigation (whose previous redirects don't apply).
113 if (PageTransitionIsNewNavigation(params->transition)) { 116 if (PageTransitionIsNewNavigation(params->transition)) {
114 params->redirects = entry.GetRedirectChain(); 117 params->redirects = entry.GetRedirectChain();
115 } else { 118 } else {
116 params->redirects.clear(); 119 params->redirects.clear();
117 } 120 }
118 121
119 params->can_load_local_resources = entry.GetCanLoadLocalResources(); 122 params->can_load_local_resources = entry.GetCanLoadLocalResources();
120 params->frame_to_navigate = entry.GetFrameToNavigate(); 123 params->frame_to_navigate = entry.GetFrameToNavigate();
124 params->browser_navigation_start = navigation_start;
121 } 125 }
122 126
123 RenderFrameHostManager* GetRenderManager(RenderFrameHostImpl* rfh) { 127 RenderFrameHostManager* GetRenderManager(RenderFrameHostImpl* rfh) {
124 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess)) 128 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess))
125 return rfh->frame_tree_node()->render_manager(); 129 return rfh->frame_tree_node()->render_manager();
126 130
127 return rfh->frame_tree_node()->frame_tree()->root()->render_manager(); 131 return rfh->frame_tree_node()->frame_tree()->root()->render_manager();
128 } 132 }
129 133
130 } // namespace 134 } // namespace
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 TRACE_EVENT0("browser", "NavigatorImpl::NavigateToEntry"); 321 TRACE_EVENT0("browser", "NavigatorImpl::NavigateToEntry");
318 322
319 // The renderer will reject IPC messages with URLs longer than 323 // The renderer will reject IPC messages with URLs longer than
320 // this limit, so don't attempt to navigate with a longer URL. 324 // this limit, so don't attempt to navigate with a longer URL.
321 if (entry.GetURL().spec().size() > GetMaxURLChars()) { 325 if (entry.GetURL().spec().size() > GetMaxURLChars()) {
322 LOG(WARNING) << "Refusing to load URL as it exceeds " << GetMaxURLChars() 326 LOG(WARNING) << "Refusing to load URL as it exceeds " << GetMaxURLChars()
323 << " characters."; 327 << " characters.";
324 return false; 328 return false;
325 } 329 }
326 330
331 // This will be used to set the Navigation Timing API navigationStart
332 // parameter for browser navigations in new tabs (intents, tabs opened through
333 // "Open link in new tab"). We need to keep it above RFHM::Navigate() call to
334 // capture the time needed for RFM initialization.
nasko 2014/06/27 23:10:54 RFM? Did you mean RFH? Maybe expand it instead of
ppi 2014/07/01 18:40:13 Done.
335 base::TimeTicks navigation_start = base::TimeTicks::Now();
336
327 RenderFrameHostManager* manager = 337 RenderFrameHostManager* manager =
328 render_frame_host->frame_tree_node()->render_manager(); 338 render_frame_host->frame_tree_node()->render_manager();
329 RenderFrameHostImpl* dest_render_frame_host = manager->Navigate(entry); 339 RenderFrameHostImpl* dest_render_frame_host = manager->Navigate(entry);
330 if (!dest_render_frame_host) 340 if (!dest_render_frame_host)
331 return false; // Unable to create the desired RenderFrameHost. 341 return false; // Unable to create the desired RenderFrameHost.
332 342
333 // Make sure no code called via RFHM::Navigate clears the pending entry. 343 // Make sure no code called via RFHM::Navigate clears the pending entry.
334 CHECK_EQ(controller_->GetPendingEntry(), &entry); 344 CHECK_EQ(controller_->GetPendingEntry(), &entry);
335 345
336 // For security, we should never send non-Web-UI URLs to a Web UI renderer. 346 // For security, we should never send non-Web-UI URLs to a Web UI renderer.
337 // Double check that here. 347 // Double check that here.
338 int enabled_bindings = 348 int enabled_bindings =
339 dest_render_frame_host->render_view_host()->GetEnabledBindings(); 349 dest_render_frame_host->render_view_host()->GetEnabledBindings();
340 bool is_allowed_in_web_ui_renderer = 350 bool is_allowed_in_web_ui_renderer =
341 WebUIControllerFactoryRegistry::GetInstance()->IsURLAcceptableForWebUI( 351 WebUIControllerFactoryRegistry::GetInstance()->IsURLAcceptableForWebUI(
342 controller_->GetBrowserContext(), entry.GetURL()); 352 controller_->GetBrowserContext(), entry.GetURL());
343 if ((enabled_bindings & BINDINGS_POLICY_WEB_UI) && 353 if ((enabled_bindings & BINDINGS_POLICY_WEB_UI) &&
344 !is_allowed_in_web_ui_renderer) { 354 !is_allowed_in_web_ui_renderer) {
345 // Log the URL to help us diagnose any future failures of this CHECK. 355 // Log the URL to help us diagnose any future failures of this CHECK.
346 GetContentClient()->SetActiveURL(entry.GetURL()); 356 GetContentClient()->SetActiveURL(entry.GetURL());
347 CHECK(0); 357 CHECK(0);
348 } 358 }
349 359
350 // Notify observers that we will navigate in this RenderFrame. 360 // Notify observers that we will navigate in this RenderFrame.
351 if (delegate_) 361 if (delegate_)
352 delegate_->AboutToNavigateRenderFrame(dest_render_frame_host); 362 delegate_->AboutToNavigateRenderFrame(dest_render_frame_host);
353 363
354 // Used for page load time metrics. 364 // WebContents uses this to fill LoadNotificationDetails when the load
365 // completes, so that PerformanceMonitor that listens to the notification can
366 // record the load time. PerformanceMonitor is no longer maintained.
367 // TODO(ppi): make this go away.
355 current_load_start_ = base::TimeTicks::Now(); 368 current_load_start_ = base::TimeTicks::Now();
356 369
357 // Navigate in the desired RenderFrameHost. 370 // Navigate in the desired RenderFrameHost.
358 FrameMsg_Navigate_Params navigate_params; 371 FrameMsg_Navigate_Params navigate_params;
359 MakeNavigateParams(entry, *controller_, reload_type, &navigate_params); 372 MakeNavigateParams(entry, *controller_, reload_type, navigation_start,
373 &navigate_params);
360 dest_render_frame_host->Navigate(navigate_params); 374 dest_render_frame_host->Navigate(navigate_params);
361 375
362 // 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.
363 CHECK_EQ(controller_->GetPendingEntry(), &entry); 377 CHECK_EQ(controller_->GetPendingEntry(), &entry);
364 378
365 if (entry.GetPageID() == -1) { 379 if (entry.GetPageID() == -1) {
366 // HACK!! This code suppresses javascript: URLs from being added to 380 // HACK!! This code suppresses javascript: URLs from being added to
367 // session history, which is what we want to do for javascript: URLs that 381 // session history, which is what we want to do for javascript: URLs that
368 // do not generate content. What we really need is a message from the 382 // do not generate content. What we really need is a message from the
369 // renderer telling us that a new page was not created. The same message 383 // renderer telling us that a new page was not created. The same message
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 647
634 // Navigations in Web UI pages count as browser-initiated navigations. 648 // Navigations in Web UI pages count as browser-initiated navigations.
635 params.is_renderer_initiated = false; 649 params.is_renderer_initiated = false;
636 } 650 }
637 651
638 if (delegate_) 652 if (delegate_)
639 delegate_->RequestOpenURL(render_frame_host, params); 653 delegate_->RequestOpenURL(render_frame_host, params);
640 } 654 }
641 655
642 } // namespace content 656 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/common/frame_messages.h » ('j') | content/common/frame_messages.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698