diff options
-rw-r--r-- | chrome/browser/history/thumbnail_database_unittest.cc | 10 | ||||
-rw-r--r-- | sql/recovery.cc | 10 | ||||
-rw-r--r-- | sql/recovery.h | 9 |
3 files changed, 29 insertions, 0 deletions
diff --git a/chrome/browser/history/thumbnail_database_unittest.cc b/chrome/browser/history/thumbnail_database_unittest.cc index bc1a25a..bb789a0 100644 --- a/chrome/browser/history/thumbnail_database_unittest.cc +++ b/chrome/browser/history/thumbnail_database_unittest.cc @@ -17,6 +17,7 @@ #include "chrome/common/chrome_paths.h" #include "chrome/test/base/testing_profile.h" #include "sql/connection.h" +#include "sql/recovery.h" // For FullRecoverySupported(). #include "sql/statement.h" #include "sql/test/scoped_error_ignorer.h" #include "sql/test/test_helpers.h" @@ -839,6 +840,15 @@ TEST_F(ThumbnailDatabaseTest, Version7) { } TEST_F(ThumbnailDatabaseTest, Recovery) { + // This code tests the recovery module in concert with Chromium's + // custom recover virtual table. Under USE_SYSTEM_SQLITE, this is + // not available. This is detected dynamically because corrupt + // databases still need to be handled, perhaps by Raze(), and the + // recovery module is an obvious layer to abstract that to. + // TODO(shess): Handle that case for real! + if (!sql::Recovery::FullRecoverySupported()) + return; + chrome::FaviconID id1, id2; GURL page_url1("http://www.google.com"); GURL page_url2("http://news.google.com"); diff --git a/sql/recovery.cc b/sql/recovery.cc index fc67661..c750fd0 100644 --- a/sql/recovery.cc +++ b/sql/recovery.cc @@ -13,6 +13,16 @@ namespace sql { // static +bool Recovery::FullRecoverySupported() { + // TODO(shess): See comment in Init(). +#if defined(USE_SYSTEM_SQLITE) + return false; +#else + return true; +#endif +} + +// static scoped_ptr<Recovery> Recovery::Begin( Connection* connection, const base::FilePath& db_path) { diff --git a/sql/recovery.h b/sql/recovery.h index e832da6..be23e97 100644 --- a/sql/recovery.h +++ b/sql/recovery.h @@ -41,6 +41,15 @@ class SQL_EXPORT Recovery { public: ~Recovery(); + // This module is intended to be used in concert with a virtual + // table module (see third_party/sqlite/src/src/recover.c). If the + // build defines USE_SYSTEM_SQLITE, this module will not be present. + // TODO(shess): I am still debating how to handle this - perhaps it + // will just imply Unrecoverable(). This is exposed to allow tests + // to adapt to the cases, please do not rely on it in production + // code. + static bool FullRecoverySupported(); + // Begin the recovery process by opening a temporary database handle // and attach the existing database to it at "corrupt". To prevent // deadlock, all transactions on |connection| are rolled back. |