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

Unified Diff: chrome/browser/history/url_database.cc

Issue 16776004: Replace FTS in the history_service with a brute force text search. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix some typos Created 7 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: chrome/browser/history/url_database.cc
diff --git a/chrome/browser/history/url_database.cc b/chrome/browser/history/url_database.cc
index 0856d25ef4f7a508a0af2939879ed4a9f810bc85..f18cabca5802fa074d697fb59b099f506f589d2f 100644
--- a/chrome/browser/history/url_database.cc
+++ b/chrome/browser/history/url_database.cc
@@ -358,6 +358,31 @@ bool URLDatabase::FindShortestURLFromBase(const std::string& base,
return true;
}
+bool URLDatabase::GetTextMatches(const string16& query,
+ URLRows* results) {
+ ScopedVector<QueryNode> query_nodes;
+ query_parser_.ParseQueryNodes(query, &query_nodes.get());
+
+ sql::Statement statement(GetDB().GetCachedStatement(SQL_FROM_HERE,
+ "SELECT" HISTORY_URL_ROW_FIELDS "FROM urls WHERE hidden = 0"));
+
+ while (statement.Step()) {
+ std::vector<QueryWord> query_words;
+ string16 url = base::i18n::ToLower(UTF8ToUTF16(statement.ColumnString(1)));
Scott Hess - ex-Googler 2013/06/13 19:45:58 Replace UTF8ToUTF16(ColumnString()) with ColumnStr
rmcilroy 2013/06/14 12:45:41 Done.
+ query_parser_.ExtractQueryWords(url, &query_words);
+ string16 title = base::i18n::ToLower(statement.ColumnString16(2));
+ query_parser_.ExtractQueryWords(title, &query_words);
+
+ if (query_parser_.DoesQueryMatch(query_words, query_nodes.get())) {
+ history::URLResult info;
+ FillURLRow(statement, &info);
+ if (info.url().is_valid())
+ results->push_back(info);
+ }
+ }
+ return !results->empty();
Scott Hess - ex-Googler 2013/06/13 19:45:58 If this is your success metric, do you want result
rmcilroy 2013/06/14 12:45:41 Done.
+}
+
bool URLDatabase::InitKeywordSearchTermsTable() {
has_keyword_search_terms_ = true;
if (!GetDB().DoesTableExist("keyword_search_terms")) {

Powered by Google App Engine
This is Rietveld 408576698