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

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

Issue 2755503002: Add a new entry to omnibox_event.proto to log specific type of contextual suggestions (Closed)
Patch Set: Created 3 years, 9 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_field_trial.h" 5 #include "components/omnibox/browser/omnibox_field_trial.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <string> 8 #include <string>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/feature_list.h" 11 #include "base/feature_list.h"
12 #include "base/metrics/field_trial.h" 12 #include "base/metrics/field_trial.h"
13 #include "base/metrics/field_trial_params.h" 13 #include "base/metrics/field_trial_params.h"
14 #include "base/metrics/histogram_macros.h"
14 #include "base/strings/string_number_conversions.h" 15 #include "base/strings/string_number_conversions.h"
15 #include "base/strings/string_split.h" 16 #include "base/strings/string_split.h"
16 #include "base/strings/string_util.h" 17 #include "base/strings/string_util.h"
17 #include "base/time/time.h" 18 #include "base/time/time.h"
18 #include "build/build_config.h" 19 #include "build/build_config.h"
19 #include "components/metrics/proto/omnibox_event.pb.h" 20 #include "components/metrics/proto/omnibox_event.pb.h"
20 #include "components/omnibox/browser/omnibox_switches.h" 21 #include "components/omnibox/browser/omnibox_switches.h"
21 #include "components/omnibox/browser/url_index_private_data.h" 22 #include "components/omnibox/browser/url_index_private_data.h"
22 #include "components/search/search.h" 23 #include "components/search/search.h"
23 #include "components/variations/active_field_trials.h" 24 #include "components/variations/active_field_trials.h"
(...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after
790 if (it != params.end()) 791 if (it != params.end())
791 return it->second; 792 return it->second;
792 // Fall back to the global instant extended context. 793 // Fall back to the global instant extended context.
793 it = params.find(rule + ":" + page_classification_str + ":*"); 794 it = params.find(rule + ":" + page_classification_str + ":*");
794 if (it != params.end()) 795 if (it != params.end())
795 return it->second; 796 return it->second;
796 // Look up rule in the global context. 797 // Look up rule in the global context.
797 it = params.find(rule + ":*:*"); 798 it = params.find(rule + ":*:*");
798 return (it != params.end()) ? it->second : std::string(); 799 return (it != params.end()) ? it->second : std::string();
799 } 800 }
801
802 namespace {
803
804 static const char* kContextualZeroSuggests[] = {"" /*type is not set*/,
805 "cooccurrence_pages",
Mark P 2017/03/14 20:17:49 If we keep the human-readable names (and maybe if
gcomanici 2017/03/14 20:42:55 Can you CC somebody that can do this? Or, should I
Mark P 2017/03/14 21:04:09 I can help do this once we have a concrete proposa
gcomanici 2017/03/15 01:35:56 SG
806 "hivemind_urls",
807 "local_store-maps",
808 "local_store-webpage",
809 "local_store-reservation",
810 "movie_reviews-review",
811 "movie_reviews-showtimes",
812 "on_the_news",
813 "popular_domains",
814 "similar_pages",
815 "top_entity_info",
816 "other"};
817 }
818
819 // static
820 std::string OmniboxFieldTrial::ContextualZeroSuggest::ToString(
821 const Type& type) {
822 static_assert(
823 arraysize(kContextualZeroSuggests) == ContextualZeroSuggest::NUM_TYPES,
824 "kContextualZeroSuggests array must have NUM_TYPES elements");
825 return kContextualZeroSuggests[type];
826 }
827
828 // static
829 OmniboxFieldTrial::ContextualZeroSuggest::Type
830 OmniboxFieldTrial::ContextualZeroSuggest::FromString(const std::string& type) {
831 if (type.empty())
832 return NOT_SET;
833 for (int i = 0; i < NUM_TYPES; ++i) {
834 if (kContextualZeroSuggests[i] == type) {
835 return (Type)i;
836 }
837 }
838 return OTHER;
839 }
840
841 // static
842 void OmniboxFieldTrial::ContextualZeroSuggest::RecordTypeAsProvided(
843 const std::string& type_as_string) {
844 const auto type = FromString(type_as_string);
845 if (type != NOT_SET)
846 UMA_HISTOGRAM_ENUMERATION(
847 "ZeroSuggest.ContextualSuggestType.SuggestionProvided", type,
848 NUM_TYPES);
849 }
850
851 // static
852 void OmniboxFieldTrial::ContextualZeroSuggest::RecordTypeAsUsed(
853 const std::string& type_as_string) {
854 const auto type = FromString(type_as_string);
855 if (type != NOT_SET)
856 UMA_HISTOGRAM_ENUMERATION(
857 "ZeroSuggest.ContextualSuggestType.SuggestionUsed", type, NUM_TYPES);
858 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698