| 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 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 // Sets the group_name as well as group_name_hash to make sure they are sync. | 210 // Sets the group_name as well as group_name_hash to make sure they are sync. |
| 211 void SetGroupChoice(const std::string& name, int number); | 211 void SetGroupChoice(const std::string& name, int number); |
| 212 | 212 |
| 213 // Ensures that a group is chosen, if it hasn't yet been. The field trial | 213 // Ensures that a group is chosen, if it hasn't yet been. The field trial |
| 214 // might yet be disabled, so this call will *not* notify observers of the | 214 // might yet be disabled, so this call will *not* notify observers of the |
| 215 // status. | 215 // status. |
| 216 void FinalizeGroupChoice(); | 216 void FinalizeGroupChoice(); |
| 217 | 217 |
| 218 // Returns the trial name and selected group name for this field trial via | 218 // Returns the trial name and selected group name for this field trial via |
| 219 // the output parameter |active_group|, but only if the group has already | 219 // the output parameter |active_group|, but only if the group has already |
| 220 // been chosen and has been externally observed via |group()|. In that case, | 220 // been chosen and has been externally observed via |group()| and the trial |
| 221 // true is returned and |active_group| is filled in; otherwise, the result | 221 // has not been disabled. In that case, true is returned and |active_group| |
| 222 // is false and |active_group| is left untouched. | 222 // is filled in; otherwise, the result is false and |active_group| is left |
| 223 // untouched. |
| 223 bool GetActiveGroup(ActiveGroup* active_group) const; | 224 bool GetActiveGroup(ActiveGroup* active_group) const; |
| 224 | 225 |
| 225 // Returns the group_name. A winner need not have been chosen. | 226 // Returns the group_name. A winner need not have been chosen. |
| 226 std::string group_name_internal() const { return group_name_; } | 227 std::string group_name_internal() const { return group_name_; } |
| 227 | 228 |
| 228 // The name of the field trial, as can be found via the FieldTrialList. | 229 // The name of the field trial, as can be found via the FieldTrialList. |
| 229 const std::string name_; | 230 const std::string name_; |
| 230 | 231 |
| 231 // The maximum sum of all probabilities supplied, which corresponds to 100%. | 232 // The maximum sum of all probabilities supplied, which corresponds to 100%. |
| 232 // This is the scaling factor used to adjust supplied probabilities. | 233 // This is the scaling factor used to adjust supplied probabilities. |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 static std::string FindFullName(const std::string& name); | 349 static std::string FindFullName(const std::string& name); |
| 349 | 350 |
| 350 // Returns true if the named trial has been registered. | 351 // Returns true if the named trial has been registered. |
| 351 static bool TrialExists(const std::string& name); | 352 static bool TrialExists(const std::string& name); |
| 352 | 353 |
| 353 // Creates a persistent representation of active FieldTrial instances for | 354 // Creates a persistent representation of active FieldTrial instances for |
| 354 // resurrection in another process. This allows randomization to be done in | 355 // resurrection in another process. This allows randomization to be done in |
| 355 // one process, and secondary processes can be synchronized on the result. | 356 // one process, and secondary processes can be synchronized on the result. |
| 356 // The resulting string contains the name and group name pairs of all | 357 // The resulting string contains the name and group name pairs of all |
| 357 // registered FieldTrials for which the group has been chosen and externally | 358 // registered FieldTrials for which the group has been chosen and externally |
| 358 // observed (via |group()|), with "/" used to separate all names and to | 359 // observed (via |group()|) and which have not been disabled, with "/" used |
| 359 // terminate the string. This string is parsed by |CreateTrialsFromString()|. | 360 // to separate all names and to terminate the string. This string is parsed |
| 361 // by |CreateTrialsFromString()|. |
| 360 static void StatesToString(std::string* output); | 362 static void StatesToString(std::string* output); |
| 361 | 363 |
| 362 // Fills in the supplied vector |active_groups| (which must be empty when | 364 // Fills in the supplied vector |active_groups| (which must be empty when |
| 363 // called) with a snapshot of all registered FieldTrials for which the group | 365 // called) with a snapshot of all registered FieldTrials for which the group |
| 364 // has been chosen and externally observed (via |group()|). | 366 // has been chosen and externally observed (via |group()|) and which have |
| 367 // not been disabled. |
| 365 static void GetActiveFieldTrialGroups( | 368 static void GetActiveFieldTrialGroups( |
| 366 FieldTrial::ActiveGroups* active_groups); | 369 FieldTrial::ActiveGroups* active_groups); |
| 367 | 370 |
| 368 // Use a state string (re: StatesToString()) to augment the current list of | 371 // Use a state string (re: StatesToString()) to augment the current list of |
| 369 // field tests to include the supplied tests, and using a 100% probability for | 372 // field tests to include the supplied tests, and using a 100% probability for |
| 370 // each test, force them to have the same group string. This is commonly used | 373 // each test, force them to have the same group string. This is commonly used |
| 371 // in a non-browser process, to carry randomly selected state in a browser | 374 // in a non-browser process, to carry randomly selected state in a browser |
| 372 // process into this non-browser process, but could also be invoked through a | 375 // process into this non-browser process, but could also be invoked through a |
| 373 // command line argument to the browser process. | 376 // command line argument to the browser process. |
| 374 static bool CreateTrialsFromString(const std::string& prior_trials); | 377 static bool CreateTrialsFromString(const std::string& prior_trials); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 | 435 |
| 433 // List of observers to be notified when a group is selected for a FieldTrial. | 436 // List of observers to be notified when a group is selected for a FieldTrial. |
| 434 scoped_refptr<ObserverListThreadSafe<Observer> > observer_list_; | 437 scoped_refptr<ObserverListThreadSafe<Observer> > observer_list_; |
| 435 | 438 |
| 436 DISALLOW_COPY_AND_ASSIGN(FieldTrialList); | 439 DISALLOW_COPY_AND_ASSIGN(FieldTrialList); |
| 437 }; | 440 }; |
| 438 | 441 |
| 439 } // namespace base | 442 } // namespace base |
| 440 | 443 |
| 441 #endif // BASE_METRICS_FIELD_TRIAL_H_ | 444 #endif // BASE_METRICS_FIELD_TRIAL_H_ |
| OLD | NEW |