| 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 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 DISALLOW_COPY_AND_ASSIGN(FieldTrial); | 284 DISALLOW_COPY_AND_ASSIGN(FieldTrial); |
| 285 }; | 285 }; |
| 286 | 286 |
| 287 //------------------------------------------------------------------------------ | 287 //------------------------------------------------------------------------------ |
| 288 // Class with a list of all active field trials. A trial is active if it has | 288 // Class with a list of all active field trials. A trial is active if it has |
| 289 // been registered, which includes evaluating its state based on its probaility. | 289 // been registered, which includes evaluating its state based on its probaility. |
| 290 // Only one instance of this class exists. | 290 // Only one instance of this class exists. |
| 291 class BASE_EXPORT FieldTrialList { | 291 class BASE_EXPORT FieldTrialList { |
| 292 public: | 292 public: |
| 293 // Specifies whether field trials should be activated (marked as "used"), when | 293 // Specifies whether field trials should be activated (marked as "used"), when |
| 294 // created using |CreateTrialsFromString()|. | 294 // created using |CreateTrialsFromString()|. Has no effect on trials that are |
| 295 // prefixed with |kActivationMarker|, which will always be activated." |
| 295 enum FieldTrialActivationMode { | 296 enum FieldTrialActivationMode { |
| 296 DONT_ACTIVATE_TRIALS, | 297 DONT_ACTIVATE_TRIALS, |
| 297 ACTIVATE_TRIALS, | 298 ACTIVATE_TRIALS, |
| 298 }; | 299 }; |
| 299 | 300 |
| 300 // Define a separator character to use when creating a persistent form of an | 301 // Define a separator character to use when creating a persistent form of an |
| 301 // instance. This is intended for use as a command line argument, passed to a | 302 // instance. This is intended for use as a command line argument, passed to a |
| 302 // second process to mimic our state (i.e., provide the same group name). | 303 // second process to mimic our state (i.e., provide the same group name). |
| 303 static const char kPersistentStringSeparator; // Currently a slash. | 304 static const char kPersistentStringSeparator; // Currently a slash. |
| 304 | 305 |
| 306 // Define a marker character to be used as a prefix to a trial name on the |
| 307 // command line which forces its activation. |
| 308 static const char kActivationMarker; // Currently an asterisk. |
| 309 |
| 305 // Year that is guaranteed to not be expired when instantiating a field trial | 310 // Year that is guaranteed to not be expired when instantiating a field trial |
| 306 // via |FactoryGetFieldTrial()|. Set to two years from the build date. | 311 // via |FactoryGetFieldTrial()|. Set to two years from the build date. |
| 307 static int kNoExpirationYear; | 312 static int kNoExpirationYear; |
| 308 | 313 |
| 309 // Observer is notified when a FieldTrial's group is selected. | 314 // Observer is notified when a FieldTrial's group is selected. |
| 310 class BASE_EXPORT Observer { | 315 class BASE_EXPORT Observer { |
| 311 public: | 316 public: |
| 312 // Notify observers when FieldTrials's group is selected. | 317 // Notify observers when FieldTrials's group is selected. |
| 313 virtual void OnFieldTrialGroupFinalized(const std::string& trial_name, | 318 virtual void OnFieldTrialGroupFinalized(const std::string& trial_name, |
| 314 const std::string& group_name) = 0; | 319 const std::string& group_name) = 0; |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 // not been disabled. | 410 // not been disabled. |
| 406 static void GetActiveFieldTrialGroups( | 411 static void GetActiveFieldTrialGroups( |
| 407 FieldTrial::ActiveGroups* active_groups); | 412 FieldTrial::ActiveGroups* active_groups); |
| 408 | 413 |
| 409 // Use a state string (re: StatesToString()) to augment the current list of | 414 // Use a state string (re: StatesToString()) to augment the current list of |
| 410 // field trials to include the supplied trials, and using a 100% probability | 415 // field trials to include the supplied trials, and using a 100% probability |
| 411 // for each trial, force them to have the same group string. This is commonly | 416 // for each trial, force them to have the same group string. This is commonly |
| 412 // used in a non-browser process, to carry randomly selected state in a | 417 // used in a non-browser process, to carry randomly selected state in a |
| 413 // browser process into this non-browser process, but could also be invoked | 418 // browser process into this non-browser process, but could also be invoked |
| 414 // through a command line argument to the browser process. The created field | 419 // through a command line argument to the browser process. The created field |
| 415 // trials are marked as "used" for the purposes of active trial reporting if | 420 // trials are all marked as "used" for the purposes of active trial reporting |
| 416 // |mode| is ACTIVATE_TRIALS. Trial names in |ignored_trial_names| are ignored | 421 // if |mode| is ACTIVATE_TRIALS, otherwise each trial will be marked as "used" |
| 417 // when parsing |prior_trials|. | 422 // if it is prefixed with |kActivationMarker|. Trial names in |
| 423 // |ignored_trial_names| are ignored when parsing |prior_trials|. |
| 418 static bool CreateTrialsFromString( | 424 static bool CreateTrialsFromString( |
| 419 const std::string& prior_trials, | 425 const std::string& prior_trials, |
| 420 FieldTrialActivationMode mode, | 426 FieldTrialActivationMode mode, |
| 421 const std::set<std::string>& ignored_trial_names); | 427 const std::set<std::string>& ignored_trial_names); |
| 422 | 428 |
| 423 // Create a FieldTrial with the given |name| and using 100% probability for | 429 // Create a FieldTrial with the given |name| and using 100% probability for |
| 424 // the FieldTrial, force FieldTrial to have the same group string as | 430 // the FieldTrial, force FieldTrial to have the same group string as |
| 425 // |group_name|. This is commonly used in a non-browser process, to carry | 431 // |group_name|. This is commonly used in a non-browser process, to carry |
| 426 // randomly selected state in a browser process into this non-browser process. | 432 // randomly selected state in a browser process into this non-browser process. |
| 427 // It returns NULL if there is a FieldTrial that is already registered with | 433 // It returns NULL if there is a FieldTrial that is already registered with |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 | 484 |
| 479 // List of observers to be notified when a group is selected for a FieldTrial. | 485 // List of observers to be notified when a group is selected for a FieldTrial. |
| 480 scoped_refptr<ObserverListThreadSafe<Observer> > observer_list_; | 486 scoped_refptr<ObserverListThreadSafe<Observer> > observer_list_; |
| 481 | 487 |
| 482 DISALLOW_COPY_AND_ASSIGN(FieldTrialList); | 488 DISALLOW_COPY_AND_ASSIGN(FieldTrialList); |
| 483 }; | 489 }; |
| 484 | 490 |
| 485 } // namespace base | 491 } // namespace base |
| 486 | 492 |
| 487 #endif // BASE_METRICS_FIELD_TRIAL_H_ | 493 #endif // BASE_METRICS_FIELD_TRIAL_H_ |
| OLD | NEW |