| 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" |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 RECOVERY_EVENT_FAILED_META_INIT, | 414 RECOVERY_EVENT_FAILED_META_INIT, |
| 415 RECOVERY_EVENT_FAILED_META_VERSION, | 415 RECOVERY_EVENT_FAILED_META_VERSION, |
| 416 RECOVERY_EVENT_DEPRECATED, | 416 RECOVERY_EVENT_DEPRECATED, |
| 417 RECOVERY_EVENT_FAILED_V5_INITSCHEMA, | 417 RECOVERY_EVENT_FAILED_V5_INITSCHEMA, |
| 418 RECOVERY_EVENT_FAILED_V5_AUTORECOVER_FAVICONS, | 418 RECOVERY_EVENT_FAILED_V5_AUTORECOVER_FAVICONS, |
| 419 RECOVERY_EVENT_FAILED_V5_AUTORECOVER_ICON_MAPPING, | 419 RECOVERY_EVENT_FAILED_V5_AUTORECOVER_ICON_MAPPING, |
| 420 RECOVERY_EVENT_RECOVERED_VERSION5, | 420 RECOVERY_EVENT_RECOVERED_VERSION5, |
| 421 RECOVERY_EVENT_FAILED_AUTORECOVER_FAVICONS, | 421 RECOVERY_EVENT_FAILED_AUTORECOVER_FAVICONS, |
| 422 RECOVERY_EVENT_FAILED_AUTORECOVER_FAVICON_BITMAPS, | 422 RECOVERY_EVENT_FAILED_AUTORECOVER_FAVICON_BITMAPS, |
| 423 RECOVERY_EVENT_FAILED_AUTORECOVER_ICON_MAPPING, | 423 RECOVERY_EVENT_FAILED_AUTORECOVER_ICON_MAPPING, |
| 424 RECOVERY_EVENT_FAILED_COMMIT, |
| 424 | 425 |
| 425 // Always keep this at the end. | 426 // Always keep this at the end. |
| 426 RECOVERY_EVENT_MAX, | 427 RECOVERY_EVENT_MAX, |
| 427 }; | 428 }; |
| 428 | 429 |
| 429 void RecordRecoveryEvent(RecoveryEventType recovery_event) { | 430 void RecordRecoveryEvent(RecoveryEventType recovery_event) { |
| 430 UMA_HISTOGRAM_ENUMERATION("History.FaviconsRecovery", | 431 UMA_HISTOGRAM_ENUMERATION("History.FaviconsRecovery", |
| 431 recovery_event, RECOVERY_EVENT_MAX); | 432 recovery_event, RECOVERY_EVENT_MAX); |
| 432 } | 433 } |
| 433 | 434 |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 608 // TODO(shess): Is it possible/likely to have broken foreign-key | 609 // TODO(shess): Is it possible/likely to have broken foreign-key |
| 609 // issues with the tables? | 610 // issues with the tables? |
| 610 // - icon_mapping.icon_id maps to no favicons.id | 611 // - icon_mapping.icon_id maps to no favicons.id |
| 611 // - favicon_bitmaps.icon_id maps to no favicons.id | 612 // - favicon_bitmaps.icon_id maps to no favicons.id |
| 612 // - favicons.id is referenced by no icon_mapping.icon_id | 613 // - favicons.id is referenced by no icon_mapping.icon_id |
| 613 // - favicons.id is referenced by no favicon_bitmaps.icon_id | 614 // - favicons.id is referenced by no favicon_bitmaps.icon_id |
| 614 // This step is possibly not worth the effort necessary to develop | 615 // This step is possibly not worth the effort necessary to develop |
| 615 // and sequence the statements, as it is basically a form of garbage | 616 // and sequence the statements, as it is basically a form of garbage |
| 616 // collection. | 617 // collection. |
| 617 | 618 |
| 618 ignore_result(sql::Recovery::Recovered(recovery.Pass())); | 619 if (!sql::Recovery::Recovered(recovery.Pass())) { |
| 620 RecordRecoveryEvent(RECOVERY_EVENT_FAILED_COMMIT); |
| 621 return; |
| 622 } |
| 619 | 623 |
| 620 // Track the size of the recovered database relative to the size of | 624 // Track the size of the recovered database relative to the size of |
| 621 // the input database. The size should almost always be smaller, | 625 // the input database. The size should almost always be smaller, |
| 622 // unless the input database was empty to start with. If the | 626 // unless the input database was empty to start with. If the |
| 623 // percentage results are very low, something is awry. | 627 // percentage results are very low, something is awry. |
| 624 int64 final_size = 0; | 628 int64 final_size = 0; |
| 625 if (original_size > 0 && | 629 if (original_size > 0 && |
| 626 file_util::GetFileSize(db_path, &final_size) && | 630 file_util::GetFileSize(db_path, &final_size) && |
| 627 final_size > 0) { | 631 final_size > 0) { |
| 628 int percentage = static_cast<int>(original_size * 100 / final_size); | 632 int percentage = static_cast<int>(original_size * 100 / final_size); |
| (...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1423 meta_table_.SetVersionNumber(7); | 1427 meta_table_.SetVersionNumber(7); |
| 1424 meta_table_.SetCompatibleVersionNumber(std::min(7, kCompatibleVersionNumber)); | 1428 meta_table_.SetCompatibleVersionNumber(std::min(7, kCompatibleVersionNumber)); |
| 1425 return true; | 1429 return true; |
| 1426 } | 1430 } |
| 1427 | 1431 |
| 1428 bool ThumbnailDatabase::IsFaviconDBStructureIncorrect() { | 1432 bool ThumbnailDatabase::IsFaviconDBStructureIncorrect() { |
| 1429 return !db_.IsSQLValid("SELECT id, url, icon_type FROM favicons"); | 1433 return !db_.IsSQLValid("SELECT id, url, icon_type FROM favicons"); |
| 1430 } | 1434 } |
| 1431 | 1435 |
| 1432 } // namespace history | 1436 } // namespace history |
| OLD | NEW |