| 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 = 20; | 31 static const int kCurrentVersionNumber = 21; |
| 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 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 } | 300 } |
| 301 | 301 |
| 302 if (cur_version == 19) { | 302 if (cur_version == 19) { |
| 303 cur_version++; | 303 cur_version++; |
| 304 meta_table_.SetVersionNumber(cur_version); | 304 meta_table_.SetVersionNumber(cur_version); |
| 305 // Set a key indicating we need to migrate thumbnails. When successfull the | 305 // Set a key indicating we need to migrate thumbnails. When successfull the |
| 306 // key is removed (ThumbnailMigrationDone). | 306 // key is removed (ThumbnailMigrationDone). |
| 307 meta_table_.SetValue(kNeedsThumbnailMigrationKey, 1); | 307 meta_table_.SetValue(kNeedsThumbnailMigrationKey, 1); |
| 308 } | 308 } |
| 309 | 309 |
| 310 if (cur_version == 20) { |
| 311 // This is the version prior to adding visit_details table. We need to |
| 312 // migrate the database. |
| 313 ++cur_version; |
| 314 meta_table_.SetVersionNumber(cur_version); |
| 315 } |
| 316 |
| 310 // When the version is too old, we just try to continue anyway, there should | 317 // When the version is too old, we just try to continue anyway, there should |
| 311 // not be a released product that makes a database too old for us to handle. | 318 // not be a released product that makes a database too old for us to handle. |
| 312 LOG_IF(WARNING, cur_version < GetCurrentVersion()) << | 319 LOG_IF(WARNING, cur_version < GetCurrentVersion()) << |
| 313 "History database version " << cur_version << " is too old to handle."; | 320 "History database version " << cur_version << " is too old to handle."; |
| 314 | 321 |
| 315 return sql::INIT_OK; | 322 return sql::INIT_OK; |
| 316 } | 323 } |
| 317 | 324 |
| 318 #if !defined(OS_WIN) | 325 #if !defined(OS_WIN) |
| 319 void HistoryDatabase::MigrateTimeEpoch() { | 326 void HistoryDatabase::MigrateTimeEpoch() { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 334 "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);")); |
| 335 | 342 |
| 336 // 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 |
| 337 // 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 |
| 338 // database. | 345 // database. |
| 339 needs_version_17_migration_ = true; | 346 needs_version_17_migration_ = true; |
| 340 } | 347 } |
| 341 #endif | 348 #endif |
| 342 | 349 |
| 343 } // namespace history | 350 } // namespace history |
| OLD | NEW |