| OLD | NEW |
| 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 |
| 11 // data is uploaded to aggregate the test results, and this FieldTrial class | 11 // data is uploaded to aggregate the test results, and this FieldTrial class |
| 12 // manages the state of each such experiment (state == which option was | 12 // manages the state of each such experiment (state == which option was |
| 13 // pseudo-randomly selected). | 13 // pseudo-randomly selected). |
| 14 // | 14 // |
| 15 // States are typically generated randomly, either based on a one time | 15 // States are typically generated randomly, either based on a one time |
| 16 // randomization (which will yield the same results, in terms of selecting | 16 // randomization (generated randomly once, and then persistently reused in the |
| 17 // the client for a field trial or not, for every run of the program on a | 17 // client during each future run of the program), or by a startup randomization |
| 18 // given machine), or by a startup randomization (generated each time the | 18 // (generated each time the application starts up, but held constant during the |
| 19 // application starts up, but held constant during the duration of the | 19 // duration of the process), or by continuous randomization across a run (where |
| 20 // process), or by continuous randomization across a run (where the state | 20 // the state can be recalculated again and again, many times during a process). |
| 21 // can be recalculated again and again, many times during a process). | 21 // Only startup randomization is implemented thus far. |
| 22 // Continuous randomization is not yet implemented. | |
| 23 | 22 |
| 24 //------------------------------------------------------------------------------ | 23 //------------------------------------------------------------------------------ |
| 25 // Example: Suppose we have an experiment involving memory, such as determining | 24 // Example: Suppose we have an experiment involving memory, such as determining |
| 26 // the impact of some pruning algorithm. | 25 // the impact of some pruning algorithm. |
| 27 // We assume that we already have a histogram of memory usage, such as: | 26 // We assume that we already have a histogram of memory usage, such as: |
| 28 | 27 |
| 29 // HISTOGRAM_COUNTS("Memory.RendererTotal", count); | 28 // HISTOGRAM_COUNTS("Memory.RendererTotal", count); |
| 30 | 29 |
| 31 // Somewhere in main thread initialization code, we'd probably define an | 30 // Somewhere in main thread initialization code, we'd probably define an |
| 32 // instance of a FieldTrial, with code such as: | 31 // instance of a FieldTrial, with code such as: |
| (...skipping 13 matching lines...) Expand all Loading... |
| 46 // if (trial->group() == kHighMemGroup) | 45 // if (trial->group() == kHighMemGroup) |
| 47 // SetPruningAlgorithm(kType1); // Sample setting of browser state. | 46 // SetPruningAlgorithm(kType1); // Sample setting of browser state. |
| 48 // else if (trial->group() == kLowMemGroup) | 47 // else if (trial->group() == kLowMemGroup) |
| 49 // SetPruningAlgorithm(kType2); // Sample alternate setting. | 48 // SetPruningAlgorithm(kType2); // Sample alternate setting. |
| 50 | 49 |
| 51 // We then, in addition to our original histogram, output histograms which have | 50 // We then, in addition to our original histogram, output histograms which have |
| 52 // slightly different names depending on what group the trial instance happened | 51 // slightly different names depending on what group the trial instance happened |
| 53 // to randomly be assigned: | 52 // to randomly be assigned: |
| 54 | 53 |
| 55 // HISTOGRAM_COUNTS("Memory.RendererTotal", count); // The original histogram. | 54 // HISTOGRAM_COUNTS("Memory.RendererTotal", count); // The original histogram. |
| 56 // static const bool memory_renderer_total_trial_exists = | 55 // static bool use_memoryexperiment_histogram( |
| 57 // FieldTrialList::TrialExists("Memory.RendererTotal"); | 56 // base::FieldTrialList::Find("MemoryExperiment") && |
| 58 // if (memory_renderer_total_trial_exists) { | 57 // !base::FieldTrialList::Find("MemoryExperiment")->group_name().empty()); |
| 58 // if (use_memoryexperiment_histogram) { |
| 59 // HISTOGRAM_COUNTS(FieldTrial::MakeName("Memory.RendererTotal", | 59 // HISTOGRAM_COUNTS(FieldTrial::MakeName("Memory.RendererTotal", |
| 60 // "MemoryExperiment"), count); | 60 // "MemoryExperiment"), count); |
| 61 // } | 61 // } |
| 62 | 62 |
| 63 // The above code will create four distinct histograms, with each run of the | 63 // The above code will create four distinct histograms, with each run of the |
| 64 // application being assigned to of of the three groups, and for each group, the | 64 // application being assigned to of of the three groups, and for each group, the |
| 65 // correspondingly named histogram will be populated: | 65 // correspondingly named histogram will be populated: |
| 66 | 66 |
| 67 // Memory.RendererTotal // 100% of users still fill this histogram. | 67 // Memory.RendererTotal // 100% of users still fill this histogram. |
| 68 // Memory.RendererTotal_HighMem // 2% of users will fill this histogram. | 68 // Memory.RendererTotal_HighMem // 2% of users will fill this histogram. |
| (...skipping 27 matching lines...) Expand all Loading... |
| 96 // A return value to indicate that a given instance has not yet had a group | 96 // 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). | 97 // assignment (and hence is not yet participating in the trial). |
| 98 static const int kNotFinalized; | 98 static const int kNotFinalized; |
| 99 | 99 |
| 100 // This is the group number of the 'default' group. This provides an easy way | 100 // 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'). | 101 // to assign all the remaining probability to a group ('default'). |
| 102 static const int kDefaultGroupNumber; | 102 static const int kDefaultGroupNumber; |
| 103 | 103 |
| 104 // The name is used to register the instance with the FieldTrialList class, | 104 // The name is used to register the instance with the FieldTrialList class, |
| 105 // and can be used to find the trial (only one trial can be present for each | 105 // and can be used to find the trial (only one trial can be present for each |
| 106 // name). |name| and |default_group_name| may not be empty. | 106 // name). |
| 107 // | |
| 108 // Group probabilities that are later supplied must sum to less than or equal | 107 // Group probabilities that are later supplied must sum to less than or equal |
| 109 // to the total_probability. Arguments year, month and day_of_month specify | 108 // to the total_probability. Arguments year, month and day_of_month specify |
| 110 // the expiration time. If the build time is after the expiration time then | 109 // the expiration time. If the build time is after the expiration time then |
| 111 // the field trial reverts to the 'default' group. | 110 // the field trial reverts to the 'default' group. |
| 112 // | |
| 113 // Using this constructor creates a startup-randomized FieldTrial. If you | |
| 114 // want a one-time randomized trial, call UseOneTimeRandomization() right | |
| 115 // after construction. | |
| 116 FieldTrial(const std::string& name, Probability total_probability, | 111 FieldTrial(const std::string& name, Probability total_probability, |
| 117 const std::string& default_group_name, const int year, | 112 const std::string& default_group_name, const int year, |
| 118 const int month, const int day_of_month); | 113 const int month, const int day_of_month); |
| 119 | 114 |
| 120 // Changes the field trial to use one-time randomization, i.e. produce the | |
| 121 // same result for the current trial on every run of this client. Must be | |
| 122 // called right after construction. | |
| 123 // | |
| 124 // Before using this method, |FieldTrialList::EnableOneTimeRandomization()| | |
| 125 // must be called exactly once. | |
| 126 void UseOneTimeRandomization(); | |
| 127 | |
| 128 // Disables this trial, meaning it always determines the default group | |
| 129 // has been selected. May be called immediately after construction, or | |
| 130 // at any time after initialization (should not be interleaved with | |
| 131 // AppendGroup calls). Once disabled, there is no way to re-enable a | |
| 132 // trial. | |
| 133 void Disable(); | |
| 134 | |
| 135 // Establish the name and probability of the next group in this trial. | 115 // Establish the name and probability of the next group in this trial. |
| 136 // Sometimes, based on construction randomization, this call may cause the | 116 // Sometimes, based on construction randomization, this call may cause the |
| 137 // provided group to be *THE* group selected for use in this instance. | 117 // provided group to be *THE* group selected for use in this instance. |
| 138 // The return value is the group number of the new group. | 118 // The return value is the group number of the new group. |
| 139 int AppendGroup(const std::string& name, Probability group_probability); | 119 int AppendGroup(const std::string& name, Probability group_probability); |
| 140 | 120 |
| 141 // Return the name of the FieldTrial (excluding the group name). | 121 // Return the name of the FieldTrial (excluding the group name). |
| 142 std::string name() const { return name_; } | 122 std::string name() const { return name_; } |
| 143 | 123 |
| 144 // Return the randomly selected group number that was assigned. | 124 // Return the randomly selected group number that was assigned. |
| 145 // Return kDefaultGroupNumber if the instance is in the 'default' group. | 125 // Return kDefaultGroupNumber if the instance is in the 'default' group. |
| 146 // Note that this will force an instance to participate, and make it illegal | 126 // Note that this will force an instance to participate, and make it illegal |
| 147 // to attempt to probabilistically add any other groups to the trial. | 127 // to attempt to probabalistically add any other groups to the trial. |
| 148 int group(); | 128 int group(); |
| 149 | 129 |
| 150 // If the group's name is empty, a string version containing the group | 130 // If the field trial is not in an experiment, this returns the empty string. |
| 131 // if the group's name is empty, a name of "_" concatenated with the group |
| 151 // number is used as the group name. | 132 // number is used as the group name. |
| 152 std::string group_name(); | 133 std::string group_name(); |
| 153 | 134 |
| 154 // Return the default group name of the FieldTrial. | 135 // Return the default group name of the FieldTrial. |
| 155 std::string default_group_name() const { return default_group_name_; } | 136 std::string default_group_name() const { return default_group_name_; } |
| 156 | 137 |
| 157 // Helper function for the most common use: as an argument to specify the | 138 // Helper function for the most common use: as an argument to specifiy the |
| 158 // name of a HISTOGRAM. Use the original histogram name as the name_prefix. | 139 // name of a HISTOGRAM. Use the original histogram name as the name_prefix. |
| 159 static std::string MakeName(const std::string& name_prefix, | 140 static std::string MakeName(const std::string& name_prefix, |
| 160 const std::string& trial_name); | 141 const std::string& trial_name); |
| 161 | 142 |
| 162 // Enable benchmarking sets field trials to a common setting. | 143 // Enable benchmarking sets field trials to a common setting. |
| 163 static void EnableBenchmarking(); | 144 static void EnableBenchmarking(); |
| 164 | 145 |
| 165 private: | 146 private: |
| 166 // Allow tests to access our innards for testing purposes. | 147 // Allow tests to access our innards for testing purposes. |
| 167 FRIEND_TEST(FieldTrialTest, Registration); | 148 FRIEND_TEST(FieldTrialTest, Registration); |
| 168 FRIEND_TEST(FieldTrialTest, AbsoluteProbabilities); | 149 FRIEND_TEST(FieldTrialTest, AbsoluteProbabilities); |
| 169 FRIEND_TEST(FieldTrialTest, RemainingProbability); | 150 FRIEND_TEST(FieldTrialTest, RemainingProbability); |
| 170 FRIEND_TEST(FieldTrialTest, FiftyFiftyProbability); | 151 FRIEND_TEST(FieldTrialTest, FiftyFiftyProbability); |
| 171 FRIEND_TEST(FieldTrialTest, MiddleProbabilities); | 152 FRIEND_TEST(FieldTrialTest, MiddleProbabilities); |
| 172 FRIEND_TEST(FieldTrialTest, OneWinner); | 153 FRIEND_TEST(FieldTrialTest, OneWinner); |
| 173 FRIEND_TEST(FieldTrialTest, DisableProbability); | 154 FRIEND_TEST(FieldTrialTest, DisableProbability); |
| 174 FRIEND_TEST(FieldTrialTest, Save); | 155 FRIEND_TEST(FieldTrialTest, Save); |
| 175 FRIEND_TEST(FieldTrialTest, DuplicateRestore); | 156 FRIEND_TEST(FieldTrialTest, DuplicateRestore); |
| 176 FRIEND_TEST(FieldTrialTest, MakeName); | 157 FRIEND_TEST(FieldTrialTest, MakeName); |
| 177 FRIEND_TEST(FieldTrialTest, HashClientId); | |
| 178 FRIEND_TEST(FieldTrialTest, HashClientIdIsUniform); | |
| 179 FRIEND_TEST(FieldTrialTest, UseOneTimeRandomization); | |
| 180 | 158 |
| 181 friend class base::FieldTrialList; | 159 friend class base::FieldTrialList; |
| 182 | 160 |
| 183 friend class RefCounted<FieldTrial>; | 161 friend class RefCounted<FieldTrial>; |
| 184 | 162 |
| 185 virtual ~FieldTrial(); | 163 virtual ~FieldTrial(); |
| 186 | 164 |
| 187 // Returns the group_name. A winner need not have been chosen. | 165 // Returns the group_name. A winner need not have been chosen. |
| 188 std::string group_name_internal() const { return group_name_; } | 166 std::string group_name_internal() const { return group_name_; } |
| 189 | 167 |
| 190 // Get build time. | 168 // Get build time. |
| 191 static Time GetBuildTime(); | 169 static Time GetBuildTime(); |
| 192 | 170 |
| 193 // Calculates a uniformly-distributed double between [0.0, 1.0) given | |
| 194 // a |client_id| and a |trial_name| (the latter is used as salt to avoid | |
| 195 // separate one-time randomized trials from all having the same results). | |
| 196 static double HashClientId(const std::string& client_id, | |
| 197 const std::string& trial_name); | |
| 198 | |
| 199 // The name of the field trial, as can be found via the FieldTrialList. | 171 // The name of the field trial, as can be found via the FieldTrialList. |
| 172 // This is empty of the trial is not in the experiment. |
| 200 const std::string name_; | 173 const std::string name_; |
| 201 | 174 |
| 202 // The maximum sum of all probabilities supplied, which corresponds to 100%. | 175 // The maximum sum of all probabilities supplied, which corresponds to 100%. |
| 203 // This is the scaling factor used to adjust supplied probabilities. | 176 // This is the scaling factor used to adjust supplied probabilities. |
| 204 const Probability divisor_; | 177 const Probability divisor_; |
| 205 | 178 |
| 206 // The name of the default group. | 179 // The name of the default group. |
| 207 const std::string default_group_name_; | 180 const std::string default_group_name_; |
| 208 | 181 |
| 209 // The randomly selected probability that is used to select a group (or have | 182 // The randomly selected probability that is used to select a group (or have |
| 210 // the instance not participate). It is the product of divisor_ and a random | 183 // the instance not participate). It is the product of divisor_ and a random |
| 211 // number between [0, 1). | 184 // number between [0, 1). |
| 212 Probability random_; | 185 const Probability random_; |
| 213 | 186 |
| 214 // Sum of the probabilities of all appended groups. | 187 // Sum of the probabilities of all appended groups. |
| 215 Probability accumulated_group_probability_; | 188 Probability accumulated_group_probability_; |
| 216 | 189 |
| 217 int next_group_number_; | 190 int next_group_number_; |
| 218 | 191 |
| 219 // The pseudo-randomly assigned group number. | 192 // The pseudo-randomly assigned group number. |
| 220 // This is kNotFinalized if no group has been assigned. | 193 // This is kNotFinalized if no group has been assigned. |
| 221 int group_; | 194 int group_; |
| 222 | 195 |
| 223 // A textual name for the randomly selected group. Valid after |group()| | 196 // A textual name for the randomly selected group. If this Trial is not a |
| 224 // has been called. | 197 // member of an group, this string is empty. |
| 225 std::string group_name_; | 198 std::string group_name_; |
| 226 | 199 |
| 227 // When enable_field_trial_ is false, field trial reverts to the 'default' | 200 // When disable_field_trial_ is true, field trial reverts to the 'default' |
| 228 // group. | 201 // group. |
| 229 bool enable_field_trial_; | 202 bool disable_field_trial_; |
| 230 | 203 |
| 231 // When benchmarking is enabled, field trials all revert to the 'default' | 204 // When benchmarking is enabled, field trials all revert to the 'default' |
| 232 // group. | 205 // group. |
| 233 static bool enable_benchmarking_; | 206 static bool enable_benchmarking_; |
| 234 | 207 |
| 235 DISALLOW_COPY_AND_ASSIGN(FieldTrial); | 208 DISALLOW_COPY_AND_ASSIGN(FieldTrial); |
| 236 }; | 209 }; |
| 237 | 210 |
| 238 //------------------------------------------------------------------------------ | 211 //------------------------------------------------------------------------------ |
| 239 // Class with a list of all active field trials. A trial is active if it has | 212 // Class with a list of all active field trials. A trial is active if it has |
| (...skipping 14 matching lines...) Expand all Loading... |
| 254 public: | 227 public: |
| 255 // Notify observers when FieldTrials's group is selected. | 228 // Notify observers when FieldTrials's group is selected. |
| 256 virtual void OnFieldTrialGroupFinalized(const std::string& trial_name, | 229 virtual void OnFieldTrialGroupFinalized(const std::string& trial_name, |
| 257 const std::string& group_name) = 0; | 230 const std::string& group_name) = 0; |
| 258 | 231 |
| 259 protected: | 232 protected: |
| 260 virtual ~Observer() {} | 233 virtual ~Observer() {} |
| 261 }; | 234 }; |
| 262 | 235 |
| 263 // This singleton holds the global list of registered FieldTrials. | 236 // This singleton holds the global list of registered FieldTrials. |
| 264 // | 237 FieldTrialList(); |
| 265 // |client_id| should be an opaque, diverse ID for this client that does not | |
| 266 // change between sessions, to enable one-time randomized trials. The empty | |
| 267 // string may be provided, in which case one-time randomized trials will | |
| 268 // not be available. | |
| 269 explicit FieldTrialList(const std::string& client_id); | |
| 270 // Destructor Release()'s references to all registered FieldTrial instances. | 238 // Destructor Release()'s references to all registered FieldTrial instances. |
| 271 ~FieldTrialList(); | 239 ~FieldTrialList(); |
| 272 | 240 |
| 273 // Register() stores a pointer to the given trial in a global map. | 241 // Register() stores a pointer to the given trial in a global map. |
| 274 // This method also AddRef's the indicated trial. | 242 // This method also AddRef's the indicated trial. |
| 275 static void Register(FieldTrial* trial); | 243 static void Register(FieldTrial* trial); |
| 276 | 244 |
| 277 // The Find() method can be used to test to see if a named Trial was already | 245 // The Find() method can be used to test to see if a named Trial was already |
| 278 // registered, or to retrieve a pointer to it from the global map. | 246 // registered, or to retrieve a pointer to it from the global map. |
| 279 static FieldTrial* Find(const std::string& name); | 247 static FieldTrial* Find(const std::string& name); |
| 280 | 248 |
| 281 // Returns the group number chosen for the named trial, or | |
| 282 // FieldTrial::kNotFinalized if the trial does not exist. | |
| 283 static int FindValue(const std::string& name); | 249 static int FindValue(const std::string& name); |
| 284 | 250 |
| 285 // Returns the group name chosen for the named trial, or the | |
| 286 // empty string if the trial does not exist. | |
| 287 static std::string FindFullName(const std::string& name); | 251 static std::string FindFullName(const std::string& name); |
| 288 | 252 |
| 289 // Returns true if the named trial has been registered. | 253 // Create a persistent representation of all FieldTrial instances for |
| 290 static bool TrialExists(const std::string& name); | 254 // resurrection in another process. This allows randomization to be done in |
| 291 | 255 // one process, and secondary processes can by synchronized on the result. |
| 292 // Create a persistent representation of all FieldTrial instances and the | 256 // The resulting string contains only the names, the trial name, and a "/" |
| 293 // |client_id()| state for resurrection in another process. This allows | 257 // separator. |
| 294 // randomization to be done in one process, and secondary processes can by | |
| 295 // synchronized on the result. The resulting string contains the | |
| 296 // |client_id()|, the names, the trial name, and a "/" separator. | |
| 297 static void StatesToString(std::string* output); | 258 static void StatesToString(std::string* output); |
| 298 | 259 |
| 299 // Use a previously generated state string (re: StatesToString()) augment the | 260 // Use a previously generated state string (re: StatesToString()) augment the |
| 300 // current list of field tests to include the supplied tests, and using a 100% | 261 // current list of field tests to include the supplied tests, and using a 100% |
| 301 // probability for each test, force them to have the same group string. This | 262 // probability for each test, force them to have the same group string. This |
| 302 // is commonly used in a non-browser process, to carry randomly selected state | 263 // is commonly used in a non-browser process, to carry randomly selected state |
| 303 // in a browser process into this non-browser process. This method calls | 264 // in a browser process into this non-browser process. This method calls |
| 304 // CreateFieldTrial to create the FieldTrial in the non-browser process. | 265 // CreateFieldTrial to create the FieldTrial in the non-browser process. |
| 305 // Currently only the group_name_ and name_ are restored, as well as the | 266 // Currently only the group_name_ and name_ are restored. |
| 306 // |client_id()| state, that could be used for one-time randomized trials | |
| 307 // set up only in child processes. | |
| 308 static bool CreateTrialsInChildProcess(const std::string& prior_trials); | 267 static bool CreateTrialsInChildProcess(const std::string& prior_trials); |
| 309 | 268 |
| 310 // Create a FieldTrial with the given |name| and using 100% probability for | 269 // Create a FieldTrial with the given |name| and using 100% probability for |
| 311 // the FieldTrial, force FieldTrial to have the same group string as | 270 // the FieldTrial, force FieldTrial to have the same group string as |
| 312 // |group_name|. This is commonly used in a non-browser process, to carry | 271 // |group_name|. This is commonly used in a non-browser process, to carry |
| 313 // randomly selected state in a browser process into this non-browser process. | 272 // randomly selected state in a browser process into this non-browser process. |
| 314 // Currently only the group_name_ and name_ are set in the FieldTrial. It | 273 // Currently only the group_name_ and name_ are set in the FieldTrial. It |
| 315 // returns NULL if there is a FieldTrial that is already registered with the | 274 // returns NULL if there is a FieldTrial that is already registered with the |
| 316 // same |name| but has different finalized group string (|group_name|). | 275 // same |name| but has different finalized group string (|group_name|). |
| 317 static FieldTrial* CreateFieldTrial(const std::string& name, | 276 static FieldTrial* CreateFieldTrial(const std::string& name, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 337 static TimeTicks application_start_time() { | 296 static TimeTicks application_start_time() { |
| 338 if (global_) | 297 if (global_) |
| 339 return global_->application_start_time_; | 298 return global_->application_start_time_; |
| 340 // For testing purposes only, or when we don't yet have a start time. | 299 // For testing purposes only, or when we don't yet have a start time. |
| 341 return TimeTicks::Now(); | 300 return TimeTicks::Now(); |
| 342 } | 301 } |
| 343 | 302 |
| 344 // Return the number of active field trials. | 303 // Return the number of active field trials. |
| 345 static size_t GetFieldTrialCount(); | 304 static size_t GetFieldTrialCount(); |
| 346 | 305 |
| 347 // Returns true if you can call |FieldTrial::UseOneTimeRandomization()| | |
| 348 // without error, i.e. if a non-empty string was provided as the client_id | |
| 349 // when constructing the FieldTrialList singleton. | |
| 350 static bool IsOneTimeRandomizationEnabled(); | |
| 351 | |
| 352 // Returns an opaque, diverse ID for this client that does not change | |
| 353 // between sessions. | |
| 354 // | |
| 355 // Returns the empty string if one-time randomization is not enabled. | |
| 356 static const std::string& client_id(); | |
| 357 | |
| 358 private: | 306 private: |
| 359 // A map from FieldTrial names to the actual instances. | 307 // A map from FieldTrial names to the actual instances. |
| 360 typedef std::map<std::string, FieldTrial*> RegistrationList; | 308 typedef std::map<std::string, FieldTrial*> RegistrationList; |
| 361 | 309 |
| 362 // Helper function should be called only while holding lock_. | 310 // Helper function should be called only while holding lock_. |
| 363 FieldTrial* PreLockedFind(const std::string& name); | 311 FieldTrial* PreLockedFind(const std::string& name); |
| 364 | 312 |
| 365 static FieldTrialList* global_; // The singleton of this class. | 313 static FieldTrialList* global_; // The singleton of this class. |
| 366 | 314 |
| 367 // This will tell us if there is an attempt to register a field trial without | 315 // This will tell us if there is an attempt to register a field trial without |
| 368 // creating the FieldTrialList. This is not an error, unless a FieldTrialList | 316 // creating the FieldTrialList. This is not an error, unless a FieldTrialList |
| 369 // is created after that. | 317 // is created after that. |
| 370 static bool register_without_global_; | 318 static bool register_without_global_; |
| 371 | 319 |
| 372 // A helper value made available to users, that shows when the FieldTrialList | 320 // A helper value made availabel to users, that shows when the FieldTrialList |
| 373 // was initialized. Note that this is a singleton instance, and hence is a | 321 // was initialized. Note that this is a singleton instance, and hence is a |
| 374 // good approximation to the start of the process. | 322 // good approximation to the start of the process. |
| 375 TimeTicks application_start_time_; | 323 TimeTicks application_start_time_; |
| 376 | 324 |
| 377 // Lock for access to registered_. | 325 // Lock for access to registered_. |
| 378 base::Lock lock_; | 326 base::Lock lock_; |
| 379 RegistrationList registered_; | 327 RegistrationList registered_; |
| 380 | 328 |
| 381 // An opaque, diverse ID for this client that does not change | |
| 382 // between sessions, or the empty string if not initialized. | |
| 383 std::string client_id_; | |
| 384 | |
| 385 // List of observers to be notified when a group is selected for a FieldTrial. | 329 // List of observers to be notified when a group is selected for a FieldTrial. |
| 386 ObserverList<Observer> observer_list_; | 330 ObserverList<Observer> observer_list_; |
| 387 | 331 |
| 388 DISALLOW_COPY_AND_ASSIGN(FieldTrialList); | 332 DISALLOW_COPY_AND_ASSIGN(FieldTrialList); |
| 389 }; | 333 }; |
| 390 | 334 |
| 391 } // namespace base | 335 } // namespace base |
| 392 | 336 |
| 393 #endif // BASE_METRICS_FIELD_TRIAL_H_ | 337 #endif // BASE_METRICS_FIELD_TRIAL_H_ |
| 338 |
| OLD | NEW |