Chromium Code Reviews| 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 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 282 | 282 |
| 283 DISALLOW_COPY_AND_ASSIGN(FieldTrial); | 283 DISALLOW_COPY_AND_ASSIGN(FieldTrial); |
| 284 }; | 284 }; |
| 285 | 285 |
| 286 //------------------------------------------------------------------------------ | 286 //------------------------------------------------------------------------------ |
| 287 // Class with a list of all active field trials. A trial is active if it has | 287 // Class with a list of all active field trials. A trial is active if it has |
| 288 // been registered, which includes evaluating its state based on its probaility. | 288 // been registered, which includes evaluating its state based on its probaility. |
| 289 // Only one instance of this class exists. | 289 // Only one instance of this class exists. |
| 290 class BASE_EXPORT FieldTrialList { | 290 class BASE_EXPORT FieldTrialList { |
| 291 public: | 291 public: |
| 292 // A callback that returns true if |name| describes a field trial that should | |
| 293 // be accepted by the method it was passed to. | |
| 294 typedef base::Callback<bool(const std::string& name)> | |
|
Alexei Svitkine (slow)
2014/02/11 22:44:02
The header for this should probably be included.
gab
2014/02/11 22:53:55
Done.
| |
| 295 IsAcceptedFieldTrialCallback; | |
| 296 | |
| 292 // Specifies whether field trials should be activated (marked as "used"), when | 297 // Specifies whether field trials should be activated (marked as "used"), when |
| 293 // created using |CreateTrialsFromString()|. | 298 // created using |CreateTrialsFromString()|. |
| 294 enum FieldTrialActivationMode { | 299 enum FieldTrialActivationMode { |
| 295 DONT_ACTIVATE_TRIALS, | 300 DONT_ACTIVATE_TRIALS, |
| 296 ACTIVATE_TRIALS, | 301 ACTIVATE_TRIALS, |
| 297 }; | 302 }; |
| 298 | 303 |
| 299 // Define a separator character to use when creating a persistent form of an | 304 // Define a separator character to use when creating a persistent form of an |
| 300 // instance. This is intended for use as a command line argument, passed to a | 305 // instance. This is intended for use as a command line argument, passed to a |
| 301 // second process to mimic our state (i.e., provide the same group name). | 306 // second process to mimic our state (i.e., provide the same group name). |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 405 static void GetActiveFieldTrialGroups( | 410 static void GetActiveFieldTrialGroups( |
| 406 FieldTrial::ActiveGroups* active_groups); | 411 FieldTrial::ActiveGroups* active_groups); |
| 407 | 412 |
| 408 // Use a state string (re: StatesToString()) to augment the current list of | 413 // Use a state string (re: StatesToString()) to augment the current list of |
| 409 // field trials to include the supplied trials, and using a 100% probability | 414 // field trials to include the supplied trials, and using a 100% probability |
| 410 // for each trial, force them to have the same group string. This is commonly | 415 // for each trial, force them to have the same group string. This is commonly |
| 411 // used in a non-browser process, to carry randomly selected state in a | 416 // used in a non-browser process, to carry randomly selected state in a |
| 412 // browser process into this non-browser process, but could also be invoked | 417 // browser process into this non-browser process, but could also be invoked |
| 413 // through a command line argument to the browser process. The created field | 418 // through a command line argument to the browser process. The created field |
| 414 // trials are marked as "used" for the purposes of active trial reporting if | 419 // trials are marked as "used" for the purposes of active trial reporting if |
| 415 // |mode| is ACTIVATE_TRIALS. | 420 // |mode| is ACTIVATE_TRIALS. If |is_accepted_callback| is not null: field |
| 416 static bool CreateTrialsFromString(const std::string& prior_trials, | 421 // trials for which |is_accepted_callback| returns false are ignored. |
| 417 FieldTrialActivationMode mode); | 422 static bool CreateTrialsFromString( |
| 423 const std::string& prior_trials, | |
| 424 FieldTrialActivationMode mode, | |
| 425 const IsAcceptedFieldTrialCallback& is_accepted_callback); | |
| 418 | 426 |
| 419 // Create a FieldTrial with the given |name| and using 100% probability for | 427 // Create a FieldTrial with the given |name| and using 100% probability for |
| 420 // the FieldTrial, force FieldTrial to have the same group string as | 428 // the FieldTrial, force FieldTrial to have the same group string as |
| 421 // |group_name|. This is commonly used in a non-browser process, to carry | 429 // |group_name|. This is commonly used in a non-browser process, to carry |
| 422 // randomly selected state in a browser process into this non-browser process. | 430 // randomly selected state in a browser process into this non-browser process. |
| 423 // It returns NULL if there is a FieldTrial that is already registered with | 431 // It returns NULL if there is a FieldTrial that is already registered with |
| 424 // the same |name| but has different finalized group string (|group_name|). | 432 // the same |name| but has different finalized group string (|group_name|). |
| 425 static FieldTrial* CreateFieldTrial(const std::string& name, | 433 static FieldTrial* CreateFieldTrial(const std::string& name, |
| 426 const std::string& group_name); | 434 const std::string& group_name); |
| 427 | 435 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 474 | 482 |
| 475 // List of observers to be notified when a group is selected for a FieldTrial. | 483 // List of observers to be notified when a group is selected for a FieldTrial. |
| 476 scoped_refptr<ObserverListThreadSafe<Observer> > observer_list_; | 484 scoped_refptr<ObserverListThreadSafe<Observer> > observer_list_; |
| 477 | 485 |
| 478 DISALLOW_COPY_AND_ASSIGN(FieldTrialList); | 486 DISALLOW_COPY_AND_ASSIGN(FieldTrialList); |
| 479 }; | 487 }; |
| 480 | 488 |
| 481 } // namespace base | 489 } // namespace base |
| 482 | 490 |
| 483 #endif // BASE_METRICS_FIELD_TRIAL_H_ | 491 #endif // BASE_METRICS_FIELD_TRIAL_H_ |
| OLD | NEW |