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

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

Issue 102683004: Add mime type information to the download database (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review fixes Created 7 years 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 "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 // or database without *too* many bad effects. 29 // or 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 : needs_version_17_migration_(false) { 37 : needs_version_17_migration_(false) {
38 } 38 }
39 39
40 HistoryDatabase::~HistoryDatabase() { 40 HistoryDatabase::~HistoryDatabase() {
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 425
426 if (cur_version == 27) { 426 if (cur_version == 27) {
427 if (!MigrateDownloadValidators()) { 427 if (!MigrateDownloadValidators()) {
428 LOG(WARNING) << "Unable to migrate history to version 28"; 428 LOG(WARNING) << "Unable to migrate history to version 28";
429 return sql::INIT_FAILURE; 429 return sql::INIT_FAILURE;
430 } 430 }
431 cur_version++; 431 cur_version++;
432 meta_table_.SetVersionNumber(cur_version); 432 meta_table_.SetVersionNumber(cur_version);
433 } 433 }
434 434
435 if (cur_version == 28) {
436 if (!MigrateMimeType()) {
437 LOG(WARNING) << "Unable to migrate history to version 29";
438 return sql::INIT_FAILURE;
439 }
440 cur_version++;
441 meta_table_.SetVersionNumber(cur_version);
442 }
443
435 // When the version is too old, we just try to continue anyway, there should 444 // When the version is too old, we just try to continue anyway, there should
436 // not be a released product that makes a database too old for us to handle. 445 // not be a released product that makes a database too old for us to handle.
437 LOG_IF(WARNING, cur_version < GetCurrentVersion()) << 446 LOG_IF(WARNING, cur_version < GetCurrentVersion()) <<
438 "History database version " << cur_version << " is too old to handle."; 447 "History database version " << cur_version << " is too old to handle.";
439 448
440 return sql::INIT_OK; 449 return sql::INIT_OK;
441 } 450 }
442 451
443 #if !defined(OS_WIN) 452 #if !defined(OS_WIN)
444 void HistoryDatabase::MigrateTimeEpoch() { 453 void HistoryDatabase::MigrateTimeEpoch() {
(...skipping 12 matching lines...) Expand all
457 "WHERE id IN (SELECT id FROM segment_usage WHERE time_slot > 0);")); 466 "WHERE id IN (SELECT id FROM segment_usage WHERE time_slot > 0);"));
458 467
459 // Erase all the full text index files. These will take a while to update and 468 // Erase all the full text index files. These will take a while to update and
460 // are less important, so we just blow them away. Same with the archived 469 // are less important, so we just blow them away. Same with the archived
461 // database. 470 // database.
462 needs_version_17_migration_ = true; 471 needs_version_17_migration_ = true;
463 } 472 }
464 #endif 473 #endif
465 474
466 } // namespace history 475 } // namespace history
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698