Commit 7706a52a authored by mpearson@chromium.org's avatar mpearson@chromium.org

Adds a UMA histogram to monitor omnibox suggest requests.

In particular it counts three things.
bucket 1: suggest requests sent
bucket 2: suggest requests invalidated (e.g., due to user typing another character)
bucket 3: suggest responses received

BUG=
TEST=using about:histograms, by hand with various typing speeds

Review URL: https://chromiumcodereview.appspot.com/10832323

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@151913 0039d316-1c4b-4281-b951-d872f2087c98
parent edc8c35d
...@@ -53,6 +53,27 @@ using base::TimeDelta; ...@@ -53,6 +53,27 @@ using base::TimeDelta;
namespace { namespace {
// We keep track in a histogram how many suggest requests we send, how
// many suggest requests we invalidate (e.g., due to a user typing
// another character), and how many replies we receive.
// *** ADD NEW ENUMS AFTER ALL PREVIOUSLY DEFINED ONES! ***
// (excluding the end-of-list enum value)
// We do not want values of existing enums to change or else it screws
// up the statistics.
enum SuggestRequestsHistogramValue {
REQUEST_SENT = 1,
REQUEST_INVALIDATED,
REPLY_RECEIVED,
MAX_SUGGEST_REQUEST_HISTOGRAM_VALUE
};
// Increments the appropriate value in the histogram by one.
void LogOmniboxSuggestRequest(
SuggestRequestsHistogramValue request_value) {
UMA_HISTOGRAM_ENUMERATION("Omnibox.SuggestRequests", request_value,
MAX_SUGGEST_REQUEST_HISTOGRAM_VALUE);
}
bool HasMultipleWords(const string16& text) { bool HasMultipleWords(const string16& text) {
base::i18n::BreakIterator i(text, base::i18n::BreakIterator::BREAK_WORD); base::i18n::BreakIterator i(text, base::i18n::BreakIterator::BREAK_WORD);
bool found_word = false; bool found_word = false;
...@@ -293,12 +314,14 @@ void SearchProvider::Run() { ...@@ -293,12 +314,14 @@ void SearchProvider::Run() {
const TemplateURL* default_url = providers_.GetDefaultProviderURL(); const TemplateURL* default_url = providers_.GetDefaultProviderURL();
if (default_url && !default_url->suggestions_url().empty()) { if (default_url && !default_url->suggestions_url().empty()) {
suggest_results_pending_++; suggest_results_pending_++;
LogOmniboxSuggestRequest(REQUEST_SENT);
default_fetcher_.reset(CreateSuggestFetcher(kDefaultProviderURLFetcherID, default_fetcher_.reset(CreateSuggestFetcher(kDefaultProviderURLFetcherID,
default_url->suggestions_url_ref(), input_.text())); default_url->suggestions_url_ref(), input_.text()));
} }
const TemplateURL* keyword_url = providers_.GetKeywordProviderURL(); const TemplateURL* keyword_url = providers_.GetKeywordProviderURL();
if (keyword_url && !keyword_url->suggestions_url().empty()) { if (keyword_url && !keyword_url->suggestions_url().empty()) {
suggest_results_pending_++; suggest_results_pending_++;
LogOmniboxSuggestRequest(REQUEST_SENT);
keyword_fetcher_.reset(CreateSuggestFetcher(kKeywordProviderURLFetcherID, keyword_fetcher_.reset(CreateSuggestFetcher(kKeywordProviderURLFetcherID,
keyword_url->suggestions_url_ref(), keyword_input_text_)); keyword_url->suggestions_url_ref(), keyword_input_text_));
} }
...@@ -332,6 +355,7 @@ void SearchProvider::AddProviderInfo(ProvidersInfo* provider_info) const { ...@@ -332,6 +355,7 @@ void SearchProvider::AddProviderInfo(ProvidersInfo* provider_info) const {
void SearchProvider::OnURLFetchComplete(const net::URLFetcher* source) { void SearchProvider::OnURLFetchComplete(const net::URLFetcher* source) {
DCHECK(!done_); DCHECK(!done_);
suggest_results_pending_--; suggest_results_pending_--;
LogOmniboxSuggestRequest(REPLY_RECEIVED);
DCHECK_GE(suggest_results_pending_, 0); // Should never go negative. DCHECK_GE(suggest_results_pending_, 0); // Should never go negative.
const net::HttpResponseHeaders* const response_headers = const net::HttpResponseHeaders* const response_headers =
source->GetResponseHeaders(); source->GetResponseHeaders();
...@@ -549,6 +573,10 @@ bool SearchProvider::IsQuerySuitableForSuggest() const { ...@@ -549,6 +573,10 @@ bool SearchProvider::IsQuerySuitableForSuggest() const {
} }
void SearchProvider::StopSuggest() { void SearchProvider::StopSuggest() {
// Increment the appropriate field in the histogram by the number of
// pending requests that were invalidated.
for (int i = 0; i < suggest_results_pending_; i++)
LogOmniboxSuggestRequest(REQUEST_INVALIDATED);
suggest_results_pending_ = 0; suggest_results_pending_ = 0;
timer_.Stop(); timer_.Stop();
// Stop any in-progress URL fetches. // Stop any in-progress URL fetches.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment