| Index: chrome/browser/history/history_backend.cc
|
| diff --git a/chrome/browser/history/history_backend.cc b/chrome/browser/history/history_backend.cc
|
| index 2817a98d0a7c23dcd9fd354ca4932055176d459c..d7d4fc492a2b4347367e66356d8a9342487aa3f1 100644
|
| --- a/chrome/browser/history/history_backend.cc
|
| +++ b/chrome/browser/history/history_backend.cc
|
| @@ -1114,6 +1114,14 @@ bool HistoryBackend::GetVisitsForURL(URLID id, VisitVector* visits) {
|
| return false;
|
| }
|
|
|
| +bool HistoryBackend::GetVisitsForURLWithOptions(URLID id,
|
| + const QueryOptions& options,
|
| + VisitVector* visits) {
|
| + if (db_)
|
| + return db_->GetVisitsForURLWithOptions(id, options, visits);
|
| + return false;
|
| +}
|
| +
|
| bool HistoryBackend::GetMostRecentVisitsForURL(URLID id,
|
| int max_visits,
|
| VisitVector* visits) {
|
| @@ -1402,8 +1410,9 @@ void HistoryBackend::QueryHistory(scoped_refptr<QueryHistoryRequest> request,
|
| // if (archived_db_.get() &&
|
| // expirer_.GetCurrentArchiveTime() - TimeDelta::FromDays(7)) {
|
| } else {
|
| - // Full text history query.
|
| - QueryHistoryFTS(text_query, options, &request->value);
|
| + // Text history query.
|
| + QueryHistoryText(db_.get(), db_.get(), text_query, options,
|
| + &request->value);
|
| }
|
| }
|
|
|
| @@ -1468,6 +1477,45 @@ void HistoryBackend::QueryHistoryBasic(URLDatabase* url_db,
|
| result->set_reached_beginning(true);
|
| }
|
|
|
| +// Text-based querying of history.
|
| +void HistoryBackend::QueryHistoryText(URLDatabase* url_db,
|
| + VisitDatabase* visit_db,
|
| + const string16& text_query,
|
| + const QueryOptions& options,
|
| + QueryResults* result) {
|
| + URLRows text_matches;
|
| + url_db->GetTextMatches(text_query, &text_matches);
|
| +
|
| + bool too_many = false;
|
| + std::vector<URLResult> matching_visits;
|
| + VisitVector visits; // Declare outside loop to prevent re-construction.
|
| + for (size_t i = 0; (i < text_matches.size()) && !too_many; i++) {
|
| + // Get all visits for given URL match.
|
| + GetVisitsForURLWithOptions(text_matches[i].id(), options, &visits);
|
| +
|
| + for (size_t j = 0; j < visits.size(); j++) {
|
| + if (options.max_count != 0 &&
|
| + static_cast<int>(result->size()) >= options.max_count) {
|
| + too_many = true; // Got too many items.
|
| + break;
|
| + }
|
| + URLResult url_result(text_matches[i]);
|
| + url_result.set_visit_time(visits[j].visit_time);
|
| + matching_visits.push_back(url_result);
|
| + }
|
| + }
|
| +
|
| + std::sort(matching_visits.begin(), matching_visits.end(),
|
| + URLResult::CompareVisitTime);
|
| + for (std::vector<URLResult>::iterator it = matching_visits.begin();
|
| + it != matching_visits.end(); ++it) {
|
| + result->AppendURLBySwapping(&(*it));
|
| + }
|
| +
|
| + if (!too_many && options.begin_time <= first_recorded_time_)
|
| + result->set_reached_beginning(true);
|
| +}
|
| +
|
| void HistoryBackend::QueryHistoryFTS(const string16& text_query,
|
| const QueryOptions& options,
|
| QueryResults* result) {
|
|
|