Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(134)

Side by Side Diff: base/metrics/field_trial.h

Issue 153913009: Make some field trials unforceable via command-line in the official build. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nit Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | base/metrics/field_trial.cc » ('j') | chrome/browser/chrome_browser_main.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 //------------------------------------------------------------------------------ 52 //------------------------------------------------------------------------------
53 53
54 #ifndef BASE_METRICS_FIELD_TRIAL_H_ 54 #ifndef BASE_METRICS_FIELD_TRIAL_H_
55 #define BASE_METRICS_FIELD_TRIAL_H_ 55 #define BASE_METRICS_FIELD_TRIAL_H_
56 56
57 #include <map> 57 #include <map>
58 #include <string> 58 #include <string>
59 #include <vector> 59 #include <vector>
60 60
61 #include "base/base_export.h" 61 #include "base/base_export.h"
62 #include "base/callback_forward.h"
62 #include "base/gtest_prod_util.h" 63 #include "base/gtest_prod_util.h"
63 #include "base/memory/ref_counted.h" 64 #include "base/memory/ref_counted.h"
64 #include "base/observer_list_threadsafe.h" 65 #include "base/observer_list_threadsafe.h"
65 #include "base/synchronization/lock.h" 66 #include "base/synchronization/lock.h"
66 #include "base/time/time.h" 67 #include "base/time/time.h"
67 68
68 namespace base { 69 namespace base {
69 70
70 class FieldTrialList; 71 class FieldTrialList;
71 72
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 283
283 DISALLOW_COPY_AND_ASSIGN(FieldTrial); 284 DISALLOW_COPY_AND_ASSIGN(FieldTrial);
284 }; 285 };
285 286
286 //------------------------------------------------------------------------------ 287 //------------------------------------------------------------------------------
287 // 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
288 // been registered, which includes evaluating its state based on its probaility. 289 // been registered, which includes evaluating its state based on its probaility.
289 // Only one instance of this class exists. 290 // Only one instance of this class exists.
290 class BASE_EXPORT FieldTrialList { 291 class BASE_EXPORT FieldTrialList {
291 public: 292 public:
293 // A callback that returns true if |name| describes a field trial that should
294 // be accepted by the method it was passed to.
295 typedef base::Callback<bool(const std::string& name)>
Alexei Svitkine (slow) 2014/02/12 14:26:47 Nit: |name| -> |trial_name| to be consistent with
gab 2014/02/12 15:59:19 Done.
296 IsAcceptedFieldTrialCallback;
297
292 // Specifies whether field trials should be activated (marked as "used"), when 298 // Specifies whether field trials should be activated (marked as "used"), when
293 // created using |CreateTrialsFromString()|. 299 // created using |CreateTrialsFromString()|.
294 enum FieldTrialActivationMode { 300 enum FieldTrialActivationMode {
295 DONT_ACTIVATE_TRIALS, 301 DONT_ACTIVATE_TRIALS,
296 ACTIVATE_TRIALS, 302 ACTIVATE_TRIALS,
297 }; 303 };
298 304
299 // 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
300 // 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
301 // 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).
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 static void GetActiveFieldTrialGroups( 411 static void GetActiveFieldTrialGroups(
406 FieldTrial::ActiveGroups* active_groups); 412 FieldTrial::ActiveGroups* active_groups);
407 413
408 // 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
409 // 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
410 // 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
411 // 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
412 // 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
413 // 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
414 // trials are marked as "used" for the purposes of active trial reporting if 420 // trials are marked as "used" for the purposes of active trial reporting if
415 // |mode| is ACTIVATE_TRIALS. 421 // |mode| is ACTIVATE_TRIALS. If |is_accepted_callback| is not null: field
416 static bool CreateTrialsFromString(const std::string& prior_trials, 422 // trials for which |is_accepted_callback| returns false are ignored.
417 FieldTrialActivationMode mode); 423 static bool CreateTrialsFromString(
424 const std::string& prior_trials,
425 FieldTrialActivationMode mode,
426 const IsAcceptedFieldTrialCallback& is_accepted_callback);
418 427
419 // Create a FieldTrial with the given |name| and using 100% probability for 428 // Create a FieldTrial with the given |name| and using 100% probability for
420 // the FieldTrial, force FieldTrial to have the same group string as 429 // 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 430 // |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. 431 // 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 432 // 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|). 433 // the same |name| but has different finalized group string (|group_name|).
425 static FieldTrial* CreateFieldTrial(const std::string& name, 434 static FieldTrial* CreateFieldTrial(const std::string& name,
426 const std::string& group_name); 435 const std::string& group_name);
427 436
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 483
475 // List of observers to be notified when a group is selected for a FieldTrial. 484 // List of observers to be notified when a group is selected for a FieldTrial.
476 scoped_refptr<ObserverListThreadSafe<Observer> > observer_list_; 485 scoped_refptr<ObserverListThreadSafe<Observer> > observer_list_;
477 486
478 DISALLOW_COPY_AND_ASSIGN(FieldTrialList); 487 DISALLOW_COPY_AND_ASSIGN(FieldTrialList);
479 }; 488 };
480 489
481 } // namespace base 490 } // namespace base
482 491
483 #endif // BASE_METRICS_FIELD_TRIAL_H_ 492 #endif // BASE_METRICS_FIELD_TRIAL_H_
OLDNEW
« no previous file with comments | « no previous file | base/metrics/field_trial.cc » ('j') | chrome/browser/chrome_browser_main.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698