| 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> |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 if (backend.get()) // Can be NULL in Incognito. | 104 if (backend.get()) // Can be NULL in Incognito. |
| 105 backend->DeleteShortcutsWithURL(url); | 105 backend->DeleteShortcutsWithURL(url); |
| 106 | 106 |
| 107 matches_.erase(std::remove_if(matches_.begin(), matches_.end(), | 107 matches_.erase(std::remove_if(matches_.begin(), matches_.end(), |
| 108 DestinationURLEqualsURL(url)), | 108 DestinationURLEqualsURL(url)), |
| 109 matches_.end()); | 109 matches_.end()); |
| 110 // NOTE: |match| is now dead! | 110 // NOTE: |match| is now dead! |
| 111 | 111 |
| 112 // Delete the match from the history DB. This will eventually result in a | 112 // Delete the match from the history DB. This will eventually result in a |
| 113 // second call to DeleteShortcutsWithURL(), which is harmless. | 113 // second call to DeleteShortcutsWithURL(), which is harmless. |
| 114 HistoryService* const history_service = | 114 HistoryService* const history_service = HistoryServiceFactory::GetForProfile( |
| 115 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); | 115 profile_, ServiceAccessType::EXPLICIT_ACCESS); |
| 116 DCHECK(history_service); | 116 DCHECK(history_service); |
| 117 history_service->DeleteURL(url); | 117 history_service->DeleteURL(url); |
| 118 } | 118 } |
| 119 | 119 |
| 120 ShortcutsProvider::~ShortcutsProvider() { | 120 ShortcutsProvider::~ShortcutsProvider() { |
| 121 scoped_refptr<ShortcutsBackend> backend = | 121 scoped_refptr<ShortcutsBackend> backend = |
| 122 ShortcutsBackendFactory::GetForProfileIfExists(profile_); | 122 ShortcutsBackendFactory::GetForProfileIfExists(profile_); |
| 123 if (backend.get()) | 123 if (backend.get()) |
| 124 backend->RemoveObserver(this); | 124 backend->RemoveObserver(this); |
| 125 } | 125 } |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 // (1.0 / each 5 additional hits), up to a maximum of 5x as long. | 403 // (1.0 / each 5 additional hits), up to a maximum of 5x as long. |
| 404 const double kMaxDecaySpeedDivisor = 5.0; | 404 const double kMaxDecaySpeedDivisor = 5.0; |
| 405 const double kNumUsesPerDecaySpeedDivisorIncrement = 5.0; | 405 const double kNumUsesPerDecaySpeedDivisorIncrement = 5.0; |
| 406 double decay_divisor = std::min(kMaxDecaySpeedDivisor, | 406 double decay_divisor = std::min(kMaxDecaySpeedDivisor, |
| 407 (shortcut.number_of_hits + kNumUsesPerDecaySpeedDivisorIncrement - 1) / | 407 (shortcut.number_of_hits + kNumUsesPerDecaySpeedDivisorIncrement - 1) / |
| 408 kNumUsesPerDecaySpeedDivisorIncrement); | 408 kNumUsesPerDecaySpeedDivisorIncrement); |
| 409 | 409 |
| 410 return static_cast<int>((base_score / exp(decay_exponent / decay_divisor)) + | 410 return static_cast<int>((base_score / exp(decay_exponent / decay_divisor)) + |
| 411 0.5); | 411 0.5); |
| 412 } | 412 } |
| OLD | NEW |