OLD | NEW |
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 Loading... |
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 Loading... |
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 } |
OLD | NEW |