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

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

Issue 9117037: Added a Unique ID for a Field Trial containing it's hashed name and the selected group ID. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 11 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') | base/metrics/field_trial.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 #include "base/synchronization/lock.h" 85 #include "base/synchronization/lock.h"
86 #include "base/time.h" 86 #include "base/time.h"
87 87
88 namespace base { 88 namespace base {
89 89
90 class FieldTrialList; 90 class FieldTrialList;
91 91
92 class BASE_EXPORT FieldTrial : public RefCounted<FieldTrial> { 92 class BASE_EXPORT FieldTrial : public RefCounted<FieldTrial> {
93 public: 93 public:
94 typedef int Probability; // Probability type for being selected in a trial. 94 typedef int Probability; // Probability type for being selected in a trial.
95 // The Unique ID of a trial, first element is a hashed value of the name
96 // and the second one is the group identifier.
97 typedef std::pair<size_t, int> UID;
jar (doing other things) 2012/01/24 19:19:45 You might want to send two hashes, rather than one
MAD 2012/01/24 20:30:24 OK! Done... Thanks! :-)
95 98
96 // A return value to indicate that a given instance has not yet had a group 99 // A return value to indicate that a given instance has not yet had a group
97 // assignment (and hence is not yet participating in the trial). 100 // assignment (and hence is not yet participating in the trial).
98 static const int kNotFinalized; 101 static const int kNotFinalized;
99 102
100 // This is the group number of the 'default' group. This provides an easy way 103 // This is the group number of the 'default' group. This provides an easy way
101 // to assign all the remaining probability to a group ('default'). 104 // to assign all the remaining probability to a group ('default').
102 static const int kDefaultGroupNumber; 105 static const int kDefaultGroupNumber;
103 106
104 // The name is used to register the instance with the FieldTrialList class, 107 // The name is used to register the instance with the FieldTrialList class,
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 // Return the randomly selected group number that was assigned. 144 // Return the randomly selected group number that was assigned.
142 // Return kDefaultGroupNumber if the instance is in the 'default' group. 145 // Return kDefaultGroupNumber if the instance is in the 'default' group.
143 // Note that this will force an instance to participate, and make it illegal 146 // Note that this will force an instance to participate, and make it illegal
144 // to attempt to probabilistically add any other groups to the trial. 147 // to attempt to probabilistically add any other groups to the trial.
145 int group(); 148 int group();
146 149
147 // If the group's name is empty, a string version containing the group 150 // If the group's name is empty, a string version containing the group
148 // number is used as the group name. 151 // number is used as the group name.
149 std::string group_name(); 152 std::string group_name();
150 153
154 // Gets the unique identifier of the Field Trial, but only if a winner was
155 // elected. Returns true if a winner is returned, false otherwise.
156 bool GetUID(UID* uid);
157
151 // Return the default group name of the FieldTrial. 158 // Return the default group name of the FieldTrial.
152 std::string default_group_name() const { return default_group_name_; } 159 std::string default_group_name() const { return default_group_name_; }
153 160
154 // Helper function for the most common use: as an argument to specify the 161 // Helper function for the most common use: as an argument to specify the
155 // name of a HISTOGRAM. Use the original histogram name as the name_prefix. 162 // name of a HISTOGRAM. Use the original histogram name as the name_prefix.
156 static std::string MakeName(const std::string& name_prefix, 163 static std::string MakeName(const std::string& name_prefix,
157 const std::string& trial_name); 164 const std::string& trial_name);
158 165
159 // Enable benchmarking sets field trials to a common setting. 166 // Enable benchmarking sets field trials to a common setting.
160 static void EnableBenchmarking(); 167 static void EnableBenchmarking();
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 285
279 // Returns the group name chosen for the named trial, or the 286 // Returns the group name chosen for the named trial, or the
280 // empty string if the trial does not exist. 287 // empty string if the trial does not exist.
281 static std::string FindFullName(const std::string& name); 288 static std::string FindFullName(const std::string& name);
282 289
283 // Returns true if the named trial has been registered. 290 // Returns true if the named trial has been registered.
284 static bool TrialExists(const std::string& name); 291 static bool TrialExists(const std::string& name);
285 292
286 // Create a persistent representation of all FieldTrial instances and the 293 // Create a persistent representation of all FieldTrial instances and the
287 // |client_id()| state for resurrection in another process. This allows 294 // |client_id()| state for resurrection in another process. This allows
288 // randomization to be done in one process, and secondary processes can by 295 // randomization to be done in one process, and secondary processes can be
289 // synchronized on the result. The resulting string contains the 296 // synchronized on the result. The resulting string contains the
290 // |client_id()|, the names, the trial name, and a "/" separator. 297 // |client_id()|, the names, the trial name, and a "/" separator.
291 static void StatesToString(std::string* output); 298 static void StatesToString(std::string* output);
292 299
300 // Returns an array of Unique IDs for each currently running Field Trials.
301 static void GetFieldTrialUIDs(std::vector<FieldTrial::UID>* uids);
302
293 // Use a previously generated state string (re: StatesToString()) augment the 303 // Use a previously generated state string (re: StatesToString()) augment the
294 // current list of field tests to include the supplied tests, and using a 100% 304 // current list of field tests to include the supplied tests, and using a 100%
295 // probability for each test, force them to have the same group string. This 305 // probability for each test, force them to have the same group string. This
296 // is commonly used in a non-browser process, to carry randomly selected state 306 // is commonly used in a non-browser process, to carry randomly selected state
297 // in a browser process into this non-browser process. This method calls 307 // in a browser process into this non-browser process. This method calls
298 // CreateFieldTrial to create the FieldTrial in the non-browser process. 308 // CreateFieldTrial to create the FieldTrial in the non-browser process.
299 // Currently only the group_name_ and name_ are restored, as well as the 309 // Currently only the group_name_ and name_ are restored, as well as the
300 // |client_id()| state, that could be used for one-time randomized trials 310 // |client_id()| state, that could be used for one-time randomized trials
301 // set up only in child processes. 311 // set up only in child processes.
302 static bool CreateTrialsInChildProcess(const std::string& prior_trials); 312 static bool CreateTrialsInChildProcess(const std::string& prior_trials);
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 389
380 // List of observers to be notified when a group is selected for a FieldTrial. 390 // List of observers to be notified when a group is selected for a FieldTrial.
381 ObserverList<Observer> observer_list_; 391 ObserverList<Observer> observer_list_;
382 392
383 DISALLOW_COPY_AND_ASSIGN(FieldTrialList); 393 DISALLOW_COPY_AND_ASSIGN(FieldTrialList);
384 }; 394 };
385 395
386 } // namespace base 396 } // namespace base
387 397
388 #endif // BASE_METRICS_FIELD_TRIAL_H_ 398 #endif // BASE_METRICS_FIELD_TRIAL_H_
OLDNEW
« no previous file with comments | « no previous file | base/metrics/field_trial.cc » ('j') | base/metrics/field_trial.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698