| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "app/gfx/codec/jpeg_codec.h" | 7 #include "app/gfx/codec/jpeg_codec.h" |
| 8 #include "app/sql/statement.h" | 8 #include "app/sql/statement.h" |
| 9 #include "app/sql/transaction.h" | 9 #include "app/sql/transaction.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| 11 #if defined(OS_MACOSX) |
| 12 #include "base/mac_util.h" |
| 13 #endif |
| 11 #include "base/time.h" | 14 #include "base/time.h" |
| 12 #include "base/string_util.h" | 15 #include "base/string_util.h" |
| 13 #include "chrome/browser/diagnostics/sqlite_diagnostics.h" | 16 #include "chrome/browser/diagnostics/sqlite_diagnostics.h" |
| 14 #include "chrome/browser/history/history_publisher.h" | 17 #include "chrome/browser/history/history_publisher.h" |
| 15 #include "chrome/browser/history/url_database.h" | 18 #include "chrome/browser/history/url_database.h" |
| 16 #include "chrome/common/thumbnail_score.h" | 19 #include "chrome/common/thumbnail_score.h" |
| 17 #include "third_party/skia/include/core/SkBitmap.h" | 20 #include "third_party/skia/include/core/SkBitmap.h" |
| 18 | 21 |
| 19 namespace history { | 22 namespace history { |
| 20 | 23 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 // database while we're running, and this will give somewhat improved perf. | 59 // database while we're running, and this will give somewhat improved perf. |
| 57 db_.set_exclusive_locking(); | 60 db_.set_exclusive_locking(); |
| 58 | 61 |
| 59 if (!db_.Open(db_name)) | 62 if (!db_.Open(db_name)) |
| 60 return INIT_FAILURE; | 63 return INIT_FAILURE; |
| 61 | 64 |
| 62 // Scope initialization in a transaction so we can't be partially initialized. | 65 // Scope initialization in a transaction so we can't be partially initialized. |
| 63 sql::Transaction transaction(&db_); | 66 sql::Transaction transaction(&db_); |
| 64 transaction.Begin(); | 67 transaction.Begin(); |
| 65 | 68 |
| 69 #if defined(OS_MACOSX) |
| 70 // Exclude the thumbnails file and its journal from backups. |
| 71 mac_util::SetFileBackupExclusion(db_name, true); |
| 72 FilePath::StringType db_name_string(db_name.value()); |
| 73 db_name_string += "-journal"; |
| 74 FilePath db_journal_name(db_name_string); |
| 75 mac_util::SetFileBackupExclusion(db_journal_name, true); |
| 76 #endif |
| 77 |
| 66 // Create the tables. | 78 // Create the tables. |
| 67 if (!meta_table_.Init(&db_, kCurrentVersionNumber, | 79 if (!meta_table_.Init(&db_, kCurrentVersionNumber, |
| 68 kCompatibleVersionNumber) || | 80 kCompatibleVersionNumber) || |
| 69 !InitThumbnailTable() || | 81 !InitThumbnailTable() || |
| 70 !InitFavIconsTable(false)) { | 82 !InitFavIconsTable(false)) { |
| 71 db_.Close(); | 83 db_.Close(); |
| 72 return INIT_FAILURE; | 84 return INIT_FAILURE; |
| 73 } | 85 } |
| 74 InitFavIconsIndex(); | 86 InitFavIconsIndex(); |
| 75 | 87 |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 // Rename the temporary one. | 448 // Rename the temporary one. |
| 437 if (!db_.Execute("ALTER TABLE temp_favicons RENAME TO favicons")) | 449 if (!db_.Execute("ALTER TABLE temp_favicons RENAME TO favicons")) |
| 438 return false; | 450 return false; |
| 439 | 451 |
| 440 // The renamed table needs the index (the temporary table doesn't have one). | 452 // The renamed table needs the index (the temporary table doesn't have one). |
| 441 InitFavIconsIndex(); | 453 InitFavIconsIndex(); |
| 442 return true; | 454 return true; |
| 443 } | 455 } |
| 444 | 456 |
| 445 } // namespace history | 457 } // namespace history |
| OLD | NEW |