Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(271)

Side by Side Diff: components/history/core/browser/history_database.cc

Issue 1924473003: [Downloads] Use the initiating StoragePartition for resumption. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix typo in comment Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 = 31; 39 const int kCurrentVersionNumber = 32;
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 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 501
502 if (cur_version == 30) { 502 if (cur_version == 30) {
503 if (!MigrateDownloadTabUrl()) { 503 if (!MigrateDownloadTabUrl()) {
504 LOG(WARNING) << "Unable to migrate history to version 31"; 504 LOG(WARNING) << "Unable to migrate history to version 31";
505 return sql::INIT_FAILURE; 505 return sql::INIT_FAILURE;
506 } 506 }
507 cur_version++; 507 cur_version++;
508 meta_table_.SetVersionNumber(cur_version); 508 meta_table_.SetVersionNumber(cur_version);
509 } 509 }
510 510
511 if (cur_version == 31) {
512 if (!MigrateDownloadSiteInstanceUrl()) {
513 LOG(WARNING) << "Unable to migrate history to version 32";
514 return sql::INIT_FAILURE;
515 }
516 cur_version++;
517 meta_table_.SetVersionNumber(cur_version);
518 }
519
511 // When the version is too old, we just try to continue anyway, there should 520 // When the version is too old, we just try to continue anyway, there should
512 // not be a released product that makes a database too old for us to handle. 521 // not be a released product that makes a database too old for us to handle.
513 LOG_IF(WARNING, cur_version < GetCurrentVersion()) << 522 LOG_IF(WARNING, cur_version < GetCurrentVersion()) <<
514 "History database version " << cur_version << " is too old to handle."; 523 "History database version " << cur_version << " is too old to handle.";
515 524
516 return sql::INIT_OK; 525 return sql::INIT_OK;
517 } 526 }
518 527
519 #if !defined(OS_WIN) 528 #if !defined(OS_WIN)
520 void HistoryDatabase::MigrateTimeEpoch() { 529 void HistoryDatabase::MigrateTimeEpoch() {
521 // Update all the times in the URLs and visits table in the main database. 530 // Update all the times in the URLs and visits table in the main database.
522 ignore_result(db_.Execute( 531 ignore_result(db_.Execute(
523 "UPDATE urls " 532 "UPDATE urls "
524 "SET last_visit_time = last_visit_time + 11644473600000000 " 533 "SET last_visit_time = last_visit_time + 11644473600000000 "
525 "WHERE id IN (SELECT id FROM urls WHERE last_visit_time > 0);")); 534 "WHERE id IN (SELECT id FROM urls WHERE last_visit_time > 0);"));
526 ignore_result(db_.Execute( 535 ignore_result(db_.Execute(
527 "UPDATE visits " 536 "UPDATE visits "
528 "SET visit_time = visit_time + 11644473600000000 " 537 "SET visit_time = visit_time + 11644473600000000 "
529 "WHERE id IN (SELECT id FROM visits WHERE visit_time > 0);")); 538 "WHERE id IN (SELECT id FROM visits WHERE visit_time > 0);"));
530 ignore_result(db_.Execute( 539 ignore_result(db_.Execute(
531 "UPDATE segment_usage " 540 "UPDATE segment_usage "
532 "SET time_slot = time_slot + 11644473600000000 " 541 "SET time_slot = time_slot + 11644473600000000 "
533 "WHERE id IN (SELECT id FROM segment_usage WHERE time_slot > 0);")); 542 "WHERE id IN (SELECT id FROM segment_usage WHERE time_slot > 0);"));
534 } 543 }
535 #endif 544 #endif
536 545
537 } // namespace history 546 } // namespace history
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698