| 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 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 | 288 |
| 289 DISALLOW_COPY_AND_ASSIGN(FieldTrial); | 289 DISALLOW_COPY_AND_ASSIGN(FieldTrial); |
| 290 }; | 290 }; |
| 291 | 291 |
| 292 //------------------------------------------------------------------------------ | 292 //------------------------------------------------------------------------------ |
| 293 // Class with a list of all active field trials. A trial is active if it has | 293 // Class with a list of all active field trials. A trial is active if it has |
| 294 // been registered, which includes evaluating its state based on its probaility. | 294 // been registered, which includes evaluating its state based on its probaility. |
| 295 // Only one instance of this class exists. | 295 // Only one instance of this class exists. |
| 296 class BASE_EXPORT FieldTrialList { | 296 class BASE_EXPORT FieldTrialList { |
| 297 public: | 297 public: |
| 298 // Specifies whether field trials should be activated (marked as "used"), when |
| 299 // created using |CreateTrialsFromString()|. |
| 300 enum FieldTrialActivationMode { |
| 301 DONT_ACTIVATE_TRIALS, |
| 302 ACTIVATE_TRIALS, |
| 303 }; |
| 304 |
| 298 // Define a separator character to use when creating a persistent form of an | 305 // Define a separator character to use when creating a persistent form of an |
| 299 // instance. This is intended for use as a command line argument, passed to a | 306 // instance. This is intended for use as a command line argument, passed to a |
| 300 // second process to mimic our state (i.e., provide the same group name). | 307 // second process to mimic our state (i.e., provide the same group name). |
| 301 static const char kPersistentStringSeparator; // Currently a slash. | 308 static const char kPersistentStringSeparator; // Currently a slash. |
| 302 | 309 |
| 303 // 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 |
| 304 // via |FactoryGetFieldTrial()|. Set to two years from the build date. | 311 // via |FactoryGetFieldTrial()|. Set to two years from the build date. |
| 305 static int kNoExpirationYear; | 312 static int kNoExpirationYear; |
| 306 | 313 |
| 307 // Observer is notified when a FieldTrial's group is selected. | 314 // Observer is notified when a FieldTrial's group is selected. |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 // not been disabled. | 392 // not been disabled. |
| 386 static void GetActiveFieldTrialGroups( | 393 static void GetActiveFieldTrialGroups( |
| 387 FieldTrial::ActiveGroups* active_groups); | 394 FieldTrial::ActiveGroups* active_groups); |
| 388 | 395 |
| 389 // Use a state string (re: StatesToString()) to augment the current list of | 396 // Use a state string (re: StatesToString()) to augment the current list of |
| 390 // field trials to include the supplied trials, and using a 100% probability | 397 // field trials to include the supplied trials, and using a 100% probability |
| 391 // for each trial, force them to have the same group string. This is commonly | 398 // for each trial, force them to have the same group string. This is commonly |
| 392 // used in a non-browser process, to carry randomly selected state in a | 399 // used in a non-browser process, to carry randomly selected state in a |
| 393 // browser process into this non-browser process, but could also be invoked | 400 // browser process into this non-browser process, but could also be invoked |
| 394 // through a command line argument to the browser process. The created field | 401 // through a command line argument to the browser process. The created field |
| 395 // trials are marked as "used" for the purposes of active trial reporting. | 402 // trials are marked as "used" for the purposes of active trial reporting if |
| 396 static bool CreateTrialsFromString(const std::string& prior_trials); | 403 // |mode| is ACTIVATE_TRIALS. |
| 404 static bool CreateTrialsFromString(const std::string& prior_trials, |
| 405 FieldTrialActivationMode mode); |
| 397 | 406 |
| 398 // Create a FieldTrial with the given |name| and using 100% probability for | 407 // Create a FieldTrial with the given |name| and using 100% probability for |
| 399 // the FieldTrial, force FieldTrial to have the same group string as | 408 // the FieldTrial, force FieldTrial to have the same group string as |
| 400 // |group_name|. This is commonly used in a non-browser process, to carry | 409 // |group_name|. This is commonly used in a non-browser process, to carry |
| 401 // randomly selected state in a browser process into this non-browser process. | 410 // randomly selected state in a browser process into this non-browser process. |
| 402 // It returns NULL if there is a FieldTrial that is already registered with | 411 // It returns NULL if there is a FieldTrial that is already registered with |
| 403 // the same |name| but has different finalized group string (|group_name|). | 412 // the same |name| but has different finalized group string (|group_name|). |
| 404 static FieldTrial* CreateFieldTrial(const std::string& name, | 413 static FieldTrial* CreateFieldTrial(const std::string& name, |
| 405 const std::string& group_name); | 414 const std::string& group_name); |
| 406 | 415 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 | 462 |
| 454 // List of observers to be notified when a group is selected for a FieldTrial. | 463 // List of observers to be notified when a group is selected for a FieldTrial. |
| 455 scoped_refptr<ObserverListThreadSafe<Observer> > observer_list_; | 464 scoped_refptr<ObserverListThreadSafe<Observer> > observer_list_; |
| 456 | 465 |
| 457 DISALLOW_COPY_AND_ASSIGN(FieldTrialList); | 466 DISALLOW_COPY_AND_ASSIGN(FieldTrialList); |
| 458 }; | 467 }; |
| 459 | 468 |
| 460 } // namespace base | 469 } // namespace base |
| 461 | 470 |
| 462 #endif // BASE_METRICS_FIELD_TRIAL_H_ | 471 #endif // BASE_METRICS_FIELD_TRIAL_H_ |
| OLD | NEW |