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

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

Powered by Google App Engine
This is Rietveld 408576698