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

Side by Side Diff: base/metrics/field_trial.cc

Issue 10382018: Added a SetForced method to allow forcing a new set of group bucketting. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Better wording for the header comments of the new method. Created 8 years, 7 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 | « base/metrics/field_trial.h ('k') | base/metrics/field_trial_unittest.cc » ('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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "base/metrics/field_trial.h" 5 #include "base/metrics/field_trial.h"
6 6
7 #include "base/build_time.h" 7 #include "base/build_time.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/rand_util.h" 9 #include "base/rand_util.h"
10 #include "base/sha1.h" 10 #include "base/sha1.h"
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 big_string.append(1, kHistogramFieldTrialSeparator); 163 big_string.append(1, kHistogramFieldTrialSeparator);
164 return big_string.append(FieldTrialList::FindFullName(trial_name)); 164 return big_string.append(FieldTrialList::FindFullName(trial_name));
165 } 165 }
166 166
167 // static 167 // static
168 void FieldTrial::EnableBenchmarking() { 168 void FieldTrial::EnableBenchmarking() {
169 DCHECK_EQ(0u, FieldTrialList::GetFieldTrialCount()); 169 DCHECK_EQ(0u, FieldTrialList::GetFieldTrialCount());
170 enable_benchmarking_ = true; 170 enable_benchmarking_ = true;
171 } 171 }
172 172
173 void FieldTrial::SetForced() {
174 // We might have been forced before (e.g., by CreateFieldTrial) and it's
175 // first come first served, e.g., command line switch has precedence.
176 if (forced_)
177 return;
178 // Explicit forcing should only be for cases where we want to set the group
179 // probabilities before the hard coded field trial setup is executed. So
180 // there must have been at least one non-default group appended at that point.
181 DCHECK_GT(next_group_number_, kDefaultGroupNumber + 1);
182
183 // And we must finalize the group choice before we mark ourselves as forced.
184 group();
185 forced_ = true;
186 }
187
173 FieldTrial::~FieldTrial() {} 188 FieldTrial::~FieldTrial() {}
174 189
175 void FieldTrial::SetGroupChoice(const std::string& name, int number) { 190 void FieldTrial::SetGroupChoice(const std::string& name, int number) {
176 group_ = number; 191 group_ = number;
177 if (name.empty()) 192 if (name.empty())
178 StringAppendF(&group_name_, "%d", group_); 193 StringAppendF(&group_name_, "%d", group_);
179 else 194 else
180 group_name_ = name; 195 group_name_ = name;
181 } 196 }
182 197
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 used_without_global_ = true; 473 used_without_global_ = true;
459 return; 474 return;
460 } 475 }
461 AutoLock auto_lock(global_->lock_); 476 AutoLock auto_lock(global_->lock_);
462 DCHECK(!global_->PreLockedFind(trial->name())); 477 DCHECK(!global_->PreLockedFind(trial->name()));
463 trial->AddRef(); 478 trial->AddRef();
464 global_->registered_[trial->name()] = trial; 479 global_->registered_[trial->name()] = trial;
465 } 480 }
466 481
467 } // namespace base 482 } // namespace base
OLDNEW
« no previous file with comments | « base/metrics/field_trial.h ('k') | base/metrics/field_trial_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698