From 9d58e3df5db2c3de7110214093fe2b2fe21fb9d4 Mon Sep 17 00:00:00 2001 From: "bartn@chromium.org" Date: Tue, 13 Nov 2012 09:42:39 +0000 Subject: [PATCH] Do not set completed_length to 0 if not available. BUG=159493 TBR=isherman@chromium.org Review URL: https://chromiumcodereview.appspot.com/11365118 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@167343 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/autocomplete/autocomplete_log.h | 3 ++- chrome/browser/metrics/metrics_log.cc | 6 ++++-- chrome/browser/ui/omnibox/omnibox_edit_model.cc | 2 +- chrome/common/metrics/proto/omnibox_event.proto | 2 ++ 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/chrome/browser/autocomplete/autocomplete_log.h b/chrome/browser/autocomplete/autocomplete_log.h index 4dec69246f7e..245481b386bd 100644 --- a/chrome/browser/autocomplete/autocomplete_log.h +++ b/chrome/browser/autocomplete/autocomplete_log.h @@ -63,7 +63,8 @@ struct AutocompleteLog { // unit tests), this elapsed time is set to -1 milliseconds. base::TimeDelta elapsed_time_since_user_first_modified_omnibox; - // Inline autocompleted length (if displayed). + // Inline autocompleted length (if displayed). Set to string16::npos + // if not available. size_t inline_autocompleted_length; // Result set. diff --git a/chrome/browser/metrics/metrics_log.cc b/chrome/browser/metrics/metrics_log.cc index a664db025d7b..9ff3957707f3 100644 --- a/chrome/browser/metrics/metrics_log.cc +++ b/chrome/browser/metrics/metrics_log.cc @@ -933,7 +933,8 @@ void MetricsLog::RecordOmniboxOpenedURL(const AutocompleteLog& log) { WriteIntAttribute("numterms", num_terms); WriteIntAttribute("selectedindex", static_cast(log.selected_index)); WriteIntAttribute("completedlength", - static_cast(log.inline_autocompleted_length)); + log.inline_autocompleted_length != string16::npos ? + static_cast(log.inline_autocompleted_length) : 0); if (log.elapsed_time_since_user_first_modified_omnibox != base::TimeDelta::FromMilliseconds(-1)) { // Only upload the typing duration if it is set/valid. @@ -969,7 +970,8 @@ void MetricsLog::RecordOmniboxOpenedURL(const AutocompleteLog& log) { omnibox_event->set_just_deleted_text(log.just_deleted_text); omnibox_event->set_num_typed_terms(num_terms); omnibox_event->set_selected_index(log.selected_index); - omnibox_event->set_completed_length(log.inline_autocompleted_length); + if (log.inline_autocompleted_length != string16::npos) + omnibox_event->set_completed_length(log.inline_autocompleted_length); if (log.elapsed_time_since_user_first_modified_omnibox != base::TimeDelta::FromMilliseconds(-1)) { // Only upload the typing duration if it is set/valid. diff --git a/chrome/browser/ui/omnibox/omnibox_edit_model.cc b/chrome/browser/ui/omnibox/omnibox_edit_model.cc index aaea2c9ce1e3..cabe9396dcb8 100644 --- a/chrome/browser/ui/omnibox/omnibox_edit_model.cc +++ b/chrome/browser/ui/omnibox/omnibox_edit_model.cc @@ -550,7 +550,7 @@ void OmniboxEditModel::OpenMatch(const AutocompleteMatch& match, ClassifyPage(controller_->GetTabContents()-> web_contents()->GetURL()), base::TimeTicks::Now() - time_user_first_modified_omnibox_, - 0, // inline autocomplete length; possibly set later + string16::npos, // inline autocomplete length; possibly set later result()); DCHECK(user_input_in_progress_ || match.provider->type() == AutocompleteProvider::TYPE_ZERO_SUGGEST) diff --git a/chrome/common/metrics/proto/omnibox_event.proto b/chrome/common/metrics/proto/omnibox_event.proto index f37780014ded..dc1b77a49839 100644 --- a/chrome/common/metrics/proto/omnibox_event.proto +++ b/chrome/common/metrics/proto/omnibox_event.proto @@ -38,6 +38,8 @@ message OmniboxEventProto { // The length of the inline autocomplete text in the omnibox. // The sum |typed_length| + |completed_length| gives the full length of the // user-visible text in the omnibox. + // This field is only set for inlineable suggestions selected at position 0 + // (|selected_index| = 0) and will be omitted otherwise. optional int32 completed_length = 6; // The amount of time, in milliseconds, since the user first began modifying -- 2.11.4.GIT