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

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

Issue 1584733003: [Cleanup] Remove some expired omnibox field trials. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Only remove the dynamic trials Created 4 years, 11 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/metrics/field_trial.h" 11 #include "base/metrics/field_trial.h"
12 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
13 #include "base/strings/string_split.h" 13 #include "base/strings/string_split.h"
14 #include "base/strings/string_util.h" 14 #include "base/strings/string_util.h"
15 #include "base/strings/stringprintf.h" 15 #include "base/strings/stringprintf.h"
Mark P 2016/01/14 18:38:47 Probably don't need this anymore.
Ilya Sherman 2016/01/15 05:16:42 Done.
16 #include "base/time/time.h" 16 #include "base/time/time.h"
17 #include "build/build_config.h" 17 #include "build/build_config.h"
18 #include "components/metrics/proto/omnibox_event.pb.h" 18 #include "components/metrics/proto/omnibox_event.pb.h"
19 #include "components/omnibox/browser/omnibox_switches.h" 19 #include "components/omnibox/browser/omnibox_switches.h"
20 #include "components/search/search.h" 20 #include "components/search/search.h"
21 #include "components/variations/active_field_trials.h" 21 #include "components/variations/active_field_trials.h"
22 #include "components/variations/metrics_util.h" 22 #include "components/variations/metrics_util.h"
23 #include "components/variations/variations_associated_data.h" 23 #include "components/variations/variations_associated_data.h"
24 24
25 using metrics::OmniboxEventProto; 25 using metrics::OmniboxEventProto;
26 26
27 namespace { 27 namespace {
28 28
29 typedef std::map<std::string, std::string> VariationParams; 29 typedef std::map<std::string, std::string> VariationParams;
30 typedef HUPScoringParams::ScoreBuckets ScoreBuckets; 30 typedef HUPScoringParams::ScoreBuckets ScoreBuckets;
31 31
32 // Field trial names. 32 // Field trial names.
33 const char kStopTimerFieldTrialName[] = "OmniboxStopTimer"; 33 const char kStopTimerFieldTrialName[] = "OmniboxStopTimer";
34 34
35 // The autocomplete dynamic field trial name prefix. Each field trial is
36 // configured dynamically and is retrieved automatically by Chrome during
37 // the startup.
38 const char kAutocompleteDynamicFieldTrialPrefix[] = "AutocompleteDynamicTrial_";
39 // The maximum number of the autocomplete dynamic field trials (aka layers).
40 const int kMaxAutocompleteDynamicFieldTrials = 5;
41
42
43 // Concatenates the autocomplete dynamic field trial prefix with a field trial
44 // ID to form a complete autocomplete field trial name.
45 std::string DynamicFieldTrialName(int id) {
46 return base::StringPrintf("%s%d", kAutocompleteDynamicFieldTrialPrefix, id);
47 }
48
49 void InitializeBucketsFromString(const std::string& bucket_string, 35 void InitializeBucketsFromString(const std::string& bucket_string,
50 ScoreBuckets* score_buckets) { 36 ScoreBuckets* score_buckets) {
51 // Clear the buckets. 37 // Clear the buckets.
52 score_buckets->buckets().clear(); 38 score_buckets->buckets().clear();
53 base::StringPairs kv_pairs; 39 base::StringPairs kv_pairs;
54 if (base::SplitStringIntoKeyValuePairs(bucket_string, ':', ',', &kv_pairs)) { 40 if (base::SplitStringIntoKeyValuePairs(bucket_string, ':', ',', &kv_pairs)) {
55 for (base::StringPairs::const_iterator it = kv_pairs.begin(); 41 for (base::StringPairs::const_iterator it = kv_pairs.begin();
56 it != kv_pairs.end(); ++it) { 42 it != kv_pairs.end(); ++it) {
57 ScoreBuckets::CountMaxRelevance bucket; 43 ScoreBuckets::CountMaxRelevance bucket;
58 base::StringToDouble(it->first, &bucket.first); 44 base::StringToDouble(it->first, &bucket.first);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 double time_ms; 102 double time_ms;
117 if ((half_life_days_ <= 0) || 103 if ((half_life_days_ <= 0) ||
118 ((time_ms = elapsed_time.InMillisecondsF()) <= 0)) 104 ((time_ms = elapsed_time.InMillisecondsF()) <= 0))
119 return 1.0; 105 return 1.0;
120 106
121 const double half_life_intervals = 107 const double half_life_intervals =
122 time_ms / base::TimeDelta::FromDays(half_life_days_).InMillisecondsF(); 108 time_ms / base::TimeDelta::FromDays(half_life_days_).InMillisecondsF();
123 return pow(2.0, -half_life_intervals); 109 return pow(2.0, -half_life_intervals);
124 } 110 }
125 111
126 void OmniboxFieldTrial::ActivateDynamicTrials() {
127 // Initialize all autocomplete dynamic field trials. This method may be
128 // called multiple times.
129 for (int i = 0; i < kMaxAutocompleteDynamicFieldTrials; ++i)
130 base::FieldTrialList::FindValue(DynamicFieldTrialName(i));
131 }
132
133 int OmniboxFieldTrial::GetDisabledProviderTypes() { 112 int OmniboxFieldTrial::GetDisabledProviderTypes() {
134 const std::string& types_string = variations::GetVariationParamValue( 113 const std::string& types_string = variations::GetVariationParamValue(
135 kBundledExperimentFieldTrialName, 114 kBundledExperimentFieldTrialName,
136 kDisableProvidersRule); 115 kDisableProvidersRule);
137 int types = 0; 116 int types = 0;
138 if (types_string.empty() || !base::StringToInt(types_string, &types)) { 117 if (types_string.empty() || !base::StringToInt(types_string, &types)) {
139 return 0; 118 return 0;
140 } 119 }
141 return types; 120 return types;
142 } 121 }
143 122
144 void OmniboxFieldTrial::GetActiveSuggestFieldTrialHashes( 123 void OmniboxFieldTrial::GetActiveSuggestFieldTrialHashes(
145 std::vector<uint32_t>* field_trial_hashes) { 124 std::vector<uint32_t>* field_trial_hashes) {
146 field_trial_hashes->clear(); 125 field_trial_hashes->clear();
147 for (int i = 0; i < kMaxAutocompleteDynamicFieldTrials; ++i) {
148 const std::string& trial_name = DynamicFieldTrialName(i);
149 if (base::FieldTrialList::TrialExists(trial_name))
150 field_trial_hashes->push_back(metrics::HashName(trial_name));
151 }
152 if (base::FieldTrialList::TrialExists(kBundledExperimentFieldTrialName)) { 126 if (base::FieldTrialList::TrialExists(kBundledExperimentFieldTrialName)) {
153 field_trial_hashes->push_back( 127 field_trial_hashes->push_back(
154 metrics::HashName(kBundledExperimentFieldTrialName)); 128 metrics::HashName(kBundledExperimentFieldTrialName));
155 } 129 }
156 } 130 }
157 131
158 base::TimeDelta OmniboxFieldTrial::StopTimerFieldTrialDuration() { 132 base::TimeDelta OmniboxFieldTrial::StopTimerFieldTrialDuration() {
159 int stop_timer_ms; 133 int stop_timer_ms;
160 if (base::StringToInt( 134 if (base::StringToInt(
161 base::FieldTrialList::FindFullName(kStopTimerFieldTrialName), 135 base::FieldTrialList::FindFullName(kStopTimerFieldTrialName),
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 if (it != params.end()) 614 if (it != params.end())
641 return it->second; 615 return it->second;
642 // Fall back to the global instant extended context. 616 // Fall back to the global instant extended context.
643 it = params.find(rule + ":" + page_classification_str + ":*"); 617 it = params.find(rule + ":" + page_classification_str + ":*");
644 if (it != params.end()) 618 if (it != params.end())
645 return it->second; 619 return it->second;
646 // Look up rule in the global context. 620 // Look up rule in the global context.
647 it = params.find(rule + ":*:*"); 621 it = params.find(rule + ":*:*");
648 return (it != params.end()) ? it->second : std::string(); 622 return (it != params.end()) ? it->second : std::string();
649 } 623 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698