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

Unified Diff: content/renderer/render_view.cc

Issue 7618016: Additional fixes for prerender/instant + browsing history. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Minor comment fix Created 9 years, 4 months 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_view.cc
diff --git a/content/renderer/render_view.cc b/content/renderer/render_view.cc
index dd31fb7e922778713effed968a234cb92882269d..d720d59ab05f7b3d24bb93fd64a3bff96a59ddd0 100644
--- a/content/renderer/render_view.cc
+++ b/content/renderer/render_view.cc
@@ -704,8 +704,9 @@ bool RenderView::OnMessageReceived(const IPC::Message& message) {
#endif
IPC_MESSAGE_HANDLER(ViewMsg_UpdateRemoteAccessClientFirewallTraversal,
OnUpdateRemoteAccessClientFirewallTraversal)
- IPC_MESSAGE_HANDLER(ViewMsg_SetHistoryLengthAndClear,
- OnSetHistoryLengthAndClear)
+ IPC_MESSAGE_HANDLER(ViewMsg_SetHistoryLengthAndPrune,
+ OnSetHistoryLengthAndPrune)
+
// Have the super handle all other messages.
IPC_MESSAGE_UNHANDLED(handled = RenderWidget::OnMessageReceived(message))
IPC_END_MESSAGE_MAP()
@@ -993,6 +994,29 @@ void RenderView::OnSelectRange(const gfx::Point& start, const gfx::Point& end) {
handling_select_range_ = false;
}
+void RenderView::OnSetHistoryLengthAndPrune(int history_length,
+ int32 minimum_page_id) {
+ DCHECK(history_length >= 0);
+ DCHECK(minimum_page_id >= -1);
+
+ // Generate the new list.
+ std::vector<int32> new_history_page_ids(history_length, -1);
+ for (size_t i = 0; i < history_page_ids_.size(); ++i) {
+ DCHECK(history_page_ids_[i] >= 0);
+ if (minimum_page_id >= 0 && history_page_ids_[i] < minimum_page_id)
+ continue;
+ new_history_page_ids.push_back(history_page_ids_[i]);
+ }
+ new_history_page_ids.swap(history_page_ids_);
+
+ // Update indexes.
+ history_list_length_ = history_page_ids_.size();
+ // TODO(cbentzel): What do we do if the history_list_offset_ was not at
+ // the end of the list before?
+ history_list_offset_ = history_list_length_ - 1;
+}
+
+
void RenderView::OnSetInitialFocus(bool reverse) {
if (!webview())
return;
@@ -1020,32 +1044,6 @@ void RenderView::OnScrollFocusedEditableNodeIntoView() {
}
}
-void RenderView::OnSetHistoryLengthAndClear(int history_length) {
- DCHECK(history_length >= 0);
-
- // history_list_length_ may be 0 if this is called between
- // a navigate and a commit of the provisional load. Otherwise,
- // only add one entry, regardless of how long the current history is.
- // TODO(cbentzel): Investigate what happens if a prerendered page
- // navigates to several entries before it is swapped in. Cropping
- // those may be a bad idea.
- int new_history_list_length = history_length;
- if (history_list_length_ > 0)
- ++new_history_list_length;
-
- DCHECK(page_id_ == -1 ||
- (history_list_offset_ >= 0 &&
- page_id_ == history_page_ids_[history_list_offset_]));
-
- // Generate the new list.
- std::vector<int32> new_history_page_ids(new_history_list_length, -1);
- if (page_id_ != -1)
- new_history_page_ids[new_history_list_length - 1] = page_id_;
- new_history_page_ids.swap(history_page_ids_);
- history_list_offset_ = new_history_list_length - 1;
- history_list_length_ = new_history_list_length;
-}
-
///////////////////////////////////////////////////////////////////////////////
// Tell the embedding application that the URL of the active page has changed

Powered by Google App Engine
This is Rietveld 408576698