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/autocomplete/shortcuts_provider.h" | 5 #include "chrome/browser/autocomplete/shortcuts_provider.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <map> | 9 #include <map> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/i18n/break_iterator.h" | 12 #include "base/i18n/break_iterator.h" |
13 #include "base/i18n/case_conversion.h" | 13 #include "base/i18n/case_conversion.h" |
14 #include "base/logging.h" | 14 #include "base/logging.h" |
15 #include "base/metrics/histogram.h" | 15 #include "base/metrics/histogram.h" |
| 16 #include "base/prefs/pref_service.h" |
16 #include "base/string_util.h" | 17 #include "base/string_util.h" |
17 #include "base/strings/string_number_conversions.h" | 18 #include "base/strings/string_number_conversions.h" |
18 #include "base/time.h" | 19 #include "base/time.h" |
19 #include "base/utf_string_conversions.h" | 20 #include "base/utf_string_conversions.h" |
20 #include "chrome/browser/autocomplete/autocomplete_input.h" | 21 #include "chrome/browser/autocomplete/autocomplete_input.h" |
21 #include "chrome/browser/autocomplete/autocomplete_provider_listener.h" | 22 #include "chrome/browser/autocomplete/autocomplete_provider_listener.h" |
22 #include "chrome/browser/autocomplete/autocomplete_result.h" | 23 #include "chrome/browser/autocomplete/autocomplete_result.h" |
23 #include "chrome/browser/history/history_notifications.h" | 24 #include "chrome/browser/history/history_notifications.h" |
24 #include "chrome/browser/history/history_service.h" | 25 #include "chrome/browser/history/history_service.h" |
25 #include "chrome/browser/history/history_service_factory.h" | 26 #include "chrome/browser/history/history_service_factory.h" |
26 #include "chrome/browser/history/shortcuts_backend_factory.h" | 27 #include "chrome/browser/history/shortcuts_backend_factory.h" |
27 #include "chrome/browser/prefs/pref_service.h" | |
28 #include "chrome/browser/profiles/profile.h" | 28 #include "chrome/browser/profiles/profile.h" |
29 #include "chrome/common/pref_names.h" | 29 #include "chrome/common/pref_names.h" |
30 #include "chrome/common/url_constants.h" | 30 #include "chrome/common/url_constants.h" |
31 #include "googleurl/src/url_parse.h" | 31 #include "googleurl/src/url_parse.h" |
32 | 32 |
33 namespace { | 33 namespace { |
34 | 34 |
35 class RemoveMatchPredicate { | 35 class RemoveMatchPredicate { |
36 public: | 36 public: |
37 explicit RemoveMatchPredicate(const std::set<GURL>& urls) | 37 explicit RemoveMatchPredicate(const std::set<GURL>& urls) |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 // (1.0 / each 5 additional hits), up to a maximum of 5x as long. | 347 // (1.0 / each 5 additional hits), up to a maximum of 5x as long. |
348 const double kMaxDecaySpeedDivisor = 5.0; | 348 const double kMaxDecaySpeedDivisor = 5.0; |
349 const double kNumUsesPerDecaySpeedDivisorIncrement = 5.0; | 349 const double kNumUsesPerDecaySpeedDivisorIncrement = 5.0; |
350 double decay_divisor = std::min(kMaxDecaySpeedDivisor, | 350 double decay_divisor = std::min(kMaxDecaySpeedDivisor, |
351 (shortcut.number_of_hits + kNumUsesPerDecaySpeedDivisorIncrement - 1) / | 351 (shortcut.number_of_hits + kNumUsesPerDecaySpeedDivisorIncrement - 1) / |
352 kNumUsesPerDecaySpeedDivisorIncrement); | 352 kNumUsesPerDecaySpeedDivisorIncrement); |
353 | 353 |
354 return static_cast<int>((base_score / exp(decay_exponent / decay_divisor)) + | 354 return static_cast<int>((base_score / exp(decay_exponent / decay_divisor)) + |
355 0.5); | 355 0.5); |
356 } | 356 } |
OLD | NEW |