| 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 "components/omnibox/browser/shortcuts_provider.h" | 5 #include "components/omnibox/browser/shortcuts_provider.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <cmath> | 10 #include <cmath> |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 } | 64 } |
| 65 } | 65 } |
| 66 | 66 |
| 67 void ShortcutsProvider::Start(const AutocompleteInput& input, | 67 void ShortcutsProvider::Start(const AutocompleteInput& input, |
| 68 bool minimal_changes) { | 68 bool minimal_changes) { |
| 69 TRACE_EVENT0("omnibox", "ShortcutsProvider::Start"); | 69 TRACE_EVENT0("omnibox", "ShortcutsProvider::Start"); |
| 70 matches_.clear(); | 70 matches_.clear(); |
| 71 | 71 |
| 72 if (input.from_omnibox_focus() || | 72 if (input.from_omnibox_focus() || |
| 73 (input.type() == metrics::OmniboxInputType::INVALID) || | 73 (input.type() == metrics::OmniboxInputType::INVALID) || |
| 74 (input.type() == metrics::OmniboxInputType::FORCED_QUERY) || | |
| 75 input.text().empty() || !initialized_) | 74 input.text().empty() || !initialized_) |
| 76 return; | 75 return; |
| 77 | 76 |
| 78 base::TimeTicks start_time = base::TimeTicks::Now(); | 77 base::TimeTicks start_time = base::TimeTicks::Now(); |
| 79 GetMatches(input); | 78 GetMatches(input); |
| 80 if (input.text().length() < 6) { | 79 if (input.text().length() < 6) { |
| 81 base::TimeTicks end_time = base::TimeTicks::Now(); | 80 base::TimeTicks end_time = base::TimeTicks::Now(); |
| 82 std::string name = "ShortcutsProvider.QueryIndexTime." + | 81 std::string name = "ShortcutsProvider.QueryIndexTime." + |
| 83 base::SizeTToString(input.text().size()); | 82 base::SizeTToString(input.text().size()); |
| 84 base::HistogramBase* counter = base::Histogram::FactoryGet( | 83 base::HistogramBase* counter = base::Histogram::FactoryGet( |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 const double kMaxDecaySpeedDivisor = 5.0; | 415 const double kMaxDecaySpeedDivisor = 5.0; |
| 417 const double kNumUsesPerDecaySpeedDivisorIncrement = 5.0; | 416 const double kNumUsesPerDecaySpeedDivisorIncrement = 5.0; |
| 418 double decay_divisor = std::min( | 417 double decay_divisor = std::min( |
| 419 kMaxDecaySpeedDivisor, | 418 kMaxDecaySpeedDivisor, |
| 420 (shortcut.number_of_hits + kNumUsesPerDecaySpeedDivisorIncrement - 1) / | 419 (shortcut.number_of_hits + kNumUsesPerDecaySpeedDivisorIncrement - 1) / |
| 421 kNumUsesPerDecaySpeedDivisorIncrement); | 420 kNumUsesPerDecaySpeedDivisorIncrement); |
| 422 | 421 |
| 423 return static_cast<int>((base_score / exp(decay_exponent / decay_divisor)) + | 422 return static_cast<int>((base_score / exp(decay_exponent / decay_divisor)) + |
| 424 0.5); | 423 0.5); |
| 425 } | 424 } |
| OLD | NEW |