OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 10 matching lines...) Expand all Loading... |
21 #include "base/mac/mac_util.h" | 21 #include "base/mac/mac_util.h" |
22 #endif | 22 #endif |
23 | 23 |
24 namespace history { | 24 namespace history { |
25 | 25 |
26 namespace { | 26 namespace { |
27 | 27 |
28 // Current version number. We write databases at the "current" version number, | 28 // Current version number. We write databases at the "current" version number, |
29 // but any previous version that can read the "compatible" one can make do with | 29 // but any previous version that can read the "compatible" one can make do with |
30 // or database without *too* many bad effects. | 30 // or database without *too* many bad effects. |
31 static const int kCurrentVersionNumber = 21; | 31 static const int kCurrentVersionNumber = 22; |
32 static const int kCompatibleVersionNumber = 16; | 32 static const int kCompatibleVersionNumber = 16; |
33 static const char kEarlyExpirationThresholdKey[] = "early_expiration_threshold"; | 33 static const char kEarlyExpirationThresholdKey[] = "early_expiration_threshold"; |
34 | 34 |
35 // Key in the meta table used to determine if we need to migrate thumbnails out | 35 // Key in the meta table used to determine if we need to migrate thumbnails out |
36 // of history. | 36 // of history. |
37 static const char kNeedsThumbnailMigrationKey[] = "needs_thumbnail_migration"; | 37 static const char kNeedsThumbnailMigrationKey[] = "needs_thumbnail_migration"; |
38 | 38 |
39 void ComputeDatabaseMetrics(const FilePath& history_name, | 39 void ComputeDatabaseMetrics(const FilePath& history_name, |
40 sql::Connection& db) { | 40 sql::Connection& db) { |
41 if (base::RandInt(1, 100) != 50) | 41 if (base::RandInt(1, 100) != 50) |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 // This is the version prior to adding the visit_duration field in visits | 315 // This is the version prior to adding the visit_duration field in visits |
316 // database. We need to migrate the database. | 316 // database. We need to migrate the database. |
317 if (!MigrateVisitsWithoutDuration()) { | 317 if (!MigrateVisitsWithoutDuration()) { |
318 LOG(WARNING) << "Unable to update history database to version 21."; | 318 LOG(WARNING) << "Unable to update history database to version 21."; |
319 return sql::INIT_FAILURE; | 319 return sql::INIT_FAILURE; |
320 } | 320 } |
321 ++cur_version; | 321 ++cur_version; |
322 meta_table_.SetVersionNumber(cur_version); | 322 meta_table_.SetVersionNumber(cur_version); |
323 } | 323 } |
324 | 324 |
| 325 if (cur_version == 21) { |
| 326 // The android_urls table's data schemal was changed in version 21. |
| 327 #if defined(OS_ANDROID) |
| 328 if (!MigrateToVersion22()) { |
| 329 LOG(WARNING) << "Unable to migrate the android_urls table to version 22"; |
| 330 } |
| 331 #endif |
| 332 ++cur_version; |
| 333 meta_table_.SetVersionNumber(cur_version); |
| 334 } |
325 // When the version is too old, we just try to continue anyway, there should | 335 // When the version is too old, we just try to continue anyway, there should |
326 // not be a released product that makes a database too old for us to handle. | 336 // not be a released product that makes a database too old for us to handle. |
327 LOG_IF(WARNING, cur_version < GetCurrentVersion()) << | 337 LOG_IF(WARNING, cur_version < GetCurrentVersion()) << |
328 "History database version " << cur_version << " is too old to handle."; | 338 "History database version " << cur_version << " is too old to handle."; |
329 | 339 |
330 return sql::INIT_OK; | 340 return sql::INIT_OK; |
331 } | 341 } |
332 | 342 |
333 #if !defined(OS_WIN) | 343 #if !defined(OS_WIN) |
334 void HistoryDatabase::MigrateTimeEpoch() { | 344 void HistoryDatabase::MigrateTimeEpoch() { |
(...skipping 14 matching lines...) Expand all Loading... |
349 "WHERE id IN (SELECT id FROM segment_usage WHERE time_slot > 0);")); | 359 "WHERE id IN (SELECT id FROM segment_usage WHERE time_slot > 0);")); |
350 | 360 |
351 // Erase all the full text index files. These will take a while to update and | 361 // Erase all the full text index files. These will take a while to update and |
352 // are less important, so we just blow them away. Same with the archived | 362 // are less important, so we just blow them away. Same with the archived |
353 // database. | 363 // database. |
354 needs_version_17_migration_ = true; | 364 needs_version_17_migration_ = true; |
355 } | 365 } |
356 #endif | 366 #endif |
357 | 367 |
358 } // namespace history | 368 } // namespace history |
OLD | NEW |