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

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

Powered by Google App Engine
This is Rietveld 408576698