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/url_database.h" | 5 #include "components/history/core/browser/url_database.h" |
6 | 6 |
7 #include <algorithm> | |
8 #include <limits> | 7 #include <limits> |
9 #include <string> | 8 #include <string> |
10 #include <vector> | 9 #include <vector> |
11 | 10 |
12 #include "base/i18n/case_conversion.h" | 11 #include "base/i18n/case_conversion.h" |
| 12 #include "base/memory/scoped_vector.h" |
13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
14 #include "chrome/common/url_constants.h" | 14 #include "components/history/core/browser/keyword_search_term.h" |
15 #include "net/base/net_util.h" | 15 #include "net/base/net_util.h" |
16 #include "sql/statement.h" | 16 #include "sql/statement.h" |
17 #include "ui/base/l10n/l10n_util.h" | |
18 #include "url/gurl.h" | 17 #include "url/gurl.h" |
19 | 18 |
20 namespace history { | 19 namespace history { |
21 | 20 |
22 const char URLDatabase::kURLRowFields[] = HISTORY_URL_ROW_FIELDS; | 21 const char URLDatabase::kURLRowFields[] = HISTORY_URL_ROW_FIELDS; |
23 const int URLDatabase::kNumURLRowFields = 9; | 22 const int URLDatabase::kNumURLRowFields = 9; |
24 | 23 |
25 URLDatabase::URLEnumeratorBase::URLEnumeratorBase() | 24 URLDatabase::URLEnumeratorBase::URLEnumeratorBase() |
26 : initialized_(false) { | 25 : initialized_(false) { |
27 } | 26 } |
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
609 "favicon_id INTEGER DEFAULT 0 NOT NULL)"); // favicon_id is not used now. | 608 "favicon_id INTEGER DEFAULT 0 NOT NULL)"); // favicon_id is not used now. |
610 | 609 |
611 return GetDB().Execute(sql.c_str()); | 610 return GetDB().Execute(sql.c_str()); |
612 } | 611 } |
613 | 612 |
614 bool URLDatabase::CreateMainURLIndex() { | 613 bool URLDatabase::CreateMainURLIndex() { |
615 return GetDB().Execute( | 614 return GetDB().Execute( |
616 "CREATE INDEX IF NOT EXISTS urls_url_index ON urls (url)"); | 615 "CREATE INDEX IF NOT EXISTS urls_url_index ON urls (url)"); |
617 } | 616 } |
618 | 617 |
| 618 const int kLowQualityMatchTypedLimit = 1; |
| 619 const int kLowQualityMatchVisitLimit = 4; |
| 620 const int kLowQualityMatchAgeLimitInDays = 3; |
| 621 |
| 622 base::Time AutocompleteAgeThreshold() { |
| 623 return (base::Time::Now() - |
| 624 base::TimeDelta::FromDays(kLowQualityMatchAgeLimitInDays)); |
| 625 } |
| 626 |
| 627 bool RowQualifiesAsSignificant(const URLRow& row, |
| 628 const base::Time& threshold) { |
| 629 const base::Time& real_threshold = |
| 630 threshold.is_null() ? AutocompleteAgeThreshold() : threshold; |
| 631 return (row.typed_count() >= kLowQualityMatchTypedLimit) || |
| 632 (row.visit_count() >= kLowQualityMatchVisitLimit) || |
| 633 (row.last_visit() >= real_threshold); |
| 634 } |
| 635 |
619 } // namespace history | 636 } // namespace history |
OLD | NEW |