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

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: use PreviewsState everywhere 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 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 327
328 // This will be used to set the Navigation Timing API navigationStart 328 // This will be used to set the Navigation Timing API navigationStart
329 // parameter for browser navigations in new tabs (intents, tabs opened through 329 // parameter for browser navigations in new tabs (intents, tabs opened through
330 // "Open link in new tab"). We need to keep it above RFHM::Navigate() call to 330 // "Open link in new tab"). We need to keep it above RFHM::Navigate() call to
331 // capture the time needed for the RenderFrameHost initialization. 331 // capture the time needed for the RenderFrameHost initialization.
332 base::TimeTicks navigation_start = base::TimeTicks::Now(); 332 base::TimeTicks navigation_start = base::TimeTicks::Now();
333 TRACE_EVENT_INSTANT_WITH_TIMESTAMP0( 333 TRACE_EVENT_INSTANT_WITH_TIMESTAMP0(
334 "navigation,rail", "NavigationTiming navigationStart", 334 "navigation,rail", "NavigationTiming navigationStart",
335 TRACE_EVENT_SCOPE_GLOBAL, navigation_start); 335 TRACE_EVENT_SCOPE_GLOBAL, navigation_start);
336 336
337 // Determine if LoFi should be used for the navigation. 337 // Determine if previews should be used for the navigation.
nasko 2016/12/12 23:05:41 nit: Previews
megjablon 2016/12/13 03:03:14 Done.
338 LoFiState lofi_state = LOFI_UNSPECIFIED; 338 PreviewsState previews_state = PREVIEWS_UNSPECIFIED;
339 if (!frame_tree_node->IsMainFrame()) { 339 if (!frame_tree_node->IsMainFrame()) {
340 // For subframes, use the state of the top-level frame. 340 // For subframes, use the state of the top-level frame.
341 lofi_state = frame_tree_node->frame_tree() 341 previews_state = frame_tree_node->frame_tree()
342 ->root() 342 ->root()
343 ->current_frame_host() 343 ->current_frame_host()
344 ->last_navigation_lofi_state(); 344 ->last_navigation_previews_state();
345 } else if (reload_type == ReloadType::DISABLE_LOFI_MODE) { 345 } else if (reload_type == ReloadType::DISABLE_LOFI_MODE) {
346 // Disable LoFi when asked for it explicitly. 346 // Disable LoFi when asked for it explicitly.
347 lofi_state = LOFI_OFF; 347 previews_state = PREVIEWS_OFF;
348 } 348 }
349 349
350 // PlzNavigate: the RenderFrameHosts are no longer asked to navigate. 350 // PlzNavigate: the RenderFrameHosts are no longer asked to navigate.
351 if (IsBrowserSideNavigationEnabled()) { 351 if (IsBrowserSideNavigationEnabled()) {
352 navigation_data_.reset(new NavigationMetricsData(navigation_start, dest_url, 352 navigation_data_.reset(new NavigationMetricsData(navigation_start, dest_url,
353 entry.restore_type())); 353 entry.restore_type()));
354 RequestNavigation(frame_tree_node, dest_url, dest_referrer, frame_entry, 354 RequestNavigation(frame_tree_node, dest_url, dest_referrer, frame_entry,
355 entry, reload_type, lofi_state, 355 entry, reload_type, previews_state,
356 is_same_document_history_load, 356 is_same_document_history_load,
357 is_history_navigation_in_new_child, navigation_start); 357 is_history_navigation_in_new_child, navigation_start);
358 if (frame_tree_node->IsMainFrame() && 358 if (frame_tree_node->IsMainFrame() &&
359 frame_tree_node->navigation_request()) { 359 frame_tree_node->navigation_request()) {
360 // TODO(carlosk): extend these traces to support subframes and 360 // TODO(carlosk): extend these traces to support subframes and
361 // non-PlzNavigate navigations. 361 // non-PlzNavigate navigations.
362 // For the trace below we're using the navigation handle as the async 362 // For the trace below we're using the navigation handle as the async
363 // trace id, |navigation_start| as the timestamp and reporting the 363 // trace id, |navigation_start| as the timestamp and reporting the
364 // FrameTreeNode id as a parameter. For navigations where no network 364 // FrameTreeNode id as a parameter. For navigations where no network
365 // request is made (data URLs, JavaScript URLs, etc) there is no handle 365 // request is made (data URLs, JavaScript URLs, etc) there is no handle
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 dest_render_frame_host->GetProcess()->GetID(); 415 dest_render_frame_host->GetProcess()->GetID();
416 if (!is_transfer_to_same) { 416 if (!is_transfer_to_same) {
417 navigation_data_.reset(new NavigationMetricsData( 417 navigation_data_.reset(new NavigationMetricsData(
418 navigation_start, dest_url, entry.restore_type())); 418 navigation_start, dest_url, entry.restore_type()));
419 // Create the navigation parameters. 419 // Create the navigation parameters.
420 FrameMsg_Navigate_Type::Value navigation_type = GetNavigationType( 420 FrameMsg_Navigate_Type::Value navigation_type = GetNavigationType(
421 controller_->GetBrowserContext(), entry, reload_type); 421 controller_->GetBrowserContext(), entry, reload_type);
422 dest_render_frame_host->Navigate( 422 dest_render_frame_host->Navigate(
423 entry.ConstructCommonNavigationParams( 423 entry.ConstructCommonNavigationParams(
424 frame_entry, post_body, dest_url, dest_referrer, navigation_type, 424 frame_entry, post_body, dest_url, dest_referrer, navigation_type,
425 lofi_state, navigation_start), 425 previews_state, navigation_start),
426 entry.ConstructStartNavigationParams(), 426 entry.ConstructStartNavigationParams(),
427 entry.ConstructRequestNavigationParams( 427 entry.ConstructRequestNavigationParams(
428 frame_entry, is_same_document_history_load, 428 frame_entry, is_same_document_history_load,
429 is_history_navigation_in_new_child, 429 is_history_navigation_in_new_child,
430 entry.GetSubframeUniqueNames(frame_tree_node), 430 entry.GetSubframeUniqueNames(frame_tree_node),
431 frame_tree_node->has_committed_real_load(), 431 frame_tree_node->has_committed_real_load(),
432 controller_->GetPendingEntryIndex() == -1, 432 controller_->GetPendingEntryIndex() == -1,
433 controller_->GetIndexOfEntry(&entry), 433 controller_->GetIndexOfEntry(&entry),
434 controller_->GetLastCommittedEntryIndex(), 434 controller_->GetLastCommittedEntryIndex(),
435 controller_->GetEntryCount())); 435 controller_->GetEntryCount()));
(...skipping 679 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