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

Unified Diff: chrome/browser/autocomplete/search_provider.cc

Issue 10832323: Adds a UMA histogram to monitor omnibox suggest requests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More rearranging. Created 8 years, 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/autocomplete/search_provider.cc
diff --git a/chrome/browser/autocomplete/search_provider.cc b/chrome/browser/autocomplete/search_provider.cc
index 8bd2c9f2a0b88abb6363c7e3f40a9cf0511330f2..b1163dad421d2ebf4e1b3d58c81ebccf921eee5f 100644
--- a/chrome/browser/autocomplete/search_provider.cc
+++ b/chrome/browser/autocomplete/search_provider.cc
@@ -53,6 +53,23 @@ using base::TimeDelta;
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.
+enum SuggestRequestsHistogramValue {
+ REQUEST_SENT = 1,
+ REQUEST_INVALIDATED = 2,
+ REPLY_RECEIVED = 3,
Ilya Sherman 2012/08/15 23:36:02 Optional nit: Any particular reason to leave the =
+ 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) {
base::i18n::BreakIterator i(text, base::i18n::BreakIterator::BREAK_WORD);
bool found_word = false;
@@ -293,12 +310,14 @@ void SearchProvider::Run() {
const TemplateURL* default_url = providers_.GetDefaultProviderURL();
if (default_url && !default_url->suggestions_url().empty()) {
suggest_results_pending_++;
+ LogOmniboxSuggestRequest(REQUEST_SENT);
default_fetcher_.reset(CreateSuggestFetcher(kDefaultProviderURLFetcherID,
default_url->suggestions_url_ref(), input_.text()));
}
const TemplateURL* keyword_url = providers_.GetKeywordProviderURL();
if (keyword_url && !keyword_url->suggestions_url().empty()) {
suggest_results_pending_++;
+ LogOmniboxSuggestRequest(REQUEST_SENT);
keyword_fetcher_.reset(CreateSuggestFetcher(kKeywordProviderURLFetcherID,
keyword_url->suggestions_url_ref(), keyword_input_text_));
}
@@ -332,6 +351,7 @@ void SearchProvider::AddProviderInfo(ProvidersInfo* provider_info) const {
void SearchProvider::OnURLFetchComplete(const net::URLFetcher* source) {
DCHECK(!done_);
suggest_results_pending_--;
+ LogOmniboxSuggestRequest(REPLY_RECEIVED);
DCHECK_GE(suggest_results_pending_, 0); // Should never go negative.
const net::HttpResponseHeaders* const response_headers =
source->GetResponseHeaders();
@@ -549,6 +569,10 @@ bool SearchProvider::IsQuerySuitableForSuggest() const {
}
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;
timer_.Stop();
// Stop any in-progress URL fetches.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698