OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #include "app/sql/transaction.h" | 10 #include "app/sql/transaction.h" |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/file_util.h" | 12 #include "base/file_util.h" |
13 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
14 #include "base/rand_util.h" | 14 #include "base/rand_util.h" |
15 #include "base/string_util.h" | 15 #include "base/string_util.h" |
16 #include "chrome/browser/diagnostics/sqlite_diagnostics.h" | 16 #include "chrome/browser/diagnostics/sqlite_diagnostics.h" |
17 #include "chrome/common/chrome_switches.h" | 17 #include "chrome/common/chrome_switches.h" |
18 | 18 |
19 #if defined(OS_MACOSX) | 19 #if defined(OS_MACOSX) |
20 #include "base/mac_util.h" | 20 #include "base/mac/mac_util.h" |
21 #endif | 21 #endif |
22 | 22 |
23 namespace history { | 23 namespace history { |
24 | 24 |
25 namespace { | 25 namespace { |
26 | 26 |
27 // Current version number. We write databases at the "current" version number, | 27 // Current version number. We write databases at the "current" version number, |
28 // but any previous version that can read the "compatible" one can make do with | 28 // but any previous version that can read the "compatible" one can make do with |
29 // or database without *too* many bad effects. | 29 // or database without *too* many bad effects. |
30 static const int kCurrentVersionNumber = 20; | 30 static const int kCurrentVersionNumber = 20; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 return sql::INIT_FAILURE; | 92 return sql::INIT_FAILURE; |
93 | 93 |
94 // Wrap the rest of init in a tranaction. This will prevent the database from | 94 // Wrap the rest of init in a tranaction. This will prevent the database from |
95 // getting corrupted if we crash in the middle of initialization or migration. | 95 // getting corrupted if we crash in the middle of initialization or migration. |
96 sql::Transaction committer(&db_); | 96 sql::Transaction committer(&db_); |
97 if (!committer.Begin()) | 97 if (!committer.Begin()) |
98 return sql::INIT_FAILURE; | 98 return sql::INIT_FAILURE; |
99 | 99 |
100 #if defined(OS_MACOSX) | 100 #if defined(OS_MACOSX) |
101 // Exclude the history file and its journal from backups. | 101 // Exclude the history file and its journal from backups. |
102 mac_util::SetFileBackupExclusion(history_name, true); | 102 base::mac::SetFileBackupExclusion(history_name, true); |
103 FilePath::StringType history_name_string(history_name.value()); | 103 FilePath::StringType history_name_string(history_name.value()); |
104 history_name_string += "-journal"; | 104 history_name_string += "-journal"; |
105 FilePath history_journal_name(history_name_string); | 105 FilePath history_journal_name(history_name_string); |
106 mac_util::SetFileBackupExclusion(history_journal_name, true); | 106 base::mac::SetFileBackupExclusion(history_journal_name, true); |
107 #endif | 107 #endif |
108 | 108 |
109 // Prime the cache. | 109 // Prime the cache. |
110 db_.Preload(); | 110 db_.Preload(); |
111 | 111 |
112 // Create the tables and indices. | 112 // Create the tables and indices. |
113 // NOTE: If you add something here, also add it to | 113 // NOTE: If you add something here, also add it to |
114 // RecreateAllButStarAndURLTables. | 114 // RecreateAllButStarAndURLTables. |
115 if (!meta_table_.Init(&db_, GetCurrentVersion(), kCompatibleVersionNumber)) | 115 if (!meta_table_.Init(&db_, GetCurrentVersion(), kCompatibleVersionNumber)) |
116 return sql::INIT_FAILURE; | 116 return sql::INIT_FAILURE; |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 "WHERE id IN (SELECT id FROM segment_usage WHERE time_slot > 0);"); | 341 "WHERE id IN (SELECT id FROM segment_usage WHERE time_slot > 0);"); |
342 | 342 |
343 // Erase all the full text index files. These will take a while to update and | 343 // Erase all the full text index files. These will take a while to update and |
344 // are less important, so we just blow them away. Same with the archived | 344 // are less important, so we just blow them away. Same with the archived |
345 // database. | 345 // database. |
346 needs_version_17_migration_ = true; | 346 needs_version_17_migration_ = true; |
347 } | 347 } |
348 #endif | 348 #endif |
349 | 349 |
350 } // namespace history | 350 } // namespace history |
OLD | NEW |