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

Side by Side Diff: components/omnibox/browser/omnibox_edit_model.cc

Issue 2361653002: Omnibox Metrics - Remove Percent Match Histograms (Closed)
Patch Set: more polish of histograms.xml Created 4 years, 2 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 unified diff | Download patch
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/omnibox/browser/omnibox_edit_model.h" 5 #include "components/omnibox/browser/omnibox_edit_model.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 76
77 // Histogram name which counts the number of milliseconds a user takes 77 // Histogram name which counts the number of milliseconds a user takes
78 // between focusing and editing the omnibox. 78 // between focusing and editing the omnibox.
79 const char kFocusToEditTimeHistogram[] = "Omnibox.FocusToEditTime"; 79 const char kFocusToEditTimeHistogram[] = "Omnibox.FocusToEditTime";
80 80
81 // Histogram name which counts the number of milliseconds a user takes 81 // Histogram name which counts the number of milliseconds a user takes
82 // between focusing and opening an omnibox match. 82 // between focusing and opening an omnibox match.
83 const char kFocusToOpenTimeHistogram[] = 83 const char kFocusToOpenTimeHistogram[] =
84 "Omnibox.FocusToOpenTimeAnyPopupState2"; 84 "Omnibox.FocusToOpenTimeAnyPopupState2";
85 85
86 // Split the percentage match histograms into buckets based on the width of the
87 // omnibox.
88 const int kPercentageMatchHistogramWidthBuckets[] = { 400, 700, 1200 };
89
90 void RecordPercentageMatchHistogram(const base::string16& old_text,
91 const base::string16& new_text,
92 ui::PageTransition transition,
93 int omnibox_width) {
94 size_t avg_length = (old_text.length() + new_text.length()) / 2;
95
96 int percent = 0;
97 if (!old_text.empty() && !new_text.empty()) {
98 size_t shorter_length = std::min(old_text.length(), new_text.length());
99 base::string16::const_iterator end(old_text.begin() + shorter_length);
100 base::string16::const_iterator mismatch(
101 std::mismatch(old_text.begin(), end, new_text.begin()).first);
102 size_t matching_characters = mismatch - old_text.begin();
103 percent = static_cast<float>(matching_characters) / avg_length * 100;
104 }
105
106 // TODO(treib,mpearson): Do we want to keep these histograms? Most of the
107 // previously-logged cases don't exist anymore. crbug.com/627747
108 std::string histogram_name;
109 if (ui::PageTransitionTypeIncludingQualifiersIs(
110 transition, ui::PAGE_TRANSITION_TYPED)) {
111 histogram_name = "InstantExtended.PercentageMatchV2_URLtoURL";
112 UMA_HISTOGRAM_PERCENTAGE(histogram_name, percent);
113 } else {
114 histogram_name = "InstantExtended.PercentageMatchV2_URLtoQuery";
115 UMA_HISTOGRAM_PERCENTAGE(histogram_name, percent);
116 }
117
118 std::string suffix = "large";
119 for (size_t i = 0; i < arraysize(kPercentageMatchHistogramWidthBuckets);
120 ++i) {
121 if (omnibox_width < kPercentageMatchHistogramWidthBuckets[i]) {
122 suffix = base::IntToString(kPercentageMatchHistogramWidthBuckets[i]);
123 break;
124 }
125 }
126
127 // Cannot rely on UMA histograms macro because the name of the histogram is
128 // generated dynamically.
129 base::HistogramBase* counter = base::LinearHistogram::FactoryGet(
130 histogram_name + "_" + suffix, 1, 101, 102,
131 base::Histogram::kUmaTargetedHistogramFlag);
132 counter->Add(percent);
133 }
134
135 } // namespace 86 } // namespace
136 87
137 88
138 // OmniboxEditModel::State ---------------------------------------------------- 89 // OmniboxEditModel::State ----------------------------------------------------
139 90
140 OmniboxEditModel::State::State(bool user_input_in_progress, 91 OmniboxEditModel::State::State(bool user_input_in_progress,
141 const base::string16& user_text, 92 const base::string16& user_text,
142 const base::string16& gray_text, 93 const base::string16& gray_text,
143 const base::string16& keyword, 94 const base::string16& keyword,
144 bool is_keyword_hint, 95 bool is_keyword_hint,
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 } 698 }
748 699
749 // Get the current text before we call RevertAll() which will clear it. 700 // Get the current text before we call RevertAll() which will clear it.
750 base::string16 current_text = view_->GetText(); 701 base::string16 current_text = view_->GetText();
751 702
752 if (disposition != WindowOpenDisposition::NEW_BACKGROUND_TAB) { 703 if (disposition != WindowOpenDisposition::NEW_BACKGROUND_TAB) {
753 base::AutoReset<bool> tmp(&in_revert_, true); 704 base::AutoReset<bool> tmp(&in_revert_, true);
754 view_->RevertAll(); // Revert the box to its unedited state. 705 view_->RevertAll(); // Revert the box to its unedited state.
755 } 706 }
756 707
757 RecordPercentageMatchHistogram(
758 permanent_text_, current_text, match.transition, view_->GetWidth());
759
760 // Track whether the destination URL sends us to a search results page 708 // Track whether the destination URL sends us to a search results page
761 // using the default search provider. 709 // using the default search provider.
762 TemplateURLService* template_url_service = client_->GetTemplateURLService(); 710 TemplateURLService* template_url_service = client_->GetTemplateURLService();
763 if (template_url_service && 711 if (template_url_service &&
764 template_url_service->IsSearchResultsPageFromDefaultSearchProvider( 712 template_url_service->IsSearchResultsPageFromDefaultSearchProvider(
765 match.destination_url)) { 713 match.destination_url)) {
766 base::RecordAction( 714 base::RecordAction(
767 base::UserMetricsAction("OmniboxDestinationURLIsSearchOnDSP")); 715 base::UserMetricsAction("OmniboxDestinationURLIsSearchOnDSP"));
768 } 716 }
769 717
(...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after
1491 // Update state and notify view if the omnibox has focus and the caret 1439 // Update state and notify view if the omnibox has focus and the caret
1492 // visibility changed. 1440 // visibility changed.
1493 const bool was_caret_visible = is_caret_visible(); 1441 const bool was_caret_visible = is_caret_visible();
1494 focus_state_ = state; 1442 focus_state_ = state;
1495 if (focus_state_ != OMNIBOX_FOCUS_NONE && 1443 if (focus_state_ != OMNIBOX_FOCUS_NONE &&
1496 is_caret_visible() != was_caret_visible) 1444 is_caret_visible() != was_caret_visible)
1497 view_->ApplyCaretVisibility(); 1445 view_->ApplyCaretVisibility();
1498 1446
1499 client_->OnFocusChanged(focus_state_, reason); 1447 client_->OnFocusChanged(focus_state_, reason);
1500 } 1448 }
OLDNEW
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698