diff options
author | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-12 22:16:09 +0000 |
---|---|---|
committer | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-12 22:16:09 +0000 |
commit | 12ec79f1936d9eedc2c6691ef73bbc3ca7b4bc4a (patch) | |
tree | 813d09a37caecb6c80a4ba3019b77c8646b43f91 /chrome/browser/autocomplete | |
parent | a0edd606ddead87a3330244156302445d0b83012 (diff) | |
download | chromium_src-12ec79f1936d9eedc2c6691ef73bbc3ca7b4bc4a.zip chromium_src-12ec79f1936d9eedc2c6691ef73bbc3ca7b4bc4a.tar.gz chromium_src-12ec79f1936d9eedc2c6691ef73bbc3ca7b4bc4a.tar.bz2 |
Omnibox metrics logging patch splitout, part 5: Add TypeToString() helpers. One of these is unused for the moment.
Review URL: http://codereview.chromium.org/10657
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5307 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autocomplete')
-rw-r--r-- | chrome/browser/autocomplete/autocomplete.cc | 30 | ||||
-rw-r--r-- | chrome/browser/autocomplete/autocomplete.h | 6 |
2 files changed, 36 insertions, 0 deletions
diff --git a/chrome/browser/autocomplete/autocomplete.cc b/chrome/browser/autocomplete/autocomplete.cc index 5e9b083..e2c89c1 100644 --- a/chrome/browser/autocomplete/autocomplete.cc +++ b/chrome/browser/autocomplete/autocomplete.cc @@ -53,6 +53,22 @@ AutocompleteInput::AutocompleteInput(const std::wstring& text, text_.erase(0, 1); } +// static +std::string AutocompleteInput::TypeToString(Type type) { + switch (type) { + case INVALID: return "invalid"; + case UNKNOWN: return "unknown"; + case REQUESTED_URL: return "requested-url"; + case URL: return "url"; + case QUERY: return "query"; + case FORCED_QUERY: return "forced-query"; + + default: + NOTREACHED(); + return std::string(); + } +} + //static AutocompleteInput::Type AutocompleteInput::Parse(const std::wstring& text, const std::wstring& desired_tld, @@ -250,6 +266,20 @@ AutocompleteMatch::AutocompleteMatch(AutocompleteProvider* provider, } // static +std::string AutocompleteMatch::TypeToString(Type type) { + switch (type) { + case URL: return "url"; + case KEYWORD: return "keyword"; + case SEARCH: return "search"; + case HISTORY_SEARCH: return "history"; + + default: + NOTREACHED(); + return std::string(); + } +} + +// static bool AutocompleteMatch::MoreRelevant(const AutocompleteMatch& elem1, const AutocompleteMatch& elem2) { // For equal-relevance matches, we sort alphabetically, so that providers diff --git a/chrome/browser/autocomplete/autocomplete.h b/chrome/browser/autocomplete/autocomplete.h index ad4c138..1c94cf9 100644 --- a/chrome/browser/autocomplete/autocomplete.h +++ b/chrome/browser/autocomplete/autocomplete.h @@ -162,6 +162,9 @@ class AutocompleteInput { bool prefer_keyword, bool synchronous_only); + // Converts |type| to a string representation. Used in logging. + static std::string TypeToString(Type type); + // Parses |text| and returns the type of input this will be interpreted as. // The components of the input are stored in the output parameter |parts|. static Type Parse(const std::wstring& text, @@ -301,6 +304,9 @@ struct AutocompleteMatch { int relevance, bool deletable); + // Converts |type| to a string representation. Used in logging. + static std::string TypeToString(Type type); + // Comparison function for determining when one match is better than another. static bool MoreRelevant(const AutocompleteMatch& elem1, const AutocompleteMatch& elem2); |