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

Unified Diff: chrome/browser/history/visit_database.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 | « chrome/browser/history/history_backend.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/history/visit_database.cc
diff --git a/chrome/browser/history/visit_database.cc b/chrome/browser/history/visit_database.cc
index 48975b1015149e3c1cb88cf755bbab1a7c9a9afc..862d574a4146893731d63d89508f8341d2fc4f86 100644
--- a/chrome/browser/history/visit_database.cc
+++ b/chrome/browser/history/visit_database.cc
@@ -159,10 +159,21 @@ bool VisitDatabase::GetRowForVisit(VisitID visit_id, VisitRow* out_visit) {
return false;
FillVisitRow(*statement, out_visit);
+
+ // We got a different visit than we asked for, something is wrong.
+ DCHECK_EQ(visit_id, out_visit->visit_id);
+ if (visit_id != out_visit->visit_id)
+ return false;
+
return true;
}
bool VisitDatabase::UpdateVisitRow(const VisitRow& visit) {
+ // Don't store inconsistent data to the database.
+ DCHECK_NE(visit.visit_id, visit.referring_visit);
+ if (visit.visit_id == visit.referring_visit)
+ return false;
+
SQLITE_UNIQUE_STATEMENT(statement, GetStatementCache(),
"UPDATE visits SET "
"url=?,visit_time=?,from_visit=?,transition=?,segment_id=?,is_indexed=? "
« no previous file with comments | « chrome/browser/history/history_backend.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698