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

Unified Diff: content/renderer/render_frame_impl.cc

Issue 743803002: Avoid stale navigation requests without excessive page id knowledge in the renderer process. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more saving Created 6 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 side-by-side diff with in-line comments
Download patch
Index: content/renderer/render_frame_impl.cc
diff --git a/content/renderer/render_frame_impl.cc b/content/renderer/render_frame_impl.cc
index a7a8d1396ae0f0731399c375323694d8291e38cc..00aed12de332000adfb52e920c76a3ae01a02933 100644
--- a/content/renderer/render_frame_impl.cc
+++ b/content/renderer/render_frame_impl.cc
@@ -947,35 +947,33 @@ void RenderFrameImpl::OnNavigate(const FrameMsg_Navigate_Params& params) {
TRACE_EVENT2("navigation", "RenderFrameImpl::OnNavigate",
"id", routing_id_,
"url", params.common_params.url.possibly_invalid_spec());
+
+ // If this is a stale back/forward (due to a recent navigation the browser
Charlie Reis 2014/12/03 23:48:07 Hmm, I wonder why clamy@ disabled the stale back/f
Avi (use Gerrit) 2014/12/04 21:15:16 Please do. Right now this code was built as a refa
Charlie Reis 2014/12/04 23:13:58 I emailed her to find out.
+ // didn't know about), ignore it. Only check if swapped in because navigations
+ // while swapped out are turned into asynchronous navigations.
Charlie Reis 2014/12/03 23:48:07 This comment is a little hard to follow. Asynchro
Avi (use Gerrit) 2014/12/04 21:15:16 That's what I meant, though I'm taking your word f
Charlie Reis 2014/12/04 23:13:58 Acknowledged.
+ bool is_history_navigation = params.commit_params.page_state.IsValid();
+ if (!render_view_->is_swapped_out() && is_history_navigation &&
+ render_view_->history_list_offset_ !=
+ params.current_history_list_offset) {
Charlie Reis 2014/12/03 23:48:07 Yes, I think this will be sufficient to replace th
Avi (use Gerrit) 2014/12/04 21:15:16 I'm trying to get things right the first time. I c
Charlie Reis 2014/12/04 23:13:58 Oh, here's an easy false positive, unless I'm misu
Avi (use Gerrit) 2014/12/05 22:16:39 I'd have to talk to you about that. The pruning is
Charlie Reis 2014/12/05 22:51:15 Yes. I may still be interested in improving the l
+ return;
+ }
+
bool is_reload =
RenderViewImpl::IsReload(params.common_params.navigation_type);
WebURLRequest::CachePolicy cache_policy =
WebURLRequest::UseProtocolCachePolicy;
if (!RenderFrameImpl::PrepareRenderViewForNavigation(
params.common_params.url, params.common_params.navigation_type,
- params.commit_params.page_state, true, params.pending_history_list_offset,
- params.page_id, &is_reload, &cache_policy)) {
+ params.commit_params.page_state, params.page_id, &is_reload,
+ &cache_policy)) {
return;
}
- int pending_history_list_offset = params.pending_history_list_offset;
Charlie Reis 2014/12/03 23:48:07 Do we ever still use pending_history_list_offset?
Avi (use Gerrit) 2014/12/04 21:15:16 We do, when history navigations commit. See the !i
- int current_history_list_offset = params.current_history_list_offset;
- int current_history_list_length = params.current_history_list_length;
+ 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(pending_history_list_offset, -1);
- CHECK_EQ(current_history_list_offset, -1);
- CHECK_EQ(current_history_list_length, 0);
- }
- render_view_->history_list_offset_ = current_history_list_offset;
- render_view_->history_list_length_ = current_history_list_length;
- if (render_view_->history_list_length_ >= 0) {
- render_view_->history_page_ids_.resize(
- render_view_->history_list_length_, -1);
- }
- if (pending_history_list_offset >= 0 &&
- pending_history_list_offset < render_view_->history_list_length_) {
- render_view_->history_page_ids_[pending_history_list_offset] =
- params.page_id;
+ CHECK_EQ(-1, render_view_->history_list_offset_);
+ CHECK_EQ(0, render_view_->history_list_length_);
}
GetContentClient()->SetActiveURL(params.common_params.url);
@@ -1013,7 +1011,7 @@ void RenderFrameImpl::OnNavigate(const FrameMsg_Navigate_Params& params) {
frame->reloadWithOverrideURL(params.common_params.url, true);
else
frame->reload(ignore_cache);
- } else if (params.commit_params.page_state.IsValid()) {
+ } 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);
scoped_ptr<HistoryEntry> entry =
@@ -2348,7 +2346,7 @@ void RenderFrameImpl::didCommitProvisionalLoad(
// We bump our Page ID to correspond with the new session history entry.
render_view_->page_id_ = render_view_->next_page_id_++;
- // Don't update history_page_ids_ (etc) for kSwappedOutURL, since
+ // Don't update history list values for kSwappedOutURL, since
// we don't want to forget the entry that was there, and since we will
// never come back to kSwappedOutURL. Note that we have to call
// UpdateSessionHistory and update page_id_ even in this case, so that
@@ -2362,10 +2360,6 @@ void RenderFrameImpl::didCommitProvisionalLoad(
render_view_->history_list_offset_ = kMaxSessionHistoryEntries - 1;
render_view_->history_list_length_ =
render_view_->history_list_offset_ + 1;
- render_view_->history_page_ids_.resize(
- render_view_->history_list_length_, -1);
- render_view_->history_page_ids_[render_view_->history_list_offset_] =
- render_view_->page_id_;
}
} else {
// Inspect the navigation_state on this frame to see if the navigation
@@ -2386,14 +2380,6 @@ void RenderFrameImpl::didCommitProvisionalLoad(
render_view_->history_list_offset_ =
navigation_state->pending_history_list_offset();
-
- // If the history list is valid, our list of page IDs should be correct.
- DCHECK(render_view_->history_list_length_ <= 0 ||
- render_view_->history_list_offset_ < 0 ||
- render_view_->history_list_offset_ >=
- render_view_->history_list_length_ ||
- render_view_->history_page_ids_[render_view_->history_list_offset_]
- == render_view_->page_id_);
}
}
@@ -3684,7 +3670,7 @@ void RenderFrameImpl::OnCommitNavigation(
WebURLRequest::UseProtocolCachePolicy;
if (!RenderFrameImpl::PrepareRenderViewForNavigation(
common_params.url, common_params.navigation_type,
- commit_params.page_state, false, -1, -1, &is_reload, &cache_policy)) {
+ commit_params.page_state, -1, &is_reload, &cache_policy)) {
return;
}
@@ -4106,8 +4092,6 @@ bool RenderFrameImpl::PrepareRenderViewForNavigation(
const GURL& url,
FrameMsg_Navigate_Type::Value navigate_type,
const PageState& state,
- bool check_history,
- int pending_history_list_offset,
int32 page_id,
bool* is_reload,
WebURLRequest::CachePolicy* cache_policy) {
@@ -4118,12 +4102,6 @@ bool RenderFrameImpl::PrepareRenderViewForNavigation(
FOR_EACH_OBSERVER(
RenderViewObserver, render_view_->observers_, Navigate(url));
- // If this is a stale back/forward (due to a recent navigation the browser
- // didn't know about), ignore it.
- if (check_history && render_view_->IsBackForwardToStaleEntry(
- state, pending_history_list_offset, page_id, *is_reload))
- return false;
-
if (!is_swapped_out_ || frame_->parent())
return true;

Powered by Google App Engine
This is Rietveld 408576698