| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/diagnostics/sqlite_diagnostics.h" | 5 #include "chrome/browser/diagnostics/sqlite_diagnostics.h" |
| 6 | 6 |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/memory/singleton.h" | 9 #include "base/memory/singleton.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 | 46 |
| 47 int errors = 0; | 47 int errors = 0; |
| 48 { // This block scopes the lifetime of the db objects. | 48 { // This block scopes the lifetime of the db objects. |
| 49 sql::Connection db; | 49 sql::Connection db; |
| 50 db.set_exclusive_locking(); | 50 db.set_exclusive_locking(); |
| 51 if (!db.Open(path)) { | 51 if (!db.Open(path)) { |
| 52 RecordFailure(ASCIIToUTF16("Cannot open DB. Possibly corrupted")); | 52 RecordFailure(ASCIIToUTF16("Cannot open DB. Possibly corrupted")); |
| 53 return true; | 53 return true; |
| 54 } | 54 } |
| 55 sql::Statement s(db.GetUniqueStatement("PRAGMA integrity_check;")); | 55 sql::Statement s(db.GetUniqueStatement("PRAGMA integrity_check;")); |
| 56 if (!s) { | 56 if (!s.is_valid()) { |
| 57 int error = db.GetErrorCode(); | 57 int error = db.GetErrorCode(); |
| 58 if (SQLITE_BUSY == error) { | 58 if (SQLITE_BUSY == error) { |
| 59 RecordFailure(ASCIIToUTF16("DB locked by another process")); | 59 RecordFailure(ASCIIToUTF16("DB locked by another process")); |
| 60 } else { | 60 } else { |
| 61 string16 str(ASCIIToUTF16("Pragma failed. Error: ")); | 61 string16 str(ASCIIToUTF16("Pragma failed. Error: ")); |
| 62 str += base::IntToString16(error); | 62 str += base::IntToString16(error); |
| 63 RecordFailure(str); | 63 RecordFailure(str); |
| 64 } | 64 } |
| 65 return false; | 65 return false; |
| 66 } | 66 } |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 appcache_db); | 158 appcache_db); |
| 159 } | 159 } |
| 160 | 160 |
| 161 DiagnosticTest* MakeSqliteWebDatabaseTrackerDbTest() { | 161 DiagnosticTest* MakeSqliteWebDatabaseTrackerDbTest() { |
| 162 FilePath databases_dir(webkit_database::kDatabaseDirectoryName); | 162 FilePath databases_dir(webkit_database::kDatabaseDirectoryName); |
| 163 FilePath tracker_db = | 163 FilePath tracker_db = |
| 164 databases_dir.Append(webkit_database::kTrackerDatabaseFileName); | 164 databases_dir.Append(webkit_database::kTrackerDatabaseFileName); |
| 165 return new SqliteIntegrityTest(false, ASCIIToUTF16("DatabaseTracker DB"), | 165 return new SqliteIntegrityTest(false, ASCIIToUTF16("DatabaseTracker DB"), |
| 166 tracker_db); | 166 tracker_db); |
| 167 } | 167 } |
| OLD | NEW |