| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/base_paths.h" | 7 #include "base/base_paths.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 11 #include "base/memory/singleton.h" | 11 #include "base/memory/singleton.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
| 14 #include "base/path_service.h" | 14 #include "base/path_service.h" |
| 15 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
| 16 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
| 17 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
| 18 #include "chrome/common/chrome_constants.h" | 18 #include "chrome/common/chrome_constants.h" |
| 19 #include "chrome/common/chrome_paths.h" | 19 #include "chrome/common/chrome_paths.h" |
| 20 #include "chromeos/chromeos_constants.h" | 20 #include "chromeos/chromeos_constants.h" |
| 21 #include "components/webdata/common/webdata_constants.h" | 21 #include "components/webdata/common/webdata_constants.h" |
| 22 #include "content/public/common/content_constants.h" | 22 #include "content/public/common/content_constants.h" |
| 23 #include "sql/connection.h" | 23 #include "sql/connection.h" |
| 24 #include "sql/statement.h" | 24 #include "sql/statement.h" |
| 25 #include "third_party/sqlite/sqlite3.h" | 25 #include "third_party/sqlite/sqlite3.h" |
| 26 #include "webkit/browser/database/database_tracker.h" | 26 #include "webkit/browser/database/database_tracker.h" |
| 27 #include "webkit/common/appcache/appcache_interfaces.h" | |
| 28 | 27 |
| 29 namespace diagnostics { | 28 namespace diagnostics { |
| 30 | 29 |
| 31 namespace { | 30 namespace { |
| 32 | 31 |
| 33 // Generic diagnostic test class for checking SQLite database integrity. | 32 // Generic diagnostic test class for checking SQLite database integrity. |
| 34 class SqliteIntegrityTest : public DiagnosticsTest { | 33 class SqliteIntegrityTest : public DiagnosticsTest { |
| 35 public: | 34 public: |
| 36 // These are bit flags, so each value should be a power of two. | 35 // These are bit flags, so each value should be a power of two. |
| 37 enum Flags { | 36 enum Flags { |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 DISALLOW_COPY_AND_ASSIGN(ErrorRecorder); | 193 DISALLOW_COPY_AND_ASSIGN(ErrorRecorder); |
| 195 }; | 194 }; |
| 196 | 195 |
| 197 uint32 flags_; | 196 uint32 flags_; |
| 198 base::FilePath db_path_; | 197 base::FilePath db_path_; |
| 199 DISALLOW_COPY_AND_ASSIGN(SqliteIntegrityTest); | 198 DISALLOW_COPY_AND_ASSIGN(SqliteIntegrityTest); |
| 200 }; | 199 }; |
| 201 | 200 |
| 202 } // namespace | 201 } // namespace |
| 203 | 202 |
| 204 DiagnosticsTest* MakeSqliteAppCacheDbTest() { | |
| 205 base::FilePath appcache_dir(content::kAppCacheDirname); | |
| 206 base::FilePath appcache_db = | |
| 207 appcache_dir.Append(appcache::kAppCacheDatabaseName); | |
| 208 return new SqliteIntegrityTest(SqliteIntegrityTest::NO_FLAGS_SET, | |
| 209 DIAGNOSTICS_SQLITE_INTEGRITY_APP_CACHE_TEST, | |
| 210 appcache_db); | |
| 211 } | |
| 212 | |
| 213 DiagnosticsTest* MakeSqliteArchivedHistoryDbTest() { | 203 DiagnosticsTest* MakeSqliteArchivedHistoryDbTest() { |
| 214 return new SqliteIntegrityTest( | 204 return new SqliteIntegrityTest( |
| 215 SqliteIntegrityTest::NO_FLAGS_SET, | 205 SqliteIntegrityTest::NO_FLAGS_SET, |
| 216 DIAGNOSTICS_SQLITE_INTEGRITY_ARCHIVED_HISTORY_TEST, | 206 DIAGNOSTICS_SQLITE_INTEGRITY_ARCHIVED_HISTORY_TEST, |
| 217 base::FilePath(chrome::kArchivedHistoryFilename)); | 207 base::FilePath(chrome::kArchivedHistoryFilename)); |
| 218 } | 208 } |
| 219 | 209 |
| 220 DiagnosticsTest* MakeSqliteCookiesDbTest() { | 210 DiagnosticsTest* MakeSqliteCookiesDbTest() { |
| 221 return new SqliteIntegrityTest(SqliteIntegrityTest::CRITICAL, | 211 return new SqliteIntegrityTest(SqliteIntegrityTest::CRITICAL, |
| 222 DIAGNOSTICS_SQLITE_INTEGRITY_COOKIE_TEST, | 212 DIAGNOSTICS_SQLITE_INTEGRITY_COOKIE_TEST, |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 base::FilePath(chrome::kThumbnailsFilename)); | 253 base::FilePath(chrome::kThumbnailsFilename)); |
| 264 } | 254 } |
| 265 | 255 |
| 266 DiagnosticsTest* MakeSqliteWebDataDbTest() { | 256 DiagnosticsTest* MakeSqliteWebDataDbTest() { |
| 267 return new SqliteIntegrityTest(SqliteIntegrityTest::CRITICAL, | 257 return new SqliteIntegrityTest(SqliteIntegrityTest::CRITICAL, |
| 268 DIAGNOSTICS_SQLITE_INTEGRITY_WEB_DATA_TEST, | 258 DIAGNOSTICS_SQLITE_INTEGRITY_WEB_DATA_TEST, |
| 269 base::FilePath(kWebDataFilename)); | 259 base::FilePath(kWebDataFilename)); |
| 270 } | 260 } |
| 271 | 261 |
| 272 } // namespace diagnostics | 262 } // namespace diagnostics |
| OLD | NEW |