| 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/sql/statement.h" | 7 #include "app/sql/statement.h" |
| 8 #include "app/sql/transaction.h" | 8 #include "app/sql/transaction.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| 11 #include "base/ref_counted_memory.h" | 11 #include "base/ref_counted_memory.h" |
| 12 #include "base/time.h" | 12 #include "base/time.h" |
| 13 #include "base/string_util.h" | 13 #include "base/string_util.h" |
| 14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
| 15 #include "chrome/browser/diagnostics/sqlite_diagnostics.h" | 15 #include "chrome/browser/diagnostics/sqlite_diagnostics.h" |
| 16 #include "chrome/browser/history/history_publisher.h" | 16 #include "chrome/browser/history/history_publisher.h" |
| 17 #include "chrome/browser/history/top_sites.h" | 17 #include "chrome/browser/history/top_sites.h" |
| 18 #include "chrome/browser/history/url_database.h" | 18 #include "chrome/browser/history/url_database.h" |
| 19 #include "chrome/common/chrome_switches.h" | 19 #include "chrome/common/chrome_switches.h" |
| 20 #include "chrome/common/thumbnail_score.h" | 20 #include "chrome/common/thumbnail_score.h" |
| 21 #include "gfx/codec/jpeg_codec.h" | 21 #include "gfx/codec/jpeg_codec.h" |
| 22 #include "third_party/skia/include/core/SkBitmap.h" | 22 #include "third_party/skia/include/core/SkBitmap.h" |
| 23 | 23 |
| 24 #if defined(OS_MACOSX) | 24 #if defined(OS_MACOSX) |
| 25 #include "base/mac_util.h" | 25 #include "base/mac/mac_util.h" |
| 26 #endif | 26 #endif |
| 27 | 27 |
| 28 namespace history { | 28 namespace history { |
| 29 | 29 |
| 30 // Version number of the database. | 30 // Version number of the database. |
| 31 static const int kCurrentVersionNumber = 3; | 31 static const int kCurrentVersionNumber = 3; |
| 32 static const int kCompatibleVersionNumber = 3; | 32 static const int kCompatibleVersionNumber = 3; |
| 33 | 33 |
| 34 ThumbnailDatabase::ThumbnailDatabase() : history_publisher_(NULL), | 34 ThumbnailDatabase::ThumbnailDatabase() : history_publisher_(NULL), |
| 35 use_top_sites_(false) { | 35 use_top_sites_(false) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 46 sql::InitStatus status = OpenDatabase(&db_, db_name); | 46 sql::InitStatus status = OpenDatabase(&db_, db_name); |
| 47 if (status != sql::INIT_OK) | 47 if (status != sql::INIT_OK) |
| 48 return status; | 48 return status; |
| 49 | 49 |
| 50 // Scope initialization in a transaction so we can't be partially initialized. | 50 // Scope initialization in a transaction so we can't be partially initialized. |
| 51 sql::Transaction transaction(&db_); | 51 sql::Transaction transaction(&db_); |
| 52 transaction.Begin(); | 52 transaction.Begin(); |
| 53 | 53 |
| 54 #if defined(OS_MACOSX) | 54 #if defined(OS_MACOSX) |
| 55 // Exclude the thumbnails file and its journal from backups. | 55 // Exclude the thumbnails file and its journal from backups. |
| 56 mac_util::SetFileBackupExclusion(db_name, true); | 56 base::mac::SetFileBackupExclusion(db_name, true); |
| 57 FilePath::StringType db_name_string(db_name.value()); | 57 FilePath::StringType db_name_string(db_name.value()); |
| 58 db_name_string += "-journal"; | 58 db_name_string += "-journal"; |
| 59 FilePath db_journal_name(db_name_string); | 59 FilePath db_journal_name(db_name_string); |
| 60 mac_util::SetFileBackupExclusion(db_journal_name, true); | 60 base::mac::SetFileBackupExclusion(db_journal_name, true); |
| 61 #endif | 61 #endif |
| 62 | 62 |
| 63 // Create the tables. | 63 // Create the tables. |
| 64 if (!meta_table_.Init(&db_, kCurrentVersionNumber, | 64 if (!meta_table_.Init(&db_, kCurrentVersionNumber, |
| 65 kCompatibleVersionNumber) || | 65 kCompatibleVersionNumber) || |
| 66 !InitThumbnailTable() || | 66 !InitThumbnailTable() || |
| 67 !InitFavIconsTable(&db_, false)) { | 67 !InitFavIconsTable(&db_, false)) { |
| 68 db_.Close(); | 68 db_.Close(); |
| 69 return sql::INIT_FAILURE; | 69 return sql::INIT_FAILURE; |
| 70 } | 70 } |
| (...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 541 | 541 |
| 542 InitFavIconsIndex(); | 542 InitFavIconsIndex(); |
| 543 | 543 |
| 544 // Reopen the transaction. | 544 // Reopen the transaction. |
| 545 BeginTransaction(); | 545 BeginTransaction(); |
| 546 use_top_sites_ = true; | 546 use_top_sites_ = true; |
| 547 return true; | 547 return true; |
| 548 } | 548 } |
| 549 | 549 |
| 550 } // namespace history | 550 } // namespace history |
| OLD | NEW |