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

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

Issue 14267032: Omnibox: HistoryContents Shouldn't *Always* Clear Results on Stop() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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/history_contents_provider.h" 5 #include "chrome/browser/autocomplete/history_contents_provider.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 base::Unretained(this))); 145 base::Unretained(this)));
146 } 146 }
147 } 147 }
148 } 148 }
149 149
150 void HistoryContentsProvider::Stop(bool clear_cached_results) { 150 void HistoryContentsProvider::Stop(bool clear_cached_results) {
151 done_ = true; 151 done_ = true;
152 request_consumer_.CancelAllRequests(); 152 request_consumer_.CancelAllRequests();
153 153
154 // Clear the results. We swap in an empty one as the easy way to clear it. 154 // Clear the results. We swap in an empty one as the easy way to clear it.
155 history::QueryResults empty_results; 155 if (clear_cached_results) {
156 results_.Swap(&empty_results); 156 history::QueryResults empty_results;
157 have_results_ = false; 157 results_.Swap(&empty_results);
158 have_results_ = false;
159 }
158 } 160 }
159 161
160 HistoryContentsProvider::~HistoryContentsProvider() { 162 HistoryContentsProvider::~HistoryContentsProvider() {
161 } 163 }
162 164
163 void HistoryContentsProvider::QueryComplete(HistoryService::Handle handle, 165 void HistoryContentsProvider::QueryComplete(HistoryService::Handle handle,
164 history::QueryResults* results) { 166 history::QueryResults* results) {
165 DCHECK(results_.empty()); 167 DCHECK(results_.empty());
166 results_.Swap(results); 168 results_.Swap(results);
167 have_results_ = true; 169 have_results_ = true;
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 267
266 int HistoryContentsProvider::CalculateRelevance( 268 int HistoryContentsProvider::CalculateRelevance(
267 const history::URLResult& result) { 269 const history::URLResult& result) {
268 const bool in_title = MatchInTitle(result); 270 const bool in_title = MatchInTitle(result);
269 BookmarkModel* bm_model = BookmarkModelFactory::GetForProfile(profile_); 271 BookmarkModel* bm_model = BookmarkModelFactory::GetForProfile(profile_);
270 if (!bm_model || !bm_model->IsBookmarked(result.url())) 272 if (!bm_model || !bm_model->IsBookmarked(result.url()))
271 return in_title ? (700 + title_count_++) : (500 + contents_count_++); 273 return in_title ? (700 + title_count_++) : (500 + contents_count_++);
272 return in_title ? 274 return in_title ?
273 (1000 + star_title_count_++) : (550 + star_contents_count_++); 275 (1000 + star_title_count_++) : (550 + star_contents_count_++);
274 } 276 }
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