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 "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/files/file_util.h" | 12 #include "base/files/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 "components/history/content/browser/download_constants_utils.h" |
| 18 #include "content/public/browser/download_interrupt_reasons.h" |
17 #include "sql/transaction.h" | 19 #include "sql/transaction.h" |
18 | 20 |
19 #if defined(OS_MACOSX) | 21 #if defined(OS_MACOSX) |
20 #include "base/mac/mac_util.h" | 22 #include "base/mac/mac_util.h" |
21 #endif | 23 #endif |
22 | 24 |
23 namespace history { | 25 namespace history { |
24 | 26 |
25 namespace { | 27 namespace { |
26 | 28 |
27 // Current version number. We write databases at the "current" version number, | 29 // 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 | 30 // but any previous version that can read the "compatible" one can make do with |
29 // our database without *too* many bad effects. | 31 // our database without *too* many bad effects. |
30 const int kCurrentVersionNumber = 29; | 32 const int kCurrentVersionNumber = 29; |
31 const int kCompatibleVersionNumber = 16; | 33 const int kCompatibleVersionNumber = 16; |
32 const char kEarlyExpirationThresholdKey[] = "early_expiration_threshold"; | 34 const char kEarlyExpirationThresholdKey[] = "early_expiration_threshold"; |
33 | 35 |
34 } // namespace | 36 } // namespace |
35 | 37 |
36 HistoryDatabase::HistoryDatabase() { | 38 HistoryDatabase::HistoryDatabase() |
| 39 : DownloadDatabase(ToHistoryDownloadInterruptReason( |
| 40 content::DOWNLOAD_INTERRUPT_REASON_NONE), |
| 41 ToHistoryDownloadInterruptReason( |
| 42 content::DOWNLOAD_INTERRUPT_REASON_CRASH)) { |
37 } | 43 } |
38 | 44 |
39 HistoryDatabase::~HistoryDatabase() { | 45 HistoryDatabase::~HistoryDatabase() { |
40 } | 46 } |
41 | 47 |
42 sql::InitStatus HistoryDatabase::Init(const base::FilePath& history_name) { | 48 sql::InitStatus HistoryDatabase::Init(const base::FilePath& history_name) { |
43 db_.set_histogram_tag("History"); | 49 db_.set_histogram_tag("History"); |
44 | 50 |
45 // Set the exceptional sqlite error handler. | 51 // Set the exceptional sqlite error handler. |
46 db_.set_error_callback(error_callback_); | 52 db_.set_error_callback(error_callback_); |
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 "SET visit_time = visit_time + 11644473600000000 " | 457 "SET visit_time = visit_time + 11644473600000000 " |
452 "WHERE id IN (SELECT id FROM visits WHERE visit_time > 0);")); | 458 "WHERE id IN (SELECT id FROM visits WHERE visit_time > 0);")); |
453 ignore_result(db_.Execute( | 459 ignore_result(db_.Execute( |
454 "UPDATE segment_usage " | 460 "UPDATE segment_usage " |
455 "SET time_slot = time_slot + 11644473600000000 " | 461 "SET time_slot = time_slot + 11644473600000000 " |
456 "WHERE id IN (SELECT id FROM segment_usage WHERE time_slot > 0);")); | 462 "WHERE id IN (SELECT id FROM segment_usage WHERE time_slot > 0);")); |
457 } | 463 } |
458 #endif | 464 #endif |
459 | 465 |
460 } // namespace history | 466 } // namespace history |
OLD | NEW |