summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-02 18:47:56 +0000
committerpkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-02 18:47:56 +0000
commit855f5938dcec109083a32bdb48b81dce3692c1af (patch)
tree82dc5f7087d9bbe1cbe0fd7440f4d530fc3ec1d3
parent078e2f331254fe1a7cf12ad4de58f94a8f1c7c10 (diff)
downloadchromium_src-855f5938dcec109083a32bdb48b81dce3692c1af.zip
chromium_src-855f5938dcec109083a32bdb48b81dce3692c1af.tar.gz
chromium_src-855f5938dcec109083a32bdb48b81dce3692c1af.tar.bz2
Raze the database if the favicon table has an invalid structure
BUG=151841, 160360 Test=Manual, see below 1) Run chrome with the --user-data-dir= flag 2) Bookmark a couple pages 3) Open up the Favicons database using the "SQLite manager " add-on for Firefox (The Favicons database should be in the directory specified by --user-data-dir) 4) Delete the 'icon_type' column in the favicons table. 5) Run Chrome again and the bookmarks should be missing their favicons. However, upon clicking on the bookmarks, the favicons should come back. 6) Close Chrome and restart. The bookmarks whose favicons reappeared should still have their favicons. Review URL: https://chromiumcodereview.appspot.com/11606004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@174819 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/history/thumbnail_database.cc23
-rw-r--r--chrome/browser/history/thumbnail_database.h9
2 files changed, 19 insertions, 13 deletions
diff --git a/chrome/browser/history/thumbnail_database.cc b/chrome/browser/history/thumbnail_database.cc
index 118470f..af07679 100644
--- a/chrome/browser/history/thumbnail_database.cc
+++ b/chrome/browser/history/thumbnail_database.cc
@@ -198,9 +198,21 @@ sql::InitStatus ThumbnailDatabase::Init(
return sql::INIT_FAILURE;
}
- // Log in a UMA histogram if the structure of the favicons database is not
- // what it should be.
- LogIfFaviconDBStructureIncorrect();
+ // Raze the database if the structure of the favicons database is not what
+ // it should be. This error cannot be detected via the SQL error code because
+ // the error code for running SQL statements against a database with missing
+ // columns is SQLITE_ERROR which is not unique enough to act upon.
+ // TODO(pkotwicz): Revisit this in M27 and see if the razing can be removed.
+ // (crbug.com/166453)
+ if (IsFaviconDBStructureIncorrect()) {
+ LOG(ERROR) << "Raze thumbnail database because of invalid favicon db"
+ << "structure.";
+ UMA_HISTOGRAM_BOOLEAN("History.InvalidFaviconsDBStructure", true);
+
+ db_.Raze();
+ db_.Close();
+ return sql::INIT_FAILURE;
+ }
return sql::INIT_OK;
}
@@ -326,9 +338,8 @@ bool ThumbnailDatabase::InitFaviconBitmapsIndex() {
"favicon_bitmaps(icon_id)");
}
-void ThumbnailDatabase::LogIfFaviconDBStructureIncorrect() {
- if (!db_.IsSQLValid("SELECT id, url, icon_type, sizes FROM favicons"))
- UMA_HISTOGRAM_BOOLEAN("History.InvalidFaviconsDBStructure", true);
+bool ThumbnailDatabase::IsFaviconDBStructureIncorrect() {
+ return !db_.IsSQLValid("SELECT id, url, icon_type, sizes FROM favicons");
}
void ThumbnailDatabase::BeginTransaction() {
diff --git a/chrome/browser/history/thumbnail_database.h b/chrome/browser/history/thumbnail_database.h
index a95ad10..dffdc90 100644
--- a/chrome/browser/history/thumbnail_database.h
+++ b/chrome/browser/history/thumbnail_database.h
@@ -376,13 +376,8 @@ class ThumbnailDatabase {
// with no index).
bool InitIconMappingIndex();
- // For the purpose of determining how widespread crbug.com/151841 is, log in a
- // UMA histogram if the |favicons| database is missing a column. This is
- // important because the SQLite error code from running SQL statements against
- // a database with missing columns is SQLITE_ERROR which is not unique enough
- // to act upon.
- // TODO(pkotwicz): remove this function once crbug.com/151841 is resolved.
- void LogIfFaviconDBStructureIncorrect();
+ // Returns true if the |favicons| database is missing a column.
+ bool IsFaviconDBStructureIncorrect();
// Adds a mapping between the given page_url and icon_id; The mapping will be
// added to temp_icon_mapping table if is_temporary is true.