| 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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 name, 1, 1000, 50, base::Histogram::kUmaTargetedHistogramFlag); | 129 name, 1, 1000, 50, base::Histogram::kUmaTargetedHistogramFlag); |
| 130 counter->Add(static_cast<int>((end_time - start_time).InMilliseconds())); | 130 counter->Add(static_cast<int>((end_time - start_time).InMilliseconds())); |
| 131 } | 131 } |
| 132 } | 132 } |
| 133 | 133 |
| 134 void ShortcutsProvider::DeleteMatch(const AutocompleteMatch& match) { | 134 void ShortcutsProvider::DeleteMatch(const AutocompleteMatch& match) { |
| 135 // Copy the URL since deleting from |matches_| will invalidate |match|. | 135 // Copy the URL since deleting from |matches_| will invalidate |match|. |
| 136 GURL url(match.destination_url); | 136 GURL url(match.destination_url); |
| 137 DCHECK(url.is_valid()); | 137 DCHECK(url.is_valid()); |
| 138 | 138 |
| 139 // When a user deletes a match, he probably means for the URL to disappear out | 139 // When a user deletes a match, they probably mean for the URL to disappear |
| 140 // of history entirely. So nuke all shortcuts that map to this URL. | 140 // out of history entirely. So nuke all shortcuts that map to this URL. |
| 141 scoped_refptr<ShortcutsBackend> backend = | 141 scoped_refptr<ShortcutsBackend> backend = |
| 142 client_->GetShortcutsBackendIfExists(); | 142 client_->GetShortcutsBackendIfExists(); |
| 143 if (backend.get()) // Can be NULL in Incognito. | 143 if (backend.get()) // Can be NULL in Incognito. |
| 144 backend->DeleteShortcutsWithURL(url); | 144 backend->DeleteShortcutsWithURL(url); |
| 145 | 145 |
| 146 matches_.erase(std::remove_if(matches_.begin(), matches_.end(), | 146 matches_.erase(std::remove_if(matches_.begin(), matches_.end(), |
| 147 DestinationURLEqualsURL(url)), | 147 DestinationURLEqualsURL(url)), |
| 148 matches_.end()); | 148 matches_.end()); |
| 149 // NOTE: |match| is now dead! | 149 // NOTE: |match| is now dead! |
| 150 | 150 |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 const double kMaxDecaySpeedDivisor = 5.0; | 476 const double kMaxDecaySpeedDivisor = 5.0; |
| 477 const double kNumUsesPerDecaySpeedDivisorIncrement = 5.0; | 477 const double kNumUsesPerDecaySpeedDivisorIncrement = 5.0; |
| 478 double decay_divisor = std::min( | 478 double decay_divisor = std::min( |
| 479 kMaxDecaySpeedDivisor, | 479 kMaxDecaySpeedDivisor, |
| 480 (shortcut.number_of_hits + kNumUsesPerDecaySpeedDivisorIncrement - 1) / | 480 (shortcut.number_of_hits + kNumUsesPerDecaySpeedDivisorIncrement - 1) / |
| 481 kNumUsesPerDecaySpeedDivisorIncrement); | 481 kNumUsesPerDecaySpeedDivisorIncrement); |
| 482 | 482 |
| 483 return static_cast<int>((base_score / exp(decay_exponent / decay_divisor)) + | 483 return static_cast<int>((base_score / exp(decay_exponent / decay_divisor)) + |
| 484 0.5); | 484 0.5); |
| 485 } | 485 } |
| OLD | NEW |