| OLD | NEW |
| 1 // Copyright (c) 2010 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 |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 if (global_) | 210 if (global_) |
| 211 return global_->application_start_time_; | 211 return global_->application_start_time_; |
| 212 // For testing purposes only, or when we don't yet have a start time. | 212 // For testing purposes only, or when we don't yet have a start time. |
| 213 return TimeTicks::Now(); | 213 return TimeTicks::Now(); |
| 214 } | 214 } |
| 215 | 215 |
| 216 // Return the number of active field trials. | 216 // Return the number of active field trials. |
| 217 static size_t GetFieldTrialCount(); | 217 static size_t GetFieldTrialCount(); |
| 218 | 218 |
| 219 private: | 219 private: |
| 220 // A map from FieldTrial names to the actual instances. |
| 221 typedef std::map<std::string, FieldTrial*> RegistrationList; |
| 222 |
| 220 // Helper function should be called only while holding lock_. | 223 // Helper function should be called only while holding lock_. |
| 221 FieldTrial* PreLockedFind(const std::string& name); | 224 FieldTrial* PreLockedFind(const std::string& name); |
| 222 | 225 |
| 223 // A map from FieldTrial names to the actual instances. | |
| 224 typedef std::map<std::string, FieldTrial*> RegistrationList; | |
| 225 | |
| 226 static FieldTrialList* global_; // The singleton of this class. | 226 static FieldTrialList* global_; // The singleton of this class. |
| 227 | 227 |
| 228 // This will tell us if there is an attempt to register a field trial without | 228 // This will tell us if there is an attempt to register a field trial without |
| 229 // creating the FieldTrialList. This is not an error, unless a FieldTrialList | 229 // creating the FieldTrialList. This is not an error, unless a FieldTrialList |
| 230 // is created after that. | 230 // is created after that. |
| 231 static bool register_without_global_; | 231 static bool register_without_global_; |
| 232 | 232 |
| 233 // A helper value made availabel to users, that shows when the FieldTrialList | 233 // A helper value made availabel to users, that shows when the FieldTrialList |
| 234 // was initialized. Note that this is a singleton instance, and hence is a | 234 // was initialized. Note that this is a singleton instance, and hence is a |
| 235 // good approximation to the start of the process. | 235 // good approximation to the start of the process. |
| 236 TimeTicks application_start_time_; | 236 TimeTicks application_start_time_; |
| 237 | 237 |
| 238 // Lock for access to registered_. | 238 // Lock for access to registered_. |
| 239 Lock lock_; | 239 Lock lock_; |
| 240 RegistrationList registered_; | 240 RegistrationList registered_; |
| 241 | 241 |
| 242 DISALLOW_COPY_AND_ASSIGN(FieldTrialList); | 242 DISALLOW_COPY_AND_ASSIGN(FieldTrialList); |
| 243 }; | 243 }; |
| 244 | 244 |
| 245 } // namespace base | 245 } // namespace base |
| 246 | 246 |
| 247 #endif // BASE_METRICS_FIELD_TRIAL_H_ | 247 #endif // BASE_METRICS_FIELD_TRIAL_H_ |
| 248 | 248 |
| OLD | NEW |