OLD | NEW |
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 // FieldTrial is a class for handling details of statistical experiments | 5 // FieldTrial is a class for handling details of statistical experiments |
6 // performed by actual users in the field (i.e., in a shipped or beta product). | 6 // performed by actual users in the field (i.e., in a shipped or beta product). |
7 // All code is called exclusively on the UI thread currently. | 7 // All code is called exclusively on the UI thread currently. |
8 // | 8 // |
9 // The simplest example is an experiment to see whether one of two options | 9 // The simplest example is an experiment to see whether one of two options |
10 // produces "better" results across our user population. In that scenario, UMA | 10 // produces "better" results across our user population. In that scenario, UMA |
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 const std::string& trial_name, | 389 const std::string& trial_name, |
390 FieldTrial::Probability total_probability, | 390 FieldTrial::Probability total_probability, |
391 const std::string& default_group_name, | 391 const std::string& default_group_name, |
392 const int year, | 392 const int year, |
393 const int month, | 393 const int month, |
394 const int day_of_month, | 394 const int day_of_month, |
395 FieldTrial::RandomizationType randomization_type, | 395 FieldTrial::RandomizationType randomization_type, |
396 uint32 randomization_seed, | 396 uint32 randomization_seed, |
397 int* default_group_number); | 397 int* default_group_number); |
398 | 398 |
399 // The Find() method can be used to test to see if a named Trial was already | 399 // The Find() method can be used to test to see if a named trial was already |
400 // registered, or to retrieve a pointer to it from the global map. | 400 // registered, or to retrieve a pointer to it from the global map. |
401 static FieldTrial* Find(const std::string& name); | 401 static FieldTrial* Find(const std::string& trial_name); |
402 | 402 |
403 // Returns the group number chosen for the named trial, or | 403 // Returns the group number chosen for the named trial, or |
404 // FieldTrial::kNotFinalized if the trial does not exist. | 404 // FieldTrial::kNotFinalized if the trial does not exist. |
405 static int FindValue(const std::string& name); | 405 static int FindValue(const std::string& trial_name); |
406 | 406 |
407 // Returns the group name chosen for the named trial, or the empty string if | 407 // Returns the group name chosen for the named trial, or the empty string if |
408 // the trial does not exist. The first call of this function on a given field | 408 // the trial does not exist. The first call of this function on a given field |
409 // trial will mark it as active, so that its state will be reported with usage | 409 // trial will mark it as active, so that its state will be reported with usage |
410 // metrics, crashes, etc. | 410 // metrics, crashes, etc. |
411 static std::string FindFullName(const std::string& name); | 411 static std::string FindFullName(const std::string& trial_name); |
412 | 412 |
413 // Returns true if the named trial has been registered. | 413 // Returns true if the named trial has been registered. |
414 static bool TrialExists(const std::string& name); | 414 static bool TrialExists(const std::string& trial_name); |
| 415 |
| 416 // Returns true if the named trial exists and has been activated. |
| 417 static bool IsTrialActive(const std::string& trial_name); |
415 | 418 |
416 // Creates a persistent representation of active FieldTrial instances for | 419 // Creates a persistent representation of active FieldTrial instances for |
417 // resurrection in another process. This allows randomization to be done in | 420 // resurrection in another process. This allows randomization to be done in |
418 // one process, and secondary processes can be synchronized on the result. | 421 // one process, and secondary processes can be synchronized on the result. |
419 // The resulting string contains the name and group name pairs of all | 422 // The resulting string contains the name and group name pairs of all |
420 // registered FieldTrials for which the group has been chosen and externally | 423 // registered FieldTrials for which the group has been chosen and externally |
421 // observed (via |group()|) and which have not been disabled, with "/" used | 424 // observed (via |group()|) and which have not been disabled, with "/" used |
422 // to separate all names and to terminate the string. This string is parsed | 425 // to separate all names and to terminate the string. This string is parsed |
423 // by |CreateTrialsFromString()|. | 426 // by |CreateTrialsFromString()|. |
424 static void StatesToString(std::string* output); | 427 static void StatesToString(std::string* output); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
513 | 516 |
514 // List of observers to be notified when a group is selected for a FieldTrial. | 517 // List of observers to be notified when a group is selected for a FieldTrial. |
515 scoped_refptr<ObserverListThreadSafe<Observer> > observer_list_; | 518 scoped_refptr<ObserverListThreadSafe<Observer> > observer_list_; |
516 | 519 |
517 DISALLOW_COPY_AND_ASSIGN(FieldTrialList); | 520 DISALLOW_COPY_AND_ASSIGN(FieldTrialList); |
518 }; | 521 }; |
519 | 522 |
520 } // namespace base | 523 } // namespace base |
521 | 524 |
522 #endif // BASE_METRICS_FIELD_TRIAL_H_ | 525 #endif // BASE_METRICS_FIELD_TRIAL_H_ |
OLD | NEW |