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

Side by Side Diff: chrome/common/variations/variations_util.cc

Issue 1200383005: Activate prepopulated fieldtrials (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@codegen_field_trials
Patch Set: rebase Created 5 years, 5 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 "chrome/common/variations/variations_util.h" 5 #include "chrome/common/variations/variations_util.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/metrics/field_trial.h"
10 #include "base/strings/string_split.h" 11 #include "base/strings/string_split.h"
11 #include "chrome/common/child_process_logging.h" 12 #include "chrome/common/child_process_logging.h"
12 #include "chrome/common/crash_keys.h" 13 #include "chrome/common/crash_keys.h"
14 #include "chrome/common/variations/fieldtrial_testing_config.h"
13 #include "components/variations/active_field_trials.h" 15 #include "components/variations/active_field_trials.h"
14 #include "components/variations/variations_associated_data.h" 16 #include "components/variations/variations_associated_data.h"
15 #include "net/base/escape.h" 17 #include "net/base/escape.h"
16 18
17 namespace chrome_variations { 19 namespace chrome_variations {
18 20
19 namespace { 21 namespace {
20 22
21 std::string EscapeValue(const std::string& value) { 23 std::string EscapeValue(const std::string& value) {
22 return net::UnescapeURLComponent(value, net::UnescapeRule::URL_SPECIAL_CHARS); 24 return net::UnescapeURLComponent(value, net::UnescapeRule::URL_SPECIAL_CHARS);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 std::string value = EscapeValue(key_values[i + 1]); 58 std::string value = EscapeValue(key_values[i + 1]);
57 params[key] = value; 59 params[key] = value;
58 } 60 }
59 std::string trial = EscapeValue(group_parts[0]); 61 std::string trial = EscapeValue(group_parts[0]);
60 std::string group = EscapeValue(group_parts[1]); 62 std::string group = EscapeValue(group_parts[1]);
61 variations::AssociateVariationParams(trial, group, params); 63 variations::AssociateVariationParams(trial, group, params);
62 } 64 }
63 return true; 65 return true;
64 } 66 }
65 67
68 void AssociateParamsFromFieldTrialConfig(
69 const FieldTrialTestingConfig& config) {
70 for (size_t i = 0; i < config.groups_size; ++i) {
71 const FieldTrialTestingGroup& group = config.groups[i];
72 if (group.params_size != 0) {
73 std::map<std::string, std::string> params;
74 for (size_t j = 0; j < group.params_size; ++j) {
75 const FieldTrialGroupParams& param = group.params[j];
76 params[param.key] = param.value;
77 }
78 variations::AssociateVariationParams(group.study, group.group_name,
79 params);
80 }
81 base::FieldTrialList::CreateFieldTrial(group.study, group.group_name);
82 }
83 }
84
85 void AssociateDefaultFieldTrialConfig() {
86 AssociateParamsFromFieldTrialConfig(kFieldTrialConfig);
87 }
88
66 } // namespace chrome_variations 89 } // namespace chrome_variations
OLDNEW
« no previous file with comments | « chrome/common/variations/variations_util.h ('k') | chrome/common/variations/variations_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698