| 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/history/thumbnail_database.h" | 5 #include "chrome/browser/history/thumbnail_database.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/debug/alias.h" | 11 #include "base/debug/alias.h" |
| 12 #include "base/debug/dump_without_crashing.h" |
| 12 #include "base/file_util.h" | 13 #include "base/file_util.h" |
| 13 #include "base/format_macros.h" | 14 #include "base/format_macros.h" |
| 14 #include "base/memory/ref_counted_memory.h" | 15 #include "base/memory/ref_counted_memory.h" |
| 15 #include "base/metrics/histogram.h" | 16 #include "base/metrics/histogram.h" |
| 16 #include "base/rand_util.h" | 17 #include "base/rand_util.h" |
| 17 #include "base/strings/string_util.h" | 18 #include "base/strings/string_util.h" |
| 18 #include "base/strings/stringprintf.h" | 19 #include "base/strings/stringprintf.h" |
| 19 #include "base/time/time.h" | 20 #include "base/time/time.h" |
| 20 #include "chrome/browser/history/url_database.h" | 21 #include "chrome/browser/history/url_database.h" |
| 21 #include "chrome/common/chrome_version_info.h" | 22 #include "chrome/common/chrome_version_info.h" |
| 22 #include "chrome/common/dump_without_crashing.h" | |
| 23 #include "sql/recovery.h" | 23 #include "sql/recovery.h" |
| 24 #include "sql/statement.h" | 24 #include "sql/statement.h" |
| 25 #include "sql/transaction.h" | 25 #include "sql/transaction.h" |
| 26 #include "third_party/sqlite/sqlite3.h" | 26 #include "third_party/sqlite/sqlite3.h" |
| 27 | 27 |
| 28 #if defined(OS_MACOSX) | 28 #if defined(OS_MACOSX) |
| 29 #include "base/mac/mac_util.h" | 29 #include "base/mac/mac_util.h" |
| 30 #endif | 30 #endif |
| 31 | 31 |
| 32 // Description of database tables: | 32 // Description of database tables: |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 UMA_HISTOGRAM_ENUMERATION("History.InvalidFaviconsDBStructure", | 114 UMA_HISTOGRAM_ENUMERATION("History.InvalidFaviconsDBStructure", |
| 115 invalid_type, STRUCTURE_EVENT_MAX); | 115 invalid_type, STRUCTURE_EVENT_MAX); |
| 116 } | 116 } |
| 117 | 117 |
| 118 // Attempt to pass 2000 bytes of |debug_info| into a crash dump. | 118 // Attempt to pass 2000 bytes of |debug_info| into a crash dump. |
| 119 void DumpWithoutCrashing2000(const std::string& debug_info) { | 119 void DumpWithoutCrashing2000(const std::string& debug_info) { |
| 120 char debug_buf[2000]; | 120 char debug_buf[2000]; |
| 121 base::strlcpy(debug_buf, debug_info.c_str(), arraysize(debug_buf)); | 121 base::strlcpy(debug_buf, debug_info.c_str(), arraysize(debug_buf)); |
| 122 base::debug::Alias(&debug_buf); | 122 base::debug::Alias(&debug_buf); |
| 123 | 123 |
| 124 logging::DumpWithoutCrashing(); | 124 base::debug::DumpWithoutCrashing(); |
| 125 } | 125 } |
| 126 | 126 |
| 127 void ReportCorrupt(sql::Connection* db, size_t startup_kb) { | 127 void ReportCorrupt(sql::Connection* db, size_t startup_kb) { |
| 128 // Buffer for accumulating debugging info about the error. Place | 128 // Buffer for accumulating debugging info about the error. Place |
| 129 // more-relevant information earlier, in case things overflow the | 129 // more-relevant information earlier, in case things overflow the |
| 130 // fixed-size buffer. | 130 // fixed-size buffer. |
| 131 std::string debug_info; | 131 std::string debug_info; |
| 132 | 132 |
| 133 base::StringAppendF(&debug_info, "SQLITE_CORRUPT, integrity_check:\n"); | 133 base::StringAppendF(&debug_info, "SQLITE_CORRUPT, integrity_check:\n"); |
| 134 | 134 |
| (...skipping 1291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1426 meta_table_.SetVersionNumber(7); | 1426 meta_table_.SetVersionNumber(7); |
| 1427 meta_table_.SetCompatibleVersionNumber(std::min(7, kCompatibleVersionNumber)); | 1427 meta_table_.SetCompatibleVersionNumber(std::min(7, kCompatibleVersionNumber)); |
| 1428 return true; | 1428 return true; |
| 1429 } | 1429 } |
| 1430 | 1430 |
| 1431 bool ThumbnailDatabase::IsFaviconDBStructureIncorrect() { | 1431 bool ThumbnailDatabase::IsFaviconDBStructureIncorrect() { |
| 1432 return !db_.IsSQLValid("SELECT id, url, icon_type FROM favicons"); | 1432 return !db_.IsSQLValid("SELECT id, url, icon_type FROM favicons"); |
| 1433 } | 1433 } |
| 1434 | 1434 |
| 1435 } // namespace history | 1435 } // namespace history |
| OLD | NEW |