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
3 // found in the LICENSE file.
4
5 #include "base/metrics/field_trial.h"
6
7 #include <algorithm>
8
9 #include "base/build_time.h"
10 #include "base/logging.h"
11 #include "base/rand_util.h"
12 #include "base/strings/string_util.h"
13 #include "base/strings/stringprintf.h"
14 #include "base/strings/utf_string_conversions.h"
15
16 namespace base {
17
18 namespace {
19
20 // Define a separator character to use when creating a persistent form of an
21 // instance. This is intended for use as a command line argument, passed to a
22 // second process to mimic our state (i.e., provide the same group name).
23 const char kPersistentStringSeparator = '/'; // Currently a slash.
24
25 // Define a marker character to be used as a prefix to a trial name on the
26 // command line which forces its activation.
27 const char kActivationMarker = '*';
28
29 // Created a time value based on |year|, |month| and |day_of_month| parameters.
CreateTimeFromParams(int year,int month,int day_of_month)30 Time CreateTimeFromParams(int year, int month, int day_of_month) {
31 DCHECK_GT(year, 1970);
32 DCHECK_GT(month, 0);
33 DCHECK_LT(month, 13);
34 DCHECK_GT(day_of_month, 0);
35 DCHECK_LT(day_of_month, 32);
36
37 Time::Exploded exploded;
38 exploded.year = year;
39 exploded.month = month;
40 exploded.day_of_week = 0; // Should be unused.
41 exploded.day_of_month = day_of_month;
42 exploded.hour = 0;
43 exploded.minute = 0;
44 exploded.second = 0;
45 exploded.millisecond = 0;
46
47 return Time::FromLocalExploded(exploded);
48 }
49
50 // Returns the boundary value for comparing against the FieldTrial's added
51 // groups for a given |divisor| (total probability) and |entropy_value|.
GetGroupBoundaryValue(FieldTrial::Probability divisor,double entropy_value)52 FieldTrial::Probability GetGroupBoundaryValue(
53 FieldTrial::Probability divisor,
54 double entropy_value) {
55 // Add a tiny epsilon value to get consistent results when converting floating
56 // points to int. Without it, boundary values have inconsistent results, e.g.:
57 //
58 // static_cast<FieldTrial::Probability>(100 * 0.56) == 56
59 // static_cast<FieldTrial::Probability>(100 * 0.57) == 56
60 // static_cast<FieldTrial::Probability>(100 * 0.58) == 57
61 // static_cast<FieldTrial::Probability>(100 * 0.59) == 59
62 const double kEpsilon = 1e-8;
63 const FieldTrial::Probability result =
64 static_cast<FieldTrial::Probability>(divisor * entropy_value + kEpsilon);
65 // Ensure that adding the epsilon still results in a value < |divisor|.
66 return std::min(result, divisor - 1);
67 }
68
69 // Parses the --force-fieldtrials string |trials_string| into |entries|.
70 // Returns true if the string was parsed correctly. On failure, the |entries|
71 // array may end up being partially filled.
ParseFieldTrialsString(const std::string & trials_string,std::vector<FieldTrial::State> * entries)72 bool ParseFieldTrialsString(const std::string& trials_string,
73 std::vector<FieldTrial::State>* entries) {
74 const StringPiece trials_string_piece(trials_string);
75
76 size_t next_item = 0;
77 while (next_item < trials_string.length()) {
78 size_t name_end = trials_string.find(kPersistentStringSeparator, next_item);
79 if (name_end == trials_string.npos || next_item == name_end)
80 return false;
81 size_t group_name_end =
82 trials_string.find(kPersistentStringSeparator, name_end + 1);
83 if (name_end + 1 == group_name_end)
84 return false;
85 if (group_name_end == trials_string.npos)
86 group_name_end = trials_string.length();
87
88 FieldTrial::State entry;
89 // Verify if the trial should be activated or not.
90 if (trials_string[next_item] == kActivationMarker) {
91 // Name cannot be only the indicator.
92 if (name_end - next_item == 1)
93 return false;
94 next_item++;
95 entry.activated = true;
96 }
97 entry.trial_name =
98 trials_string_piece.substr(next_item, name_end - next_item);
99 entry.group_name =
100 trials_string_piece.substr(name_end + 1, group_name_end - name_end - 1);
101 next_item = group_name_end + 1;
102
103 entries->push_back(entry);
104 }
105 return true;
106 }
107
108 } // namespace
109
110 // statics
111 const int FieldTrial::kNotFinalized = -1;
112 const int FieldTrial::kDefaultGroupNumber = 0;
113 bool FieldTrial::enable_benchmarking_ = false;
114
115 int FieldTrialList::kNoExpirationYear = 0;
116
117 //------------------------------------------------------------------------------
118 // FieldTrial methods and members.
119
~EntropyProvider()120 FieldTrial::EntropyProvider::~EntropyProvider() {
121 }
122
State()123 FieldTrial::State::State() : activated(false) {}
124
~State()125 FieldTrial::State::~State() {}
126
Disable()127 void FieldTrial::Disable() {
128 DCHECK(!group_reported_);
129 enable_field_trial_ = false;
130
131 // In case we are disabled after initialization, we need to switch
132 // the trial to the default group.
133 if (group_ != kNotFinalized) {
134 // Only reset when not already the default group, because in case we were
135 // forced to the default group, the group number may not be
136 // kDefaultGroupNumber, so we should keep it as is.
137 if (group_name_ != default_group_name_)
138 SetGroupChoice(default_group_name_, kDefaultGroupNumber);
139 }
140 }
141
AppendGroup(const std::string & name,Probability group_probability)142 int FieldTrial::AppendGroup(const std::string& name,
143 Probability group_probability) {
144 // When the group choice was previously forced, we only need to return the
145 // the id of the chosen group, and anything can be returned for the others.
146 if (forced_) {
147 DCHECK(!group_name_.empty());
148 if (name == group_name_) {
149 // Note that while |group_| may be equal to |kDefaultGroupNumber| on the
150 // forced trial, it will not have the same value as the default group
151 // number returned from the non-forced |FactoryGetFieldTrial()| call,
152 // which takes care to ensure that this does not happen.
153 return group_;
154 }
155 DCHECK_NE(next_group_number_, group_);
156 // We still return different numbers each time, in case some caller need
157 // them to be different.
158 return next_group_number_++;
159 }
160
161 DCHECK_LE(group_probability, divisor_);
162 DCHECK_GE(group_probability, 0);
163
164 if (enable_benchmarking_ || !enable_field_trial_)
165 group_probability = 0;
166
167 accumulated_group_probability_ += group_probability;
168
169 DCHECK_LE(accumulated_group_probability_, divisor_);
170 if (group_ == kNotFinalized && accumulated_group_probability_ > random_) {
171 // This is the group that crossed the random line, so we do the assignment.
172 SetGroupChoice(name, next_group_number_);
173 }
174 return next_group_number_++;
175 }
176
group()177 int FieldTrial::group() {
178 FinalizeGroupChoice();
179 if (trial_registered_)
180 FieldTrialList::NotifyFieldTrialGroupSelection(this);
181 return group_;
182 }
183
group_name()184 const std::string& FieldTrial::group_name() {
185 // Call |group()| to ensure group gets assigned and observers are notified.
186 group();
187 DCHECK(!group_name_.empty());
188 return group_name_;
189 }
190
GetGroupNameWithoutActivation()191 const std::string& FieldTrial::GetGroupNameWithoutActivation() {
192 FinalizeGroupChoice();
193 return group_name_;
194 }
195
SetForced()196 void FieldTrial::SetForced() {
197 // We might have been forced before (e.g., by CreateFieldTrial) and it's
198 // first come first served, e.g., command line switch has precedence.
199 if (forced_)
200 return;
201
202 // And we must finalize the group choice before we mark ourselves as forced.
203 FinalizeGroupChoice();
204 forced_ = true;
205 }
206
207 // static
EnableBenchmarking()208 void FieldTrial::EnableBenchmarking() {
209 DCHECK_EQ(0u, FieldTrialList::GetFieldTrialCount());
210 enable_benchmarking_ = true;
211 }
212
213 // static
CreateSimulatedFieldTrial(const std::string & trial_name,Probability total_probability,const std::string & default_group_name,double entropy_value)214 FieldTrial* FieldTrial::CreateSimulatedFieldTrial(
215 const std::string& trial_name,
216 Probability total_probability,
217 const std::string& default_group_name,
218 double entropy_value) {
219 return new FieldTrial(trial_name, total_probability, default_group_name,
220 entropy_value);
221 }
222
FieldTrial(const std::string & trial_name,const Probability total_probability,const std::string & default_group_name,double entropy_value)223 FieldTrial::FieldTrial(const std::string& trial_name,
224 const Probability total_probability,
225 const std::string& default_group_name,
226 double entropy_value)
227 : trial_name_(trial_name),
228 divisor_(total_probability),
229 default_group_name_(default_group_name),
230 random_(GetGroupBoundaryValue(total_probability, entropy_value)),
231 accumulated_group_probability_(0),
232 next_group_number_(kDefaultGroupNumber + 1),
233 group_(kNotFinalized),
234 enable_field_trial_(true),
235 forced_(false),
236 group_reported_(false),
237 trial_registered_(false) {
238 DCHECK_GT(total_probability, 0);
239 DCHECK(!trial_name_.empty());
240 DCHECK(!default_group_name_.empty());
241 }
242
~FieldTrial()243 FieldTrial::~FieldTrial() {}
244
SetTrialRegistered()245 void FieldTrial::SetTrialRegistered() {
246 DCHECK_EQ(kNotFinalized, group_);
247 DCHECK(!trial_registered_);
248 trial_registered_ = true;
249 }
250
SetGroupChoice(const std::string & group_name,int number)251 void FieldTrial::SetGroupChoice(const std::string& group_name, int number) {
252 group_ = number;
253 if (group_name.empty())
254 StringAppendF(&group_name_, "%d", group_);
255 else
256 group_name_ = group_name;
257 DVLOG(1) << "Field trial: " << trial_name_ << " Group choice:" << group_name_;
258 }
259
FinalizeGroupChoice()260 void FieldTrial::FinalizeGroupChoice() {
261 if (group_ != kNotFinalized)
262 return;
263 accumulated_group_probability_ = divisor_;
264 // Here it's OK to use |kDefaultGroupNumber| since we can't be forced and not
265 // finalized.
266 DCHECK(!forced_);
267 SetGroupChoice(default_group_name_, kDefaultGroupNumber);
268 }
269
GetActiveGroup(ActiveGroup * active_group) const270 bool FieldTrial::GetActiveGroup(ActiveGroup* active_group) const {
271 if (!group_reported_ || !enable_field_trial_)
272 return false;
273 DCHECK_NE(group_, kNotFinalized);
274 active_group->trial_name = trial_name_;
275 active_group->group_name = group_name_;
276 return true;
277 }
278
GetState(State * field_trial_state)279 bool FieldTrial::GetState(State* field_trial_state) {
280 if (!enable_field_trial_)
281 return false;
282 FinalizeGroupChoice();
283 field_trial_state->trial_name = trial_name_;
284 field_trial_state->group_name = group_name_;
285 field_trial_state->activated = group_reported_;
286 return true;
287 }
288
289 //------------------------------------------------------------------------------
290 // FieldTrialList methods and members.
291
292 // static
293 FieldTrialList* FieldTrialList::global_ = NULL;
294
295 // static
296 bool FieldTrialList::used_without_global_ = false;
297
~Observer()298 FieldTrialList::Observer::~Observer() {
299 }
300
FieldTrialList(const FieldTrial::EntropyProvider * entropy_provider)301 FieldTrialList::FieldTrialList(
302 const FieldTrial::EntropyProvider* entropy_provider)
303 : entropy_provider_(entropy_provider),
304 observer_list_(new ObserverListThreadSafe<FieldTrialList::Observer>(
305 ObserverListBase<FieldTrialList::Observer>::NOTIFY_EXISTING_ONLY)) {
306 DCHECK(!global_);
307 DCHECK(!used_without_global_);
308 global_ = this;
309
310 Time two_years_from_build_time = GetBuildTime() + TimeDelta::FromDays(730);
311 Time::Exploded exploded;
312 two_years_from_build_time.LocalExplode(&exploded);
313 kNoExpirationYear = exploded.year;
314 }
315
~FieldTrialList()316 FieldTrialList::~FieldTrialList() {
317 AutoLock auto_lock(lock_);
318 while (!registered_.empty()) {
319 RegistrationMap::iterator it = registered_.begin();
320 it->second->Release();
321 registered_.erase(it->first);
322 }
323 DCHECK_EQ(this, global_);
324 global_ = NULL;
325 }
326
327 // static
FactoryGetFieldTrial(const std::string & trial_name,FieldTrial::Probability total_probability,const std::string & default_group_name,const int year,const int month,const int day_of_month,FieldTrial::RandomizationType randomization_type,int * default_group_number)328 FieldTrial* FieldTrialList::FactoryGetFieldTrial(
329 const std::string& trial_name,
330 FieldTrial::Probability total_probability,
331 const std::string& default_group_name,
332 const int year,
333 const int month,
334 const int day_of_month,
335 FieldTrial::RandomizationType randomization_type,
336 int* default_group_number) {
337 return FactoryGetFieldTrialWithRandomizationSeed(
338 trial_name, total_probability, default_group_name,
339 year, month, day_of_month, randomization_type, 0, default_group_number);
340 }
341
342 // static
FactoryGetFieldTrialWithRandomizationSeed(const std::string & trial_name,FieldTrial::Probability total_probability,const std::string & default_group_name,const int year,const int month,const int day_of_month,FieldTrial::RandomizationType randomization_type,uint32_t randomization_seed,int * default_group_number)343 FieldTrial* FieldTrialList::FactoryGetFieldTrialWithRandomizationSeed(
344 const std::string& trial_name,
345 FieldTrial::Probability total_probability,
346 const std::string& default_group_name,
347 const int year,
348 const int month,
349 const int day_of_month,
350 FieldTrial::RandomizationType randomization_type,
351 uint32_t randomization_seed,
352 int* default_group_number) {
353 if (default_group_number)
354 *default_group_number = FieldTrial::kDefaultGroupNumber;
355 // Check if the field trial has already been created in some other way.
356 FieldTrial* existing_trial = Find(trial_name);
357 if (existing_trial) {
358 CHECK(existing_trial->forced_);
359 // If the default group name differs between the existing forced trial
360 // and this trial, then use a different value for the default group number.
361 if (default_group_number &&
362 default_group_name != existing_trial->default_group_name()) {
363 // If the new default group number corresponds to the group that was
364 // chosen for the forced trial (which has been finalized when it was
365 // forced), then set the default group number to that.
366 if (default_group_name == existing_trial->group_name_internal()) {
367 *default_group_number = existing_trial->group_;
368 } else {
369 // Otherwise, use |kNonConflictingGroupNumber| (-2) for the default
370 // group number, so that it does not conflict with the |AppendGroup()|
371 // result for the chosen group.
372 const int kNonConflictingGroupNumber = -2;
373 static_assert(
374 kNonConflictingGroupNumber != FieldTrial::kDefaultGroupNumber,
375 "The 'non-conflicting' group number conflicts");
376 static_assert(kNonConflictingGroupNumber != FieldTrial::kNotFinalized,
377 "The 'non-conflicting' group number conflicts");
378 *default_group_number = kNonConflictingGroupNumber;
379 }
380 }
381 return existing_trial;
382 }
383
384 double entropy_value;
385 if (randomization_type == FieldTrial::ONE_TIME_RANDOMIZED) {
386 const FieldTrial::EntropyProvider* entropy_provider =
387 GetEntropyProviderForOneTimeRandomization();
388 CHECK(entropy_provider);
389 entropy_value = entropy_provider->GetEntropyForTrial(trial_name,
390 randomization_seed);
391 } else {
392 DCHECK_EQ(FieldTrial::SESSION_RANDOMIZED, randomization_type);
393 DCHECK_EQ(0U, randomization_seed);
394 entropy_value = RandDouble();
395 }
396
397 FieldTrial* field_trial = new FieldTrial(trial_name, total_probability,
398 default_group_name, entropy_value);
399 if (GetBuildTime() > CreateTimeFromParams(year, month, day_of_month))
400 field_trial->Disable();
401 FieldTrialList::Register(field_trial);
402 return field_trial;
403 }
404
405 // static
Find(const std::string & trial_name)406 FieldTrial* FieldTrialList::Find(const std::string& trial_name) {
407 if (!global_)
408 return NULL;
409 AutoLock auto_lock(global_->lock_);
410 return global_->PreLockedFind(trial_name);
411 }
412
413 // static
FindValue(const std::string & trial_name)414 int FieldTrialList::FindValue(const std::string& trial_name) {
415 FieldTrial* field_trial = Find(trial_name);
416 if (field_trial)
417 return field_trial->group();
418 return FieldTrial::kNotFinalized;
419 }
420
421 // static
FindFullName(const std::string & trial_name)422 std::string FieldTrialList::FindFullName(const std::string& trial_name) {
423 FieldTrial* field_trial = Find(trial_name);
424 if (field_trial)
425 return field_trial->group_name();
426 return std::string();
427 }
428
429 // static
TrialExists(const std::string & trial_name)430 bool FieldTrialList::TrialExists(const std::string& trial_name) {
431 return Find(trial_name) != NULL;
432 }
433
434 // static
IsTrialActive(const std::string & trial_name)435 bool FieldTrialList::IsTrialActive(const std::string& trial_name) {
436 FieldTrial* field_trial = Find(trial_name);
437 FieldTrial::ActiveGroup active_group;
438 return field_trial && field_trial->GetActiveGroup(&active_group);
439 }
440
441 // static
StatesToString(std::string * output)442 void FieldTrialList::StatesToString(std::string* output) {
443 FieldTrial::ActiveGroups active_groups;
444 GetActiveFieldTrialGroups(&active_groups);
445 for (FieldTrial::ActiveGroups::const_iterator it = active_groups.begin();
446 it != active_groups.end(); ++it) {
447 DCHECK_EQ(std::string::npos,
448 it->trial_name.find(kPersistentStringSeparator));
449 DCHECK_EQ(std::string::npos,
450 it->group_name.find(kPersistentStringSeparator));
451 output->append(it->trial_name);
452 output->append(1, kPersistentStringSeparator);
453 output->append(it->group_name);
454 output->append(1, kPersistentStringSeparator);
455 }
456 }
457
458 // static
AllStatesToString(std::string * output)459 void FieldTrialList::AllStatesToString(std::string* output) {
460 if (!global_)
461 return;
462 AutoLock auto_lock(global_->lock_);
463
464 for (const auto& registered : global_->registered_) {
465 FieldTrial::State trial;
466 if (!registered.second->GetState(&trial))
467 continue;
468 DCHECK_EQ(std::string::npos,
469 trial.trial_name.find(kPersistentStringSeparator));
470 DCHECK_EQ(std::string::npos,
471 trial.group_name.find(kPersistentStringSeparator));
472 if (trial.activated)
473 output->append(1, kActivationMarker);
474 trial.trial_name.AppendToString(output);
475 output->append(1, kPersistentStringSeparator);
476 trial.group_name.AppendToString(output);
477 output->append(1, kPersistentStringSeparator);
478 }
479 }
480
481 // static
GetActiveFieldTrialGroups(FieldTrial::ActiveGroups * active_groups)482 void FieldTrialList::GetActiveFieldTrialGroups(
483 FieldTrial::ActiveGroups* active_groups) {
484 DCHECK(active_groups->empty());
485 if (!global_)
486 return;
487 AutoLock auto_lock(global_->lock_);
488
489 for (RegistrationMap::iterator it = global_->registered_.begin();
490 it != global_->registered_.end(); ++it) {
491 FieldTrial::ActiveGroup active_group;
492 if (it->second->GetActiveGroup(&active_group))
493 active_groups->push_back(active_group);
494 }
495 }
496
497 // static
GetActiveFieldTrialGroupsFromString(const std::string & trials_string,FieldTrial::ActiveGroups * active_groups)498 void FieldTrialList::GetActiveFieldTrialGroupsFromString(
499 const std::string& trials_string,
500 FieldTrial::ActiveGroups* active_groups) {
501 std::vector<FieldTrial::State> entries;
502 if (!ParseFieldTrialsString(trials_string, &entries))
503 return;
504
505 for (const auto& entry : entries) {
506 if (entry.activated) {
507 FieldTrial::ActiveGroup group;
508 group.trial_name = entry.trial_name.as_string();
509 group.group_name = entry.group_name.as_string();
510 active_groups->push_back(group);
511 }
512 }
513 }
514
515 // static
CreateTrialsFromString(const std::string & trials_string,FieldTrialActivationMode mode,const std::set<std::string> & ignored_trial_names)516 bool FieldTrialList::CreateTrialsFromString(
517 const std::string& trials_string,
518 FieldTrialActivationMode mode,
519 const std::set<std::string>& ignored_trial_names) {
520 DCHECK(global_);
521 if (trials_string.empty() || !global_)
522 return true;
523
524 std::vector<FieldTrial::State> entries;
525 if (!ParseFieldTrialsString(trials_string, &entries))
526 return false;
527
528 for (const auto& entry : entries) {
529 const std::string trial_name = entry.trial_name.as_string();
530 const std::string group_name = entry.group_name.as_string();
531
532 if (ContainsKey(ignored_trial_names, trial_name))
533 continue;
534
535 FieldTrial* trial = CreateFieldTrial(trial_name, group_name);
536 if (!trial)
537 return false;
538 if (mode == ACTIVATE_TRIALS || entry.activated) {
539 // Call |group()| to mark the trial as "used" and notify observers, if
540 // any. This is useful to ensure that field trials created in child
541 // processes are properly reported in crash reports.
542 trial->group();
543 }
544 }
545 return true;
546 }
547
548 // static
CreateFieldTrial(const std::string & name,const std::string & group_name)549 FieldTrial* FieldTrialList::CreateFieldTrial(
550 const std::string& name,
551 const std::string& group_name) {
552 DCHECK(global_);
553 DCHECK_GE(name.size(), 0u);
554 DCHECK_GE(group_name.size(), 0u);
555 if (name.empty() || group_name.empty() || !global_)
556 return NULL;
557
558 FieldTrial* field_trial = FieldTrialList::Find(name);
559 if (field_trial) {
560 // In single process mode, or when we force them from the command line,
561 // we may have already created the field trial.
562 if (field_trial->group_name_internal() != group_name)
563 return NULL;
564 return field_trial;
565 }
566 const int kTotalProbability = 100;
567 field_trial = new FieldTrial(name, kTotalProbability, group_name, 0);
568 FieldTrialList::Register(field_trial);
569 // Force the trial, which will also finalize the group choice.
570 field_trial->SetForced();
571 return field_trial;
572 }
573
574 // static
AddObserver(Observer * observer)575 void FieldTrialList::AddObserver(Observer* observer) {
576 if (!global_)
577 return;
578 global_->observer_list_->AddObserver(observer);
579 }
580
581 // static
RemoveObserver(Observer * observer)582 void FieldTrialList::RemoveObserver(Observer* observer) {
583 if (!global_)
584 return;
585 global_->observer_list_->RemoveObserver(observer);
586 }
587
588 // static
NotifyFieldTrialGroupSelection(FieldTrial * field_trial)589 void FieldTrialList::NotifyFieldTrialGroupSelection(FieldTrial* field_trial) {
590 if (!global_)
591 return;
592
593 {
594 AutoLock auto_lock(global_->lock_);
595 if (field_trial->group_reported_)
596 return;
597 field_trial->group_reported_ = true;
598 }
599
600 if (!field_trial->enable_field_trial_)
601 return;
602
603 global_->observer_list_->Notify(
604 FROM_HERE, &FieldTrialList::Observer::OnFieldTrialGroupFinalized,
605 field_trial->trial_name(), field_trial->group_name_internal());
606 }
607
608 // static
GetFieldTrialCount()609 size_t FieldTrialList::GetFieldTrialCount() {
610 if (!global_)
611 return 0;
612 AutoLock auto_lock(global_->lock_);
613 return global_->registered_.size();
614 }
615
616 // static
617 const FieldTrial::EntropyProvider*
GetEntropyProviderForOneTimeRandomization()618 FieldTrialList::GetEntropyProviderForOneTimeRandomization() {
619 if (!global_) {
620 used_without_global_ = true;
621 return NULL;
622 }
623
624 return global_->entropy_provider_.get();
625 }
626
PreLockedFind(const std::string & name)627 FieldTrial* FieldTrialList::PreLockedFind(const std::string& name) {
628 RegistrationMap::iterator it = registered_.find(name);
629 if (registered_.end() == it)
630 return NULL;
631 return it->second;
632 }
633
634 // static
Register(FieldTrial * trial)635 void FieldTrialList::Register(FieldTrial* trial) {
636 if (!global_) {
637 used_without_global_ = true;
638 return;
639 }
640 AutoLock auto_lock(global_->lock_);
641 DCHECK(!global_->PreLockedFind(trial->trial_name()));
642 trial->AddRef();
643 trial->SetTrialRegistered();
644 global_->registered_[trial->trial_name()] = trial;
645 }
646
647 } // namespace base
648