OLD | NEW |
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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 | 324 |
325 // This will be used to set the Navigation Timing API navigationStart | 325 // This will be used to set the Navigation Timing API navigationStart |
326 // parameter for browser navigations in new tabs (intents, tabs opened through | 326 // parameter for browser navigations in new tabs (intents, tabs opened through |
327 // "Open link in new tab"). We need to keep it above RFHM::Navigate() call to | 327 // "Open link in new tab"). We need to keep it above RFHM::Navigate() call to |
328 // capture the time needed for the RenderFrameHost initialization. | 328 // capture the time needed for the RenderFrameHost initialization. |
329 base::TimeTicks navigation_start = base::TimeTicks::Now(); | 329 base::TimeTicks navigation_start = base::TimeTicks::Now(); |
330 TRACE_EVENT_INSTANT_WITH_TIMESTAMP0( | 330 TRACE_EVENT_INSTANT_WITH_TIMESTAMP0( |
331 "navigation,rail", "NavigationTiming navigationStart", | 331 "navigation,rail", "NavigationTiming navigationStart", |
332 TRACE_EVENT_SCOPE_GLOBAL, navigation_start); | 332 TRACE_EVENT_SCOPE_GLOBAL, navigation_start); |
333 | 333 |
334 // Determine if LoFi should be used for the navigation. | 334 // Determine if Previews should be used for the navigation. |
335 LoFiState lofi_state = LOFI_UNSPECIFIED; | 335 PreviewsState previews_state = PREVIEWS_UNSPECIFIED; |
336 if (!frame_tree_node->IsMainFrame()) { | 336 if (!frame_tree_node->IsMainFrame()) { |
337 // For subframes, use the state of the top-level frame. | 337 // For subframes, use the state of the top-level frame. |
338 lofi_state = frame_tree_node->frame_tree() | 338 previews_state = frame_tree_node->frame_tree() |
339 ->root() | 339 ->root() |
340 ->current_frame_host() | 340 ->current_frame_host() |
341 ->last_navigation_lofi_state(); | 341 ->last_navigation_previews_state(); |
342 } else if (reload_type == ReloadType::DISABLE_LOFI_MODE) { | 342 } else if (reload_type == ReloadType::DISABLE_LOFI_MODE) { |
343 // Disable LoFi when asked for it explicitly. | 343 // Disable LoFi when asked for it explicitly. |
344 lofi_state = LOFI_OFF; | 344 previews_state = PREVIEWS_OFF; |
345 } | 345 } |
346 | 346 |
347 // PlzNavigate: the RenderFrameHosts are no longer asked to navigate. | 347 // PlzNavigate: the RenderFrameHosts are no longer asked to navigate. |
348 if (IsBrowserSideNavigationEnabled()) { | 348 if (IsBrowserSideNavigationEnabled()) { |
349 navigation_data_.reset(new NavigationMetricsData(navigation_start, dest_url, | 349 navigation_data_.reset(new NavigationMetricsData(navigation_start, dest_url, |
350 entry.restore_type())); | 350 entry.restore_type())); |
351 RequestNavigation(frame_tree_node, dest_url, dest_referrer, frame_entry, | 351 RequestNavigation(frame_tree_node, dest_url, dest_referrer, frame_entry, |
352 entry, reload_type, lofi_state, | 352 entry, reload_type, previews_state, |
353 is_same_document_history_load, | 353 is_same_document_history_load, |
354 is_history_navigation_in_new_child, navigation_start); | 354 is_history_navigation_in_new_child, navigation_start); |
355 if (frame_tree_node->IsMainFrame() && | 355 if (frame_tree_node->IsMainFrame() && |
356 frame_tree_node->navigation_request()) { | 356 frame_tree_node->navigation_request()) { |
357 // TODO(carlosk): extend these traces to support subframes and | 357 // TODO(carlosk): extend these traces to support subframes and |
358 // non-PlzNavigate navigations. | 358 // non-PlzNavigate navigations. |
359 // For the trace below we're using the navigation handle as the async | 359 // For the trace below we're using the navigation handle as the async |
360 // trace id, |navigation_start| as the timestamp and reporting the | 360 // trace id, |navigation_start| as the timestamp and reporting the |
361 // FrameTreeNode id as a parameter. For navigations where no network | 361 // FrameTreeNode id as a parameter. For navigations where no network |
362 // request is made (data URLs, JavaScript URLs, etc) there is no handle | 362 // request is made (data URLs, JavaScript URLs, etc) there is no handle |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 dest_render_frame_host->GetProcess()->GetID(); | 412 dest_render_frame_host->GetProcess()->GetID(); |
413 if (!is_transfer_to_same) { | 413 if (!is_transfer_to_same) { |
414 navigation_data_.reset(new NavigationMetricsData( | 414 navigation_data_.reset(new NavigationMetricsData( |
415 navigation_start, dest_url, entry.restore_type())); | 415 navigation_start, dest_url, entry.restore_type())); |
416 // Create the navigation parameters. | 416 // Create the navigation parameters. |
417 FrameMsg_Navigate_Type::Value navigation_type = GetNavigationType( | 417 FrameMsg_Navigate_Type::Value navigation_type = GetNavigationType( |
418 controller_->GetBrowserContext(), entry, reload_type); | 418 controller_->GetBrowserContext(), entry, reload_type); |
419 dest_render_frame_host->Navigate( | 419 dest_render_frame_host->Navigate( |
420 entry.ConstructCommonNavigationParams( | 420 entry.ConstructCommonNavigationParams( |
421 frame_entry, post_body, dest_url, dest_referrer, navigation_type, | 421 frame_entry, post_body, dest_url, dest_referrer, navigation_type, |
422 lofi_state, navigation_start), | 422 previews_state, navigation_start), |
423 entry.ConstructStartNavigationParams(), | 423 entry.ConstructStartNavigationParams(), |
424 entry.ConstructRequestNavigationParams( | 424 entry.ConstructRequestNavigationParams( |
425 frame_entry, is_same_document_history_load, | 425 frame_entry, is_same_document_history_load, |
426 is_history_navigation_in_new_child, | 426 is_history_navigation_in_new_child, |
427 entry.GetSubframeUniqueNames(frame_tree_node), | 427 entry.GetSubframeUniqueNames(frame_tree_node), |
428 frame_tree_node->has_committed_real_load(), | 428 frame_tree_node->has_committed_real_load(), |
429 controller_->GetPendingEntryIndex() == -1, | 429 controller_->GetPendingEntryIndex() == -1, |
430 controller_->GetIndexOfEntry(&entry), | 430 controller_->GetIndexOfEntry(&entry), |
431 controller_->GetLastCommittedEntryIndex(), | 431 controller_->GetLastCommittedEntryIndex(), |
432 controller_->GetEntryCount())); | 432 controller_->GetEntryCount())); |
(...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1113 } | 1113 } |
1114 } | 1114 } |
1115 | 1115 |
1116 // PlzNavigate | 1116 // PlzNavigate |
1117 void NavigatorImpl::RequestNavigation(FrameTreeNode* frame_tree_node, | 1117 void NavigatorImpl::RequestNavigation(FrameTreeNode* frame_tree_node, |
1118 const GURL& dest_url, | 1118 const GURL& dest_url, |
1119 const Referrer& dest_referrer, | 1119 const Referrer& dest_referrer, |
1120 const FrameNavigationEntry& frame_entry, | 1120 const FrameNavigationEntry& frame_entry, |
1121 const NavigationEntryImpl& entry, | 1121 const NavigationEntryImpl& entry, |
1122 ReloadType reload_type, | 1122 ReloadType reload_type, |
1123 LoFiState lofi_state, | 1123 PreviewsState previews_state, |
1124 bool is_same_document_history_load, | 1124 bool is_same_document_history_load, |
1125 bool is_history_navigation_in_new_child, | 1125 bool is_history_navigation_in_new_child, |
1126 base::TimeTicks navigation_start) { | 1126 base::TimeTicks navigation_start) { |
1127 CHECK(IsBrowserSideNavigationEnabled()); | 1127 CHECK(IsBrowserSideNavigationEnabled()); |
1128 DCHECK(frame_tree_node); | 1128 DCHECK(frame_tree_node); |
1129 | 1129 |
1130 // This value must be set here because creating a NavigationRequest might | 1130 // This value must be set here because creating a NavigationRequest might |
1131 // change the renderer live/non-live status and change this result. | 1131 // change the renderer live/non-live status and change this result. |
1132 bool should_dispatch_beforeunload = | 1132 bool should_dispatch_beforeunload = |
1133 !is_same_document_history_load && | 1133 !is_same_document_history_load && |
1134 frame_tree_node->current_frame_host()->ShouldDispatchBeforeUnload(); | 1134 frame_tree_node->current_frame_host()->ShouldDispatchBeforeUnload(); |
1135 FrameMsg_Navigate_Type::Value navigation_type = | 1135 FrameMsg_Navigate_Type::Value navigation_type = |
1136 GetNavigationType(controller_->GetBrowserContext(), entry, reload_type); | 1136 GetNavigationType(controller_->GetBrowserContext(), entry, reload_type); |
1137 std::unique_ptr<NavigationRequest> scoped_request = | 1137 std::unique_ptr<NavigationRequest> scoped_request = |
1138 NavigationRequest::CreateBrowserInitiated( | 1138 NavigationRequest::CreateBrowserInitiated( |
1139 frame_tree_node, dest_url, dest_referrer, frame_entry, entry, | 1139 frame_tree_node, dest_url, dest_referrer, frame_entry, entry, |
1140 navigation_type, lofi_state, is_same_document_history_load, | 1140 navigation_type, previews_state, is_same_document_history_load, |
1141 is_history_navigation_in_new_child, navigation_start, controller_); | 1141 is_history_navigation_in_new_child, navigation_start, controller_); |
1142 NavigationRequest* navigation_request = scoped_request.get(); | 1142 NavigationRequest* navigation_request = scoped_request.get(); |
1143 | 1143 |
1144 // Navigation to a javascript URL is not a "real" navigation so there is no | 1144 // Navigation to a javascript URL is not a "real" navigation so there is no |
1145 // need to create a NavigationHandle. The navigation commits immediately and | 1145 // need to create a NavigationHandle. The navigation commits immediately and |
1146 // the NavigationRequest is not assigned to the FrameTreeNode as navigating to | 1146 // the NavigationRequest is not assigned to the FrameTreeNode as navigating to |
1147 // a Javascript URL should not interrupt a previous navigation. | 1147 // a Javascript URL should not interrupt a previous navigation. |
1148 // Note: The scoped_request will be destroyed at the end of this function. | 1148 // Note: The scoped_request will be destroyed at the end of this function. |
1149 if (dest_url.SchemeIs(url::kJavaScriptScheme)) { | 1149 if (dest_url.SchemeIs(url::kJavaScriptScheme)) { |
1150 RenderFrameHostImpl* render_frame_host = | 1150 RenderFrameHostImpl* render_frame_host = |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1265 if (navigation_handle) | 1265 if (navigation_handle) |
1266 navigation_handle->update_entry_id_for_transfer(entry->GetUniqueID()); | 1266 navigation_handle->update_entry_id_for_transfer(entry->GetUniqueID()); |
1267 | 1267 |
1268 controller_->SetPendingEntry(std::move(entry)); | 1268 controller_->SetPendingEntry(std::move(entry)); |
1269 if (delegate_) | 1269 if (delegate_) |
1270 delegate_->NotifyChangedNavigationState(content::INVALIDATE_TYPE_URL); | 1270 delegate_->NotifyChangedNavigationState(content::INVALIDATE_TYPE_URL); |
1271 } | 1271 } |
1272 } | 1272 } |
1273 | 1273 |
1274 } // namespace content | 1274 } // namespace content |
OLD | NEW |