| 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 "components/history/core/browser/history_database.h" | 5 #include "components/history/core/browser/history_database.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 #include "base/mac/mac_util.h" | 29 #include "base/mac/mac_util.h" |
| 30 #endif | 30 #endif |
| 31 | 31 |
| 32 namespace history { | 32 namespace history { |
| 33 | 33 |
| 34 namespace { | 34 namespace { |
| 35 | 35 |
| 36 // Current version number. We write databases at the "current" version number, | 36 // Current version number. We write databases at the "current" version number, |
| 37 // but any previous version that can read the "compatible" one can make do with | 37 // but any previous version that can read the "compatible" one can make do with |
| 38 // our database without *too* many bad effects. | 38 // our database without *too* many bad effects. |
| 39 const int kCurrentVersionNumber = 29; | 39 const int kCurrentVersionNumber = 30; |
| 40 const int kCompatibleVersionNumber = 16; | 40 const int kCompatibleVersionNumber = 16; |
| 41 const char kEarlyExpirationThresholdKey[] = "early_expiration_threshold"; | 41 const char kEarlyExpirationThresholdKey[] = "early_expiration_threshold"; |
| 42 const int kMaxHostsInMemory = 10000; | 42 const int kMaxHostsInMemory = 10000; |
| 43 | 43 |
| 44 } // namespace | 44 } // namespace |
| 45 | 45 |
| 46 HistoryDatabase::HistoryDatabase( | 46 HistoryDatabase::HistoryDatabase( |
| 47 DownloadInterruptReason download_interrupt_reason_none, | 47 DownloadInterruptReason download_interrupt_reason_none, |
| 48 DownloadInterruptReason download_interrupt_reason_crash) | 48 DownloadInterruptReason download_interrupt_reason_crash) |
| 49 : DownloadDatabase(download_interrupt_reason_none, | 49 : DownloadDatabase(download_interrupt_reason_none, |
| (...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 | 483 |
| 484 if (cur_version == 28) { | 484 if (cur_version == 28) { |
| 485 if (!MigrateMimeType()) { | 485 if (!MigrateMimeType()) { |
| 486 LOG(WARNING) << "Unable to migrate history to version 29"; | 486 LOG(WARNING) << "Unable to migrate history to version 29"; |
| 487 return sql::INIT_FAILURE; | 487 return sql::INIT_FAILURE; |
| 488 } | 488 } |
| 489 cur_version++; | 489 cur_version++; |
| 490 meta_table_.SetVersionNumber(cur_version); | 490 meta_table_.SetVersionNumber(cur_version); |
| 491 } | 491 } |
| 492 | 492 |
| 493 if (cur_version == 29) { |
| 494 if (!MigrateHashHttpMethodAndGenerateGuids()) { |
| 495 LOG(WARNING) << "Unable to migrate history to version 30"; |
| 496 return sql::INIT_FAILURE; |
| 497 } |
| 498 cur_version++; |
| 499 meta_table_.SetVersionNumber(cur_version); |
| 500 } |
| 501 |
| 493 // When the version is too old, we just try to continue anyway, there should | 502 // When the version is too old, we just try to continue anyway, there should |
| 494 // not be a released product that makes a database too old for us to handle. | 503 // not be a released product that makes a database too old for us to handle. |
| 495 LOG_IF(WARNING, cur_version < GetCurrentVersion()) << | 504 LOG_IF(WARNING, cur_version < GetCurrentVersion()) << |
| 496 "History database version " << cur_version << " is too old to handle."; | 505 "History database version " << cur_version << " is too old to handle."; |
| 497 | 506 |
| 498 return sql::INIT_OK; | 507 return sql::INIT_OK; |
| 499 } | 508 } |
| 500 | 509 |
| 501 #if !defined(OS_WIN) | 510 #if !defined(OS_WIN) |
| 502 void HistoryDatabase::MigrateTimeEpoch() { | 511 void HistoryDatabase::MigrateTimeEpoch() { |
| 503 // Update all the times in the URLs and visits table in the main database. | 512 // Update all the times in the URLs and visits table in the main database. |
| 504 ignore_result(db_.Execute( | 513 ignore_result(db_.Execute( |
| 505 "UPDATE urls " | 514 "UPDATE urls " |
| 506 "SET last_visit_time = last_visit_time + 11644473600000000 " | 515 "SET last_visit_time = last_visit_time + 11644473600000000 " |
| 507 "WHERE id IN (SELECT id FROM urls WHERE last_visit_time > 0);")); | 516 "WHERE id IN (SELECT id FROM urls WHERE last_visit_time > 0);")); |
| 508 ignore_result(db_.Execute( | 517 ignore_result(db_.Execute( |
| 509 "UPDATE visits " | 518 "UPDATE visits " |
| 510 "SET visit_time = visit_time + 11644473600000000 " | 519 "SET visit_time = visit_time + 11644473600000000 " |
| 511 "WHERE id IN (SELECT id FROM visits WHERE visit_time > 0);")); | 520 "WHERE id IN (SELECT id FROM visits WHERE visit_time > 0);")); |
| 512 ignore_result(db_.Execute( | 521 ignore_result(db_.Execute( |
| 513 "UPDATE segment_usage " | 522 "UPDATE segment_usage " |
| 514 "SET time_slot = time_slot + 11644473600000000 " | 523 "SET time_slot = time_slot + 11644473600000000 " |
| 515 "WHERE id IN (SELECT id FROM segment_usage WHERE time_slot > 0);")); | 524 "WHERE id IN (SELECT id FROM segment_usage WHERE time_slot > 0);")); |
| 516 } | 525 } |
| 517 #endif | 526 #endif |
| 518 | 527 |
| 519 } // namespace history | 528 } // namespace history |
| OLD | NEW |