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 = 33; | 39 const int kCurrentVersionNumber = 34; |
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 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
535 cur_version++; | 535 cur_version++; |
536 meta_table_.SetVersionNumber(cur_version); | 536 meta_table_.SetVersionNumber(cur_version); |
537 } | 537 } |
538 | 538 |
539 if (cur_version == 32) { | 539 if (cur_version == 32) { |
540 // New download slices table is introduced, no migration needed. | 540 // New download slices table is introduced, no migration needed. |
541 cur_version++; | 541 cur_version++; |
542 meta_table_.SetVersionNumber(cur_version); | 542 meta_table_.SetVersionNumber(cur_version); |
543 } | 543 } |
544 | 544 |
| 545 if (cur_version == 33) { |
| 546 if (!MigrateDownloadLastAccessTime()) { |
| 547 LOG(WARNING) << "Unable to migrate to version 34"; |
| 548 return sql::INIT_FAILURE; |
| 549 } |
| 550 cur_version++; |
| 551 meta_table_.SetVersionNumber(cur_version); |
| 552 } |
| 553 |
545 // When the version is too old, we just try to continue anyway, there should | 554 // When the version is too old, we just try to continue anyway, there should |
546 // not be a released product that makes a database too old for us to handle. | 555 // not be a released product that makes a database too old for us to handle. |
547 LOG_IF(WARNING, cur_version < GetCurrentVersion()) << | 556 LOG_IF(WARNING, cur_version < GetCurrentVersion()) << |
548 "History database version " << cur_version << " is too old to handle."; | 557 "History database version " << cur_version << " is too old to handle."; |
549 | 558 |
550 return sql::INIT_OK; | 559 return sql::INIT_OK; |
551 } | 560 } |
552 | 561 |
553 #if !defined(OS_WIN) | 562 #if !defined(OS_WIN) |
554 void HistoryDatabase::MigrateTimeEpoch() { | 563 void HistoryDatabase::MigrateTimeEpoch() { |
555 // Update all the times in the URLs and visits table in the main database. | 564 // Update all the times in the URLs and visits table in the main database. |
556 ignore_result(db_.Execute( | 565 ignore_result(db_.Execute( |
557 "UPDATE urls " | 566 "UPDATE urls " |
558 "SET last_visit_time = last_visit_time + 11644473600000000 " | 567 "SET last_visit_time = last_visit_time + 11644473600000000 " |
559 "WHERE id IN (SELECT id FROM urls WHERE last_visit_time > 0);")); | 568 "WHERE id IN (SELECT id FROM urls WHERE last_visit_time > 0);")); |
560 ignore_result(db_.Execute( | 569 ignore_result(db_.Execute( |
561 "UPDATE visits " | 570 "UPDATE visits " |
562 "SET visit_time = visit_time + 11644473600000000 " | 571 "SET visit_time = visit_time + 11644473600000000 " |
563 "WHERE id IN (SELECT id FROM visits WHERE visit_time > 0);")); | 572 "WHERE id IN (SELECT id FROM visits WHERE visit_time > 0);")); |
564 ignore_result(db_.Execute( | 573 ignore_result(db_.Execute( |
565 "UPDATE segment_usage " | 574 "UPDATE segment_usage " |
566 "SET time_slot = time_slot + 11644473600000000 " | 575 "SET time_slot = time_slot + 11644473600000000 " |
567 "WHERE id IN (SELECT id FROM segment_usage WHERE time_slot > 0);")); | 576 "WHERE id IN (SELECT id FROM segment_usage WHERE time_slot > 0);")); |
568 } | 577 } |
569 #endif | 578 #endif |
570 | 579 |
571 } // namespace history | 580 } // namespace history |
OLD | NEW |