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

Unified Diff: components/history/core/browser/history_backend.cc

Issue 2906953003: Remove ScopedVector usage from components/history (Closed)
Patch Set: Remove ScopedVector usage from components/history Created 3 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: components/history/core/browser/history_backend.cc
diff --git a/components/history/core/browser/history_backend.cc b/components/history/core/browser/history_backend.cc
index 9c24373f52b4a13f1cdf56c6819052d7168809e2..48bb98e4078e6df5312e088ecd4a44a3e264eaef 100644
--- a/components/history/core/browser/history_backend.cc
+++ b/components/history/core/browser/history_backend.cc
@@ -1233,6 +1233,7 @@ void HistoryBackend::QueryHistoryBasic(const QueryOptions& options,
DCHECK_LE(static_cast<int>(visits.size()), options.EffectiveMaxCount());
// Now add them and the URL rows to the results.
+ std::vector<URLResult> matching_results;
URLResult url_result;
for (size_t i = 0; i < visits.size(); i++) {
const VisitRow visit = visits[i];
@@ -1258,8 +1259,9 @@ void HistoryBackend::QueryHistoryBasic(const QueryOptions& options,
// We don't set any of the query-specific parts of the URLResult, since
// snippets and stuff don't apply to basic querying.
- result->AppendURLBySwapping(&url_result);
+ matching_results.push_back(std::move(url_result));
}
+ result->SetURLResults(std::move(matching_results));
if (!has_more_results && options.begin_time <= first_recorded_time_)
result->set_reached_beginning(true);
@@ -1292,13 +1294,14 @@ void HistoryBackend::QueryHistoryText(const base::string16& text_query,
size_t max_results = options.max_count == 0
? std::numeric_limits<size_t>::max()
: static_cast<int>(options.max_count);
- for (std::vector<URLResult>::iterator it = matching_visits.begin();
- it != matching_visits.end() && result->size() < max_results; ++it) {
- result->AppendURLBySwapping(&(*it));
+ bool has_more_results = false;
+ if (matching_visits.size() > max_results) {
+ has_more_results = true;
+ matching_visits.resize(max_results);
}
+ result->SetURLResults(std::move(matching_visits));
- if (matching_visits.size() == result->size() &&
- options.begin_time <= first_recorded_time_)
+ if(!has_more_results && options.begin_time <= first_recorded_time_)
result->set_reached_beginning(true);
}
« no previous file with comments | « chrome/browser/ui/webui/browsing_history_handler_unittest.cc ('k') | components/history/core/browser/history_types.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698