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

Unified Diff: sql/connection.cc

Issue 104593010: AppCache: Run a quick integrity check on the sqlite database when opening. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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
Index: sql/connection.cc
diff --git a/sql/connection.cc b/sql/connection.cc
index 6e02cd755f56a31342f6291b4ae418303d5781c9..0caa9edc5b5e7bc4c93599509ed589f269b9baf1 100644
--- a/sql/connection.cc
+++ b/sql/connection.cc
@@ -1050,9 +1050,21 @@ int Connection::OnSqliteError(int err, sql::Statement *stmt, const char* sql) {
return err;
}
-// TODO(shess): Allow specifying integrity_check versus quick_check.
+bool Connection::FullIntegrityCheck(std::vector<std::string>* messages) {
+ return IntegrityCheckHelper("PRAGMA integrity_check", messages);
+}
+
+bool Connection::QuickIntegrityCheck() {
+ std::vector<std::string> messages;
+ if (!IntegrityCheckHelper("PRAGMA quick_check", &messages))
+ return false;
+ return messages.size() == 1 && messages[0] == "ok";
+}
+
// TODO(shess): Allow specifying maximum results (default 100 lines).
-bool Connection::IntegrityCheck(std::vector<std::string>* messages) {
+bool Connection::IntegrityCheckHelper(
+ const char* pragma_sql,
+ std::vector<std::string>* messages) {
messages->clear();
// This has the side effect of setting SQLITE_RecoveryMode, which
@@ -1065,8 +1077,7 @@ bool Connection::IntegrityCheck(std::vector<std::string>* messages) {
bool ret = false;
{
- const char kSql[] = "PRAGMA integrity_check";
- sql::Statement stmt(GetUniqueStatement(kSql));
+ sql::Statement stmt(GetUniqueStatement(pragma_sql));
// The pragma appears to return all results (up to 100 by default)
// as a single string. This doesn't appear to be an API contract,
« no previous file with comments | « sql/connection.h ('k') | sql/connection_unittest.cc » ('j') | sql/connection_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698