OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/logging.h" | 7 #include "base/logging.h" |
8 #include "base/rand_util.h" | 8 #include "base/rand_util.h" |
9 #include "base/sha1.h" | 9 #include "base/sha1.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
362 // static | 362 // static |
363 size_t FieldTrialList::GetFieldTrialCount() { | 363 size_t FieldTrialList::GetFieldTrialCount() { |
364 if (!global_) | 364 if (!global_) |
365 return 0; | 365 return 0; |
366 AutoLock auto_lock(global_->lock_); | 366 AutoLock auto_lock(global_->lock_); |
367 return global_->registered_.size(); | 367 return global_->registered_.size(); |
368 } | 368 } |
369 | 369 |
370 // static | 370 // static |
371 bool FieldTrialList::IsOneTimeRandomizationEnabled() { | 371 bool FieldTrialList::IsOneTimeRandomizationEnabled() { |
372 DCHECK(global_); | 372 // This can occur in valid cases, e.g. when certain unit tests initialize |
jar (doing other things)
2011/06/16 18:50:12
NIT: Ok... based on phone chat, I'm fine with remo
| |
373 // and tickle code that wants to set up a trial only if one-time | |
374 // randomization is supported, so we do not DCHECK. | |
jar (doing other things)
2011/06/12 06:49:12
Why is it valuable to test in this mode, and not i
Jói
2011/06/13 17:27:14
That's just it, this is the method my field trial
jar (doing other things)
2011/06/14 02:28:46
The common(?) error case is for someone to place a
| |
373 if (!global_) | 375 if (!global_) |
374 return false; | 376 return false; |
375 | 377 |
376 return !global_->client_id_.empty(); | 378 return !global_->client_id_.empty(); |
377 } | 379 } |
378 | 380 |
379 // static | 381 // static |
380 const std::string& FieldTrialList::client_id() { | 382 const std::string& FieldTrialList::client_id() { |
381 DCHECK(global_); | 383 DCHECK(global_); |
382 if (!global_) | 384 if (!global_) |
383 return EmptyString(); | 385 return EmptyString(); |
384 | 386 |
385 return global_->client_id_; | 387 return global_->client_id_; |
386 } | 388 } |
387 | 389 |
388 FieldTrial* FieldTrialList::PreLockedFind(const std::string& name) { | 390 FieldTrial* FieldTrialList::PreLockedFind(const std::string& name) { |
389 RegistrationList::iterator it = registered_.find(name); | 391 RegistrationList::iterator it = registered_.find(name); |
390 if (registered_.end() == it) | 392 if (registered_.end() == it) |
391 return NULL; | 393 return NULL; |
392 return it->second; | 394 return it->second; |
393 } | 395 } |
394 | 396 |
395 } // namespace base | 397 } // namespace base |
OLD | NEW |