OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 | 10 |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 if (version_status != sql::INIT_OK) | 123 if (version_status != sql::INIT_OK) |
124 return version_status; | 124 return version_status; |
125 | 125 |
126 ComputeDatabaseMetrics(history_name, db_); | 126 ComputeDatabaseMetrics(history_name, db_); |
127 return committer.Commit() ? sql::INIT_OK : sql::INIT_FAILURE; | 127 return committer.Commit() ? sql::INIT_OK : sql::INIT_FAILURE; |
128 } | 128 } |
129 | 129 |
130 void HistoryDatabase::BeginExclusiveMode() { | 130 void HistoryDatabase::BeginExclusiveMode() { |
131 // We can't use set_exclusive_locking() since that only has an effect before | 131 // We can't use set_exclusive_locking() since that only has an effect before |
132 // the DB is opened. | 132 // the DB is opened. |
133 db_.Execute("PRAGMA locking_mode=EXCLUSIVE"); | 133 ignore_result(db_.Execute("PRAGMA locking_mode=EXCLUSIVE")); |
134 } | 134 } |
135 | 135 |
136 // static | 136 // static |
137 int HistoryDatabase::GetCurrentVersion() { | 137 int HistoryDatabase::GetCurrentVersion() { |
138 return kCurrentVersionNumber; | 138 return kCurrentVersionNumber; |
139 } | 139 } |
140 | 140 |
141 void HistoryDatabase::BeginTransaction() { | 141 void HistoryDatabase::BeginTransaction() { |
142 db_.BeginTransaction(); | 142 db_.BeginTransaction(); |
143 } | 143 } |
(...skipping 21 matching lines...) Expand all Loading... |
165 // We also add the supplementary URL indices at this point. This index is | 165 // We also add the supplementary URL indices at this point. This index is |
166 // over parts of the URL table that weren't automatically created when the | 166 // over parts of the URL table that weren't automatically created when the |
167 // temporary URL table was | 167 // temporary URL table was |
168 CreateKeywordSearchTermsIndices(); | 168 CreateKeywordSearchTermsIndices(); |
169 return true; | 169 return true; |
170 } | 170 } |
171 | 171 |
172 void HistoryDatabase::Vacuum() { | 172 void HistoryDatabase::Vacuum() { |
173 DCHECK_EQ(0, db_.transaction_nesting()) << | 173 DCHECK_EQ(0, db_.transaction_nesting()) << |
174 "Can not have a transaction when vacuuming."; | 174 "Can not have a transaction when vacuuming."; |
175 db_.Execute("VACUUM"); | 175 ignore_result(db_.Execute("VACUUM")); |
176 } | 176 } |
177 | 177 |
178 void HistoryDatabase::ThumbnailMigrationDone() { | 178 void HistoryDatabase::ThumbnailMigrationDone() { |
179 meta_table_.SetValue(kNeedsThumbnailMigrationKey, 0); | 179 meta_table_.SetValue(kNeedsThumbnailMigrationKey, 0); |
180 } | 180 } |
181 | 181 |
182 bool HistoryDatabase::GetNeedsThumbnailMigration() { | 182 bool HistoryDatabase::GetNeedsThumbnailMigration() { |
183 int value = 0; | 183 int value = 0; |
184 return (meta_table_.GetValue(kNeedsThumbnailMigrationKey, &value) && | 184 return (meta_table_.GetValue(kNeedsThumbnailMigrationKey, &value) && |
185 value != 0); | 185 value != 0); |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 "History database version " << cur_version << " is too old to handle."; | 316 "History database version " << cur_version << " is too old to handle."; |
317 | 317 |
318 return sql::INIT_OK; | 318 return sql::INIT_OK; |
319 } | 319 } |
320 | 320 |
321 #if !defined(OS_WIN) | 321 #if !defined(OS_WIN) |
322 void HistoryDatabase::MigrateTimeEpoch() { | 322 void HistoryDatabase::MigrateTimeEpoch() { |
323 // Update all the times in the URLs and visits table in the main database. | 323 // Update all the times in the URLs and visits table in the main database. |
324 // For visits, clear the indexed flag since we'll delete the FTS databases in | 324 // For visits, clear the indexed flag since we'll delete the FTS databases in |
325 // the next step. | 325 // the next step. |
326 db_.Execute( | 326 ignore_result(db_.Execute( |
327 "UPDATE urls " | 327 "UPDATE urls " |
328 "SET last_visit_time = last_visit_time + 11644473600000000 " | 328 "SET last_visit_time = last_visit_time + 11644473600000000 " |
329 "WHERE id IN (SELECT id FROM urls WHERE last_visit_time > 0);"); | 329 "WHERE id IN (SELECT id FROM urls WHERE last_visit_time > 0);")); |
330 db_.Execute( | 330 ignore_result(db_.Execute( |
331 "UPDATE visits " | 331 "UPDATE visits " |
332 "SET visit_time = visit_time + 11644473600000000, is_indexed = 0 " | 332 "SET visit_time = visit_time + 11644473600000000, is_indexed = 0 " |
333 "WHERE id IN (SELECT id FROM visits WHERE visit_time > 0);"); | 333 "WHERE id IN (SELECT id FROM visits WHERE visit_time > 0);")); |
334 db_.Execute( | 334 ignore_result(db_.Execute( |
335 "UPDATE segment_usage " | 335 "UPDATE segment_usage " |
336 "SET time_slot = time_slot + 11644473600000000 " | 336 "SET time_slot = time_slot + 11644473600000000 " |
337 "WHERE id IN (SELECT id FROM segment_usage WHERE time_slot > 0);"); | 337 "WHERE id IN (SELECT id FROM segment_usage WHERE time_slot > 0);")); |
338 | 338 |
339 // Erase all the full text index files. These will take a while to update and | 339 // Erase all the full text index files. These will take a while to update and |
340 // are less important, so we just blow them away. Same with the archived | 340 // are less important, so we just blow them away. Same with the archived |
341 // database. | 341 // database. |
342 needs_version_17_migration_ = true; | 342 needs_version_17_migration_ = true; |
343 } | 343 } |
344 #endif | 344 #endif |
345 | 345 |
346 } // namespace history | 346 } // namespace history |
OLD | NEW |