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

Side by Side Diff: content/browser/tab_contents/navigation_controller.cc

Issue 7078002: Fix a crash where an index to a modified array wasn't always kept up to date. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/tab_contents/navigation_controller.h" 5 #include "content/browser/tab_contents/navigation_controller.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/time.h" 10 #include "base/time.h"
(...skipping 1070 matching lines...) Expand 10 before | Expand all | Expand 10 after
1081 if (pending_entry) 1081 if (pending_entry)
1082 entry->set_unique_id(pending_entry->unique_id()); 1082 entry->set_unique_id(pending_entry->unique_id());
1083 1083
1084 DiscardNonCommittedEntriesInternal(); 1084 DiscardNonCommittedEntriesInternal();
1085 1085
1086 int current_size = static_cast<int>(entries_.size()); 1086 int current_size = static_cast<int>(entries_.size());
1087 1087
1088 if (current_size > 0) { 1088 if (current_size > 0) {
1089 // Prune any entries which are in front of the current entry. 1089 // Prune any entries which are in front of the current entry.
1090 // Also prune the current entry if we are to replace the current entry. 1090 // Also prune the current entry if we are to replace the current entry.
1091 int prune_up_to = replace ? last_committed_entry_index_ - 1 1091 // last_committed_entry_index_ must be updated here since calls to
1092 : last_committed_entry_index_; 1092 // NotifyPrunedEntries() below may re-enter and we must make sure
1093 // last_committed_entry_index_ is not left in an invalid state.
1094 if (replace)
1095 --last_committed_entry_index_;
1096
1093 int num_pruned = 0; 1097 int num_pruned = 0;
1094 while (prune_up_to < (current_size - 1)) { 1098 while (last_committed_entry_index_ < (current_size - 1)) {
1095 num_pruned++; 1099 num_pruned++;
1096 entries_.pop_back(); 1100 entries_.pop_back();
1097 current_size--; 1101 current_size--;
1098 } 1102 }
1099 if (num_pruned > 0) // Only notify if we did prune something. 1103 if (num_pruned > 0) // Only notify if we did prune something.
1100 NotifyPrunedEntries(this, false, num_pruned); 1104 NotifyPrunedEntries(this, false, num_pruned);
1101 } 1105 }
1102 1106
1103 if (entries_.size() >= max_entry_count_) { 1107 if (entries_.size() >= max_entry_count_) {
1104 RemoveEntryAtIndex(0, GURL()); 1108 RemoveEntryAtIndex(0, GURL());
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
1238 size_t insert_index = 0; 1242 size_t insert_index = 0;
1239 for (int i = 0; i < max_index; i++) { 1243 for (int i = 0; i < max_index; i++) {
1240 // When cloning a tab, copy all entries except interstitial pages 1244 // When cloning a tab, copy all entries except interstitial pages
1241 if (source.entries_[i].get()->page_type() != INTERSTITIAL_PAGE) { 1245 if (source.entries_[i].get()->page_type() != INTERSTITIAL_PAGE) {
1242 entries_.insert(entries_.begin() + insert_index++, 1246 entries_.insert(entries_.begin() + insert_index++,
1243 linked_ptr<NavigationEntry>( 1247 linked_ptr<NavigationEntry>(
1244 new NavigationEntry(*source.entries_[i]))); 1248 new NavigationEntry(*source.entries_[i])));
1245 } 1249 }
1246 } 1250 }
1247 } 1251 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698