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

Unified Diff: chrome/browser/history/history_backend.cc

Issue 206041: Some history backend fixes for database corruption. (Closed)
Patch Set: Update to use a set to track bigger referer loops. Created 11 years, 3 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
« no previous file with comments | « no previous file | chrome/browser/history/visit_database.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/history/history_backend.cc
diff --git a/chrome/browser/history/history_backend.cc b/chrome/browser/history/history_backend.cc
index cedc28b4b1fd1fbbbb5c0878fb753a48c287e6f1..eddf2d0e64dca0d3115f723c738c9b51fc74e01f 100644
--- a/chrome/browser/history/history_backend.cc
+++ b/chrome/browser/history/history_backend.cc
@@ -248,6 +248,9 @@ FilePath HistoryBackend::GetArchivedFileName() const {
}
SegmentID HistoryBackend::GetLastSegmentID(VisitID from_visit) {
+ // Set is used to detect referrer loops. Should not happen, but can
+ // if the database is corrupt.
+ std::set<VisitID> visit_set;
VisitID visit_id = from_visit;
while (visit_id) {
VisitRow row;
@@ -258,6 +261,12 @@ SegmentID HistoryBackend::GetLastSegmentID(VisitID from_visit) {
// Check the referrer of this visit, if any.
visit_id = row.referring_visit;
+
+ if (visit_set.find(visit_id) != visit_set.end()) {
+ NOTREACHED() << "Loop in referer chain, giving up";
+ break;
+ }
+ visit_set.insert(visit_id);
}
return 0;
}
« no previous file with comments | « no previous file | chrome/browser/history/visit_database.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698