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/history_database.h" | 5 #include "chrome/browser/history/history_database.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 | |
11 #include "app/sql/transaction.h" | 10 #include "app/sql/transaction.h" |
12 #include "base/file_util.h" | 11 #include "base/file_util.h" |
| 12 #if defined(OS_MACOSX) |
| 13 #include "base/mac_util.h" |
| 14 #endif |
13 #include "base/histogram.h" | 15 #include "base/histogram.h" |
14 #include "base/rand_util.h" | 16 #include "base/rand_util.h" |
15 #include "base/string_util.h" | 17 #include "base/string_util.h" |
16 #include "chrome/browser/diagnostics/sqlite_diagnostics.h" | 18 #include "chrome/browser/diagnostics/sqlite_diagnostics.h" |
17 | 19 |
18 namespace history { | 20 namespace history { |
19 | 21 |
20 namespace { | 22 namespace { |
21 | 23 |
22 // Current version number. We write databases at the "current" version number, | 24 // Current version number. We write databases at the "current" version number, |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 | 83 |
82 if (!db_.Open(history_name)) | 84 if (!db_.Open(history_name)) |
83 return INIT_FAILURE; | 85 return INIT_FAILURE; |
84 | 86 |
85 // Wrap the rest of init in a tranaction. This will prevent the database from | 87 // Wrap the rest of init in a tranaction. This will prevent the database from |
86 // getting corrupted if we crash in the middle of initialization or migration. | 88 // getting corrupted if we crash in the middle of initialization or migration. |
87 sql::Transaction committer(&db_); | 89 sql::Transaction committer(&db_); |
88 if (!committer.Begin()) | 90 if (!committer.Begin()) |
89 return INIT_FAILURE; | 91 return INIT_FAILURE; |
90 | 92 |
| 93 #if defined(OS_MACOSX) |
| 94 // Exclude the history file and its journal from backups. |
| 95 mac_util::SetFileBackupExclusion(history_name, true); |
| 96 FilePath::StringType history_name_string(history_name.value()); |
| 97 history_name_string += "-journal"; |
| 98 FilePath history_journal_name(history_name_string); |
| 99 mac_util::SetFileBackupExclusion(history_journal_name, true); |
| 100 #endif |
| 101 |
91 // Prime the cache. | 102 // Prime the cache. |
92 db_.Preload(); | 103 db_.Preload(); |
93 | 104 |
94 // Create the tables and indices. | 105 // Create the tables and indices. |
95 // NOTE: If you add something here, also add it to | 106 // NOTE: If you add something here, also add it to |
96 // RecreateAllButStarAndURLTables. | 107 // RecreateAllButStarAndURLTables. |
97 if (!meta_table_.Init(&db_, kCurrentVersionNumber, kCompatibleVersionNumber)) | 108 if (!meta_table_.Init(&db_, kCurrentVersionNumber, kCompatibleVersionNumber)) |
98 return INIT_FAILURE; | 109 return INIT_FAILURE; |
99 if (!CreateURLTable(false) || !InitVisitTable() || | 110 if (!CreateURLTable(false) || !InitVisitTable() || |
100 !InitKeywordSearchTermsTable() || !InitDownloadTable() || | 111 !InitKeywordSearchTermsTable() || !InitDownloadTable() || |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 "WHERE id IN (SELECT id FROM segment_usage WHERE time_slot > 0);"); | 300 "WHERE id IN (SELECT id FROM segment_usage WHERE time_slot > 0);"); |
290 | 301 |
291 // Erase all the full text index files. These will take a while to update and | 302 // Erase all the full text index files. These will take a while to update and |
292 // are less important, so we just blow them away. Same with the archived | 303 // are less important, so we just blow them away. Same with the archived |
293 // database. | 304 // database. |
294 needs_version_17_migration_ = true; | 305 needs_version_17_migration_ = true; |
295 } | 306 } |
296 #endif | 307 #endif |
297 | 308 |
298 } // namespace history | 309 } // namespace history |
OLD | NEW |