Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(956)

Side by Side Diff: chrome/browser/autocomplete/shortcuts_provider.cc

Issue 22954004: autocomplete: Fix the use of std::remove_if() function. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 ShortcutsBackendFactory::GetForProfileIfExists(profile_); 126 ShortcutsBackendFactory::GetForProfileIfExists(profile_);
127 if (backend.get()) 127 if (backend.get())
128 backend->RemoveObserver(this); 128 backend->RemoveObserver(this);
129 } 129 }
130 130
131 void ShortcutsProvider::OnShortcutsLoaded() { 131 void ShortcutsProvider::OnShortcutsLoaded() {
132 initialized_ = true; 132 initialized_ = true;
133 } 133 }
134 134
135 void ShortcutsProvider::DeleteMatchesWithURLs(const std::set<GURL>& urls) { 135 void ShortcutsProvider::DeleteMatchesWithURLs(const std::set<GURL>& urls) {
136 std::remove_if(matches_.begin(), matches_.end(), RemoveMatchPredicate(urls)); 136 matches_.erase(
137 std::remove_if(
138 matches_.begin(), matches_.end(), RemoveMatchPredicate(urls)),
139 matches_.end());
137 listener_->OnProviderUpdate(true); 140 listener_->OnProviderUpdate(true);
138 } 141 }
139 142
140 void ShortcutsProvider::DeleteShortcutsWithURLs(const std::set<GURL>& urls) { 143 void ShortcutsProvider::DeleteShortcutsWithURLs(const std::set<GURL>& urls) {
141 scoped_refptr<history::ShortcutsBackend> backend = 144 scoped_refptr<history::ShortcutsBackend> backend =
142 ShortcutsBackendFactory::GetForProfileIfExists(profile_); 145 ShortcutsBackendFactory::GetForProfileIfExists(profile_);
143 if (!backend.get()) 146 if (!backend.get())
144 return; // We are off the record. 147 return; // We are off the record.
145 for (std::set<GURL>::const_iterator url = urls.begin(); url != urls.end(); 148 for (std::set<GURL>::const_iterator url = urls.begin(); url != urls.end();
146 ++url) 149 ++url)
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 // (1.0 / each 5 additional hits), up to a maximum of 5x as long. 367 // (1.0 / each 5 additional hits), up to a maximum of 5x as long.
365 const double kMaxDecaySpeedDivisor = 5.0; 368 const double kMaxDecaySpeedDivisor = 5.0;
366 const double kNumUsesPerDecaySpeedDivisorIncrement = 5.0; 369 const double kNumUsesPerDecaySpeedDivisorIncrement = 5.0;
367 double decay_divisor = std::min(kMaxDecaySpeedDivisor, 370 double decay_divisor = std::min(kMaxDecaySpeedDivisor,
368 (shortcut.number_of_hits + kNumUsesPerDecaySpeedDivisorIncrement - 1) / 371 (shortcut.number_of_hits + kNumUsesPerDecaySpeedDivisorIncrement - 1) /
369 kNumUsesPerDecaySpeedDivisorIncrement); 372 kNumUsesPerDecaySpeedDivisorIncrement);
370 373
371 return static_cast<int>((base_score / exp(decay_exponent / decay_divisor)) + 374 return static_cast<int>((base_score / exp(decay_exponent / decay_divisor)) +
372 0.5); 375 0.5);
373 } 376 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698