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

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

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

Powered by Google App Engine
This is Rietveld 408576698