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

Unified Diff: components/query_parser/query_parser.h

Issue 703553002: Allow systematic prefix search in bookmarks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed comments at https://codereview.chromium.org/701553002/ Created 6 years, 1 month 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
« no previous file with comments | « components/history/core/browser/url_database.cc ('k') | components/query_parser/query_parser.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/query_parser/query_parser.h
diff --git a/components/query_parser/query_parser.h b/components/query_parser/query_parser.h
index cc3f94b2cf3bc68f3353961b3bbe1c854dfa228d..8ed38e93a5d94a393fa5724a2233a03d033e08c2 100644
--- a/components/query_parser/query_parser.h
+++ b/components/query_parser/query_parser.h
@@ -24,6 +24,14 @@ struct QueryWord {
size_t position;
};
+enum class MatchingAlgorithm {
+ // Only words long enough are considered for prefix search. Shorter words are
+ // considered for exact matches.
+ DEFAULT,
+ // All words are considered for a prefix search.
+ ALWAYS_PREFIX_SEARCH,
+};
+
typedef std::vector<query_parser::QueryWord> QueryWordVector;
// QueryNode is used by QueryParser to represent the elements that constitute a
@@ -72,23 +80,29 @@ class QueryParser {
// point doing anything for them and we only adjust the minimum length
// to 2 for Korean Hangul while using 3 for others. This is a temporary
// hack until we have a segmentation support.
- static bool IsWordLongEnoughForPrefixSearch(const base::string16& word);
+ static bool IsWordLongEnoughForPrefixSearch(
+ const base::string16& word,
+ const MatchingAlgorithm matching_algorithm);
// Parse a query into a SQLite query. The resulting query is placed in
// |sqlite_query| and the number of words is returned.
- int ParseQuery(const base::string16& query, base::string16* sqlite_query);
+ int ParseQuery(const base::string16& query,
+ const MatchingAlgorithm matching_algorithm,
+ base::string16* sqlite_query);
// Parses |query|, returning the words that make up it. Any words in quotes
// are put in |words| without the quotes. For example, the query text
// "foo bar" results in two entries being added to words, one for foo and one
// for bar.
void ParseQueryWords(const base::string16& query,
+ const MatchingAlgorithm matching_algorithm,
std::vector<base::string16>* words);
// Parses |query|, returning the nodes that constitute the valid words in the
// query. This is intended for later usage with DoesQueryMatch. Ownership of
// the nodes passes to the caller.
void ParseQueryNodes(const base::string16& query,
+ const MatchingAlgorithm matching_algorithm,
QueryNodeStarVector* nodes);
// Returns true if the string text matches the query nodes created by a call
@@ -114,7 +128,9 @@ class QueryParser {
private:
// Does the work of parsing |query|; creates nodes in |root| as appropriate.
// This is invoked from both of the ParseQuery methods.
- bool ParseQueryImpl(const base::string16& query, QueryNodeList* root);
+ bool ParseQueryImpl(const base::string16& query,
+ const MatchingAlgorithm matching_algorithm,
sky 2014/11/04 03:32:05 Are we really using const for these? Isn't the enu
Kibeom Kim (inactive) 2014/11/04 08:38:31 Done.
+ QueryNodeList* root);
DISALLOW_COPY_AND_ASSIGN(QueryParser);
};
« no previous file with comments | « components/history/core/browser/url_database.cc ('k') | components/query_parser/query_parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698