summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authorclamy <clamy@chromium.org>2016-03-24 11:46:51 -0700
committerCommit bot <commit-bot@chromium.org>2016-03-24 18:48:33 +0000
commit53a76bcfcd9bcfb4507436e3d93ce7d26bad69fd (patch)
tree7a880b93e4f3dca88d83c6b530e86da88e76c14a /content
parent9cc6c874bc68353acbec895fcc79ef293d6e5f45 (diff)
downloadchromium_src-53a76bcfcd9bcfb4507436e3d93ce7d26bad69fd.zip
chromium_src-53a76bcfcd9bcfb4507436e3d93ce7d26bad69fd.tar.gz
chromium_src-53a76bcfcd9bcfb4507436e3d93ce7d26bad69fd.tar.bz2
PlzNavigate: fix LoFi test ShouldEnableLoFiModeNavigateBackThenForward
This CL fixes LoFiResourceDispatcherHostBrowserTest.ShouldEnableLoFiModeNavigateBackThenForward when run with PlzNavigate enabled. The RenderFrameHost keeps track of the LoFi state of the last successful network navigation, which allows to give the proper value to subframes that are doing a history navigation. Subframe history navigations do not go to the renderer when PlzNavigate is enabled, therefore the value of LoFi state for the top level frame must be kept on the browser side to give it to subframes. BUG=575212 CQ_INCLUDE_TRYBOTS=tryserver.chromium.linux:linux_site_isolation Review URL: https://codereview.chromium.org/1828663003 Cr-Commit-Position: refs/heads/master@{#383106}
Diffstat (limited to 'content')
-rw-r--r--content/browser/frame_host/navigator_impl.cc18
-rw-r--r--content/browser/frame_host/render_frame_host_impl.cc5
-rw-r--r--content/browser/frame_host/render_frame_host_impl.h11
3 files changed, 29 insertions, 5 deletions
diff --git a/content/browser/frame_host/navigator_impl.cc b/content/browser/frame_host/navigator_impl.cc
index dfce246..63b1510 100644
--- a/content/browser/frame_host/navigator_impl.cc
+++ b/content/browser/frame_host/navigator_impl.cc
@@ -291,11 +291,19 @@ bool NavigatorImpl::NavigateToEntry(
"navigation", "NavigationTiming navigationStart",
TRACE_EVENT_SCOPE_GLOBAL, navigation_start.ToInternalValue());
- LoFiState lofi_state =
- (reload_type ==
- NavigationController::ReloadType::RELOAD_DISABLE_LOFI_MODE)
- ? LOFI_OFF
- : LOFI_UNSPECIFIED;
+ // Determine if LoFi should be used for the navigation.
+ LoFiState lofi_state = LOFI_UNSPECIFIED;
+ if (!frame_tree_node->IsMainFrame()) {
+ // For subframes, use the state of the top-level frame.
+ lofi_state = frame_tree_node->frame_tree()
+ ->root()
+ ->current_frame_host()
+ ->last_navigation_lofi_state();
+ } else if (reload_type ==
+ NavigationController::ReloadType::RELOAD_DISABLE_LOFI_MODE) {
+ // Disable LoFi when asked for it explicitly.
+ lofi_state = LOFI_OFF;
+ }
// PlzNavigate: the RenderFrameHosts are no longer asked to navigate.
if (IsBrowserSideNavigationEnabled()) {
diff --git a/content/browser/frame_host/render_frame_host_impl.cc b/content/browser/frame_host/render_frame_host_impl.cc
index 337b03b..c600045 100644
--- a/content/browser/frame_host/render_frame_host_impl.cc
+++ b/content/browser/frame_host/render_frame_host_impl.cc
@@ -210,6 +210,7 @@ RenderFrameHostImpl::RenderFrameHostImpl(SiteInstance* site_instance,
pending_web_ui_type_(WebUI::kNoWebUI),
should_reuse_web_ui_(false),
is_in_commit_(false),
+ last_navigation_lofi_state_(LOFI_UNSPECIFIED),
weak_ptr_factory_(this) {
bool hidden = !!(flags & CREATE_RF_HIDDEN);
frame_tree_->AddRenderViewHostRef(render_view_host_);
@@ -2161,6 +2162,10 @@ void RenderFrameHostImpl::CommitNavigation(
Send(new FrameMsg_CommitNavigation(routing_id_, head, body_url, common_params,
request_params));
+ // If a network request was made, update the LoFi state.
+ if (ShouldMakeNetworkRequestForURL(common_params.url))
+ last_navigation_lofi_state_ = common_params.lofi_state;
+
// TODO(clamy): Release the stream handle once the renderer has finished
// reading it.
stream_handle_ = std::move(body);
diff --git a/content/browser/frame_host/render_frame_host_impl.h b/content/browser/frame_host/render_frame_host_impl.h
index 0bf26b9..9c44727 100644
--- a/content/browser/frame_host/render_frame_host_impl.h
+++ b/content/browser/frame_host/render_frame_host_impl.h
@@ -548,6 +548,12 @@ class CONTENT_EXPORT RenderFrameHostImpl : public RenderFrameHost,
// in a non-loading state.
void ResetLoadingState();
+ // PlzNavigate: returns the LoFi state of the last successful navigation that
+ // made a network request.
+ LoFiState last_navigation_lofi_state() const {
+ return last_navigation_lofi_state_;
+ }
+
protected:
friend class RenderFrameHostFactory;
@@ -934,6 +940,11 @@ class CONTENT_EXPORT RenderFrameHostImpl : public RenderFrameHost,
// TODO(clamy): Remove once enough data has been gathered.
bool is_in_commit_;
+ // PlzNavigate: The LoFi state of the last navigation. This is used during
+ // history navigation of subframes to ensure that subframes navigate with the
+ // same LoFi status as the top-level frame.
+ LoFiState last_navigation_lofi_state_;
+
// NOTE: This must be the last member.
base::WeakPtrFactory<RenderFrameHostImpl> weak_ptr_factory_;