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 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
563 // autofill_model_type_state tables are introduced, no migration needed for | 563 // autofill_model_type_state tables are introduced, no migration needed for |
564 // those two tables. | 564 // those two tables. |
565 if (!RecreateURLTableWithAllContents()) { | 565 if (!RecreateURLTableWithAllContents()) { |
566 LOG(WARNING) << "Unable to update history database to version 35."; | 566 LOG(WARNING) << "Unable to update history database to version 35."; |
567 return sql::INIT_FAILURE; | 567 return sql::INIT_FAILURE; |
568 } | 568 } |
569 cur_version++; | 569 cur_version++; |
570 meta_table_.SetVersionNumber(cur_version); | 570 meta_table_.SetVersionNumber(cur_version); |
571 } | 571 } |
572 | 572 |
| 573 if (cur_version == 35) { |
| 574 if (!MigrateDownloadTransient()) { |
| 575 LOG(WARNING) << "Unable to migrate to version 35"; |
| 576 return sql::INIT_FAILURE; |
| 577 } |
| 578 cur_version++; |
| 579 meta_table_.SetVersionNumber(cur_version); |
| 580 } |
| 581 |
573 // When the version is too old, we just try to continue anyway, there should | 582 // When the version is too old, we just try to continue anyway, there should |
574 // not be a released product that makes a database too old for us to handle. | 583 // not be a released product that makes a database too old for us to handle. |
575 LOG_IF(WARNING, cur_version < GetCurrentVersion()) << | 584 LOG_IF(WARNING, cur_version < GetCurrentVersion()) << |
576 "History database version " << cur_version << " is too old to handle."; | 585 "History database version " << cur_version << " is too old to handle."; |
577 | 586 |
578 return sql::INIT_OK; | 587 return sql::INIT_OK; |
579 } | 588 } |
580 | 589 |
581 #if !defined(OS_WIN) | 590 #if !defined(OS_WIN) |
582 void HistoryDatabase::MigrateTimeEpoch() { | 591 void HistoryDatabase::MigrateTimeEpoch() { |
583 // Update all the times in the URLs and visits table in the main database. | 592 // Update all the times in the URLs and visits table in the main database. |
584 ignore_result(db_.Execute( | 593 ignore_result(db_.Execute( |
585 "UPDATE urls " | 594 "UPDATE urls " |
586 "SET last_visit_time = last_visit_time + 11644473600000000 " | 595 "SET last_visit_time = last_visit_time + 11644473600000000 " |
587 "WHERE id IN (SELECT id FROM urls WHERE last_visit_time > 0);")); | 596 "WHERE id IN (SELECT id FROM urls WHERE last_visit_time > 0);")); |
588 ignore_result(db_.Execute( | 597 ignore_result(db_.Execute( |
589 "UPDATE visits " | 598 "UPDATE visits " |
590 "SET visit_time = visit_time + 11644473600000000 " | 599 "SET visit_time = visit_time + 11644473600000000 " |
591 "WHERE id IN (SELECT id FROM visits WHERE visit_time > 0);")); | 600 "WHERE id IN (SELECT id FROM visits WHERE visit_time > 0);")); |
592 ignore_result(db_.Execute( | 601 ignore_result(db_.Execute( |
593 "UPDATE segment_usage " | 602 "UPDATE segment_usage " |
594 "SET time_slot = time_slot + 11644473600000000 " | 603 "SET time_slot = time_slot + 11644473600000000 " |
595 "WHERE id IN (SELECT id FROM segment_usage WHERE time_slot > 0);")); | 604 "WHERE id IN (SELECT id FROM segment_usage WHERE time_slot > 0);")); |
596 } | 605 } |
597 #endif | 606 #endif |
598 | 607 |
599 } // namespace history | 608 } // namespace history |
OLD | NEW |