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

Side by Side Diff: chrome/browser/history/history_database.cc

Issue 319703002: Add mime type information to the download database (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix DownloadUIController_HistoryDownload test failure Created 6 years, 6 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
« no previous file with comments | « chrome/browser/history/download_row.cc ('k') | chrome/browser/history/history_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "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
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/file_util.h" 12 #include "base/file_util.h"
13 #include "base/metrics/histogram.h" 13 #include "base/metrics/histogram.h"
14 #include "base/rand_util.h" 14 #include "base/rand_util.h"
15 #include "base/strings/string_util.h" 15 #include "base/strings/string_util.h"
16 #include "base/time/time.h" 16 #include "base/time/time.h"
17 #include "sql/transaction.h" 17 #include "sql/transaction.h"
18 18
19 #if defined(OS_MACOSX) 19 #if defined(OS_MACOSX)
20 #include "base/mac/mac_util.h" 20 #include "base/mac/mac_util.h"
21 #endif 21 #endif
22 22
23 namespace history { 23 namespace history {
24 24
25 namespace { 25 namespace {
26 26
27 // Current version number. We write databases at the "current" version number, 27 // Current version number. We write databases at the "current" version number,
28 // but any previous version that can read the "compatible" one can make do with 28 // but any previous version that can read the "compatible" one can make do with
29 // our database without *too* many bad effects. 29 // our database without *too* many bad effects.
30 const int kCurrentVersionNumber = 28; 30 const int kCurrentVersionNumber = 29;
31 const int kCompatibleVersionNumber = 16; 31 const int kCompatibleVersionNumber = 16;
32 const char kEarlyExpirationThresholdKey[] = "early_expiration_threshold"; 32 const char kEarlyExpirationThresholdKey[] = "early_expiration_threshold";
33 33
34 } // namespace 34 } // namespace
35 35
36 HistoryDatabase::HistoryDatabase() { 36 HistoryDatabase::HistoryDatabase() {
37 } 37 }
38 38
39 HistoryDatabase::~HistoryDatabase() { 39 HistoryDatabase::~HistoryDatabase() {
40 } 40 }
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 415
416 if (cur_version == 27) { 416 if (cur_version == 27) {
417 if (!MigrateDownloadValidators()) { 417 if (!MigrateDownloadValidators()) {
418 LOG(WARNING) << "Unable to migrate history to version 28"; 418 LOG(WARNING) << "Unable to migrate history to version 28";
419 return sql::INIT_FAILURE; 419 return sql::INIT_FAILURE;
420 } 420 }
421 cur_version++; 421 cur_version++;
422 meta_table_.SetVersionNumber(cur_version); 422 meta_table_.SetVersionNumber(cur_version);
423 } 423 }
424 424
425 if (cur_version == 28) {
426 if (!MigrateMimeType()) {
427 LOG(WARNING) << "Unable to migrate history to version 29";
428 return sql::INIT_FAILURE;
429 }
430 cur_version++;
431 meta_table_.SetVersionNumber(cur_version);
432 }
433
425 // When the version is too old, we just try to continue anyway, there should 434 // When the version is too old, we just try to continue anyway, there should
426 // not be a released product that makes a database too old for us to handle. 435 // not be a released product that makes a database too old for us to handle.
427 LOG_IF(WARNING, cur_version < GetCurrentVersion()) << 436 LOG_IF(WARNING, cur_version < GetCurrentVersion()) <<
428 "History database version " << cur_version << " is too old to handle."; 437 "History database version " << cur_version << " is too old to handle.";
429 438
430 return sql::INIT_OK; 439 return sql::INIT_OK;
431 } 440 }
432 441
433 #if !defined(OS_WIN) 442 #if !defined(OS_WIN)
434 void HistoryDatabase::MigrateTimeEpoch() { 443 void HistoryDatabase::MigrateTimeEpoch() {
435 // Update all the times in the URLs and visits table in the main database. 444 // Update all the times in the URLs and visits table in the main database.
436 ignore_result(db_.Execute( 445 ignore_result(db_.Execute(
437 "UPDATE urls " 446 "UPDATE urls "
438 "SET last_visit_time = last_visit_time + 11644473600000000 " 447 "SET last_visit_time = last_visit_time + 11644473600000000 "
439 "WHERE id IN (SELECT id FROM urls WHERE last_visit_time > 0);")); 448 "WHERE id IN (SELECT id FROM urls WHERE last_visit_time > 0);"));
440 ignore_result(db_.Execute( 449 ignore_result(db_.Execute(
441 "UPDATE visits " 450 "UPDATE visits "
442 "SET visit_time = visit_time + 11644473600000000 " 451 "SET visit_time = visit_time + 11644473600000000 "
443 "WHERE id IN (SELECT id FROM visits WHERE visit_time > 0);")); 452 "WHERE id IN (SELECT id FROM visits WHERE visit_time > 0);"));
444 ignore_result(db_.Execute( 453 ignore_result(db_.Execute(
445 "UPDATE segment_usage " 454 "UPDATE segment_usage "
446 "SET time_slot = time_slot + 11644473600000000 " 455 "SET time_slot = time_slot + 11644473600000000 "
447 "WHERE id IN (SELECT id FROM segment_usage WHERE time_slot > 0);")); 456 "WHERE id IN (SELECT id FROM segment_usage WHERE time_slot > 0);"));
448 } 457 }
449 #endif 458 #endif
450 459
451 } // namespace history 460 } // namespace history
OLDNEW
« no previous file with comments | « chrome/browser/history/download_row.cc ('k') | chrome/browser/history/history_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698