Deprecate old Favicons database versions.

Histograms show a non-zero number of users with very old databases at
startup.  These old databases likely result from some sort of
corruption or filesystem problem, and are unlikely to spontaneously
progress forward.  Since the number of databases involved is very low
(<.03% of users), just delete them in hopes that that allows forward
progress.

Arbitrarily set a 2-year deprecation deadline for this database.  This
is a few weeks early, as version 5 landed on 2011-10-12.

BUG=240396

Review URL: https://codereview.chromium.org/24443002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@227433 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/sql/test/test_helpers.cc b/sql/test/test_helpers.cc
index 607f146af..20471dc 100644
--- a/sql/test/test_helpers.cc
+++ b/sql/test/test_helpers.cc
@@ -55,6 +55,20 @@
   return rows;
 }
 
+bool CountTableRows(sql::Connection* db, const char* table, size_t* count) {
+  // TODO(shess): Table should probably be quoted with [] or "".  See
+  // http://www.sqlite.org/lang_keywords.html .  Meanwhile, odd names
+  // will throw an error.
+  std::string sql = "SELECT COUNT(*) FROM ";
+  sql += table;
+  sql::Statement s(db->GetUniqueStatement(sql.c_str()));
+  if (!s.Step())
+    return false;
+
+  *count = s.ColumnInt64(0);
+  return true;
+}
+
 bool CreateDatabaseFromSQL(const base::FilePath& db_path,
                            const base::FilePath& sql_path) {
   if (base::PathExists(db_path) || !base::PathExists(sql_path))