diff options
author | clamy <clamy@chromium.org> | 2015-03-05 09:40:02 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-03-05 17:40:47 +0000 |
commit | cbe86a0c3963fa295521e10f94367e5a45378fd5 (patch) | |
tree | 180b151f1086b3f46d5e70154b216fc49fd0edf4 /content/renderer/render_frame_impl.cc | |
parent | e52ebffface82559ec1943c5e431661e0873cc7c (diff) | |
download | chromium_src-cbe86a0c3963fa295521e10f94367e5a45378fd5.zip chromium_src-cbe86a0c3963fa295521e10f94367e5a45378fd5.tar.gz chromium_src-cbe86a0c3963fa295521e10f94367e5a45378fd5.tar.bz2 |
PlzNavigate: send history params at commit time to the renderer
This CL introduces a new struct HistoryNavigationParams used in
FrameMsg_Navigate and FrameMsg_CommitNavigation. This allows to check for stale
backforward navigations when browser-side navigation is enabled.
BUG=376091
TBR=nasko@chromium.org
Review URL: https://codereview.chromium.org/979443002
Cr-Commit-Position: refs/heads/master@{#319276}
Diffstat (limited to 'content/renderer/render_frame_impl.cc')
-rw-r--r-- | content/renderer/render_frame_impl.cc | 64 |
1 files changed, 32 insertions, 32 deletions
diff --git a/content/renderer/render_frame_impl.cc b/content/renderer/render_frame_impl.cc index bceb2b5..d4910ca 100644 --- a/content/renderer/render_frame_impl.cc +++ b/content/renderer/render_frame_impl.cc @@ -1036,23 +1036,16 @@ void RenderFrameImpl::OnNavigate(const FrameMsg_Navigate_Params& params) { bool is_reload = RenderViewImpl::IsReload(params.common_params.navigation_type); - bool is_history_navigation = params.commit_params.page_state.IsValid(); + bool is_history_navigation = params.history_params.page_state.IsValid(); WebURLRequest::CachePolicy cache_policy = WebURLRequest::UseProtocolCachePolicy; if (!RenderFrameImpl::PrepareRenderViewForNavigation( - params.common_params.url, true, is_history_navigation, - params.current_history_list_offset, &is_reload, &cache_policy)) { + params.common_params.url, is_history_navigation, + params.history_params, &is_reload, &cache_policy)) { Send(new FrameHostMsg_DidDropNavigation(routing_id_)); return; } - render_view_->history_list_offset_ = params.current_history_list_offset; - render_view_->history_list_length_ = params.current_history_list_length; - if (params.should_clear_history_list) { - CHECK_EQ(-1, render_view_->history_list_offset_); - CHECK_EQ(0, render_view_->history_list_length_); - } - GetContentClient()->SetActiveURL(params.common_params.url); WebFrame* frame = frame_; @@ -1090,9 +1083,9 @@ void RenderFrameImpl::OnNavigate(const FrameMsg_Navigate_Params& params) { frame->reload(ignore_cache); } else if (is_history_navigation) { // We must know the page ID of the page we are navigating back to. - DCHECK_NE(params.page_id, -1); + DCHECK_NE(params.history_params.page_id, -1); scoped_ptr<HistoryEntry> entry = - PageStateToHistoryEntry(params.commit_params.page_state); + PageStateToHistoryEntry(params.history_params.page_state); if (entry) { // Ensure we didn't save the swapped out URL in UpdateState, since the // browser should never be telling us to navigate to swappedout://. @@ -1135,7 +1128,7 @@ void RenderFrameImpl::OnNavigate(const FrameMsg_Navigate_Params& params) { } // A session history navigation should have been accompanied by state. - CHECK_EQ(params.page_id, -1); + CHECK_EQ(params.history_params.page_id, -1); // Record this before starting the load, we need a lower bound of this time // to sanitize the navigationStart override set below. @@ -2418,18 +2411,18 @@ void RenderFrameImpl::didFailProvisionalLoad(blink::WebLocalFrame* frame, if (!navigation_state->is_content_initiated()) { render_view_->pending_navigation_params_.reset( new FrameMsg_Navigate_Params); - render_view_->pending_navigation_params_->page_id = + FrameMsg_Navigate_Params* pending_params = + render_view_->pending_navigation_params_.get(); + pending_params->history_params.page_id = navigation_state->pending_page_id(); - render_view_->pending_navigation_params_->pending_history_list_offset = + pending_params->history_params.pending_history_list_offset = navigation_state->pending_history_list_offset(); - render_view_->pending_navigation_params_->should_clear_history_list = + pending_params->history_params.should_clear_history_list = navigation_state->history_list_was_cleared(); - render_view_->pending_navigation_params_->common_params.transition = + pending_params->common_params.transition = navigation_state->transition_type(); - render_view_->pending_navigation_params_->request_time = - document_state->request_time(); - render_view_->pending_navigation_params_->should_replace_current_entry = - replace; + pending_params->request_time = document_state->request_time(); + pending_params->should_replace_current_entry = replace; } // Load an error page. @@ -3876,17 +3869,17 @@ void RenderFrameImpl::OnCommitNavigation( const ResourceResponseHead& response, const GURL& stream_url, const CommonNavigationParams& common_params, - const CommitNavigationParams& commit_params) { + const CommitNavigationParams& commit_params, + const HistoryNavigationParams& history_params) { CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( switches::kEnableBrowserSideNavigation)); bool is_reload = false; - bool is_history_navigation = commit_params.page_state.IsValid(); + bool is_history_navigation = history_params.page_state.IsValid(); WebURLRequest::CachePolicy cache_policy = WebURLRequest::UseProtocolCachePolicy; if (!RenderFrameImpl::PrepareRenderViewForNavigation( - common_params.url, false /* check_for_stale_navigation */, - is_history_navigation, -1 /* current_history_list_offset; TODO(clamy)*/, - &is_reload, &cache_policy)) { + common_params.url, is_history_navigation, history_params, &is_reload, + &cache_policy)) { return; } @@ -4314,9 +4307,8 @@ RenderFrameImpl::CreateRendererFactory() { bool RenderFrameImpl::PrepareRenderViewForNavigation( const GURL& url, - bool check_for_stale_navigation, bool is_history_navigation, - int current_history_list_offset, + const HistoryNavigationParams& history_params, bool* is_reload, WebURLRequest::CachePolicy* cache_policy) { MaybeHandleDebugURL(url); @@ -4329,13 +4321,21 @@ bool RenderFrameImpl::PrepareRenderViewForNavigation( // If this is a stale back/forward (due to a recent navigation the browser // didn't know about), ignore it. Only check if swapped in because if the // frame is swapped out, it won't commit before asking the browser. - // TODO(clamy): remove check_for_stale_navigation - if (check_for_stale_navigation && - !render_view_->is_swapped_out() && is_history_navigation && - render_view_->history_list_offset_ != current_history_list_offset) { + if (!render_view_->is_swapped_out() && is_history_navigation && + render_view_->history_list_offset_ != + history_params.current_history_list_offset) { return false; } + render_view_->history_list_offset_ = + history_params.current_history_list_offset; + render_view_->history_list_length_ = + history_params.current_history_list_length; + if (history_params.should_clear_history_list) { + CHECK_EQ(-1, render_view_->history_list_offset_); + CHECK_EQ(0, render_view_->history_list_length_); + } + if (!is_swapped_out_ || frame_->parent()) return true; |