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 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 | 71 |
72 //------------------------------------------------------------------------------ | 72 //------------------------------------------------------------------------------ |
73 | 73 |
74 #ifndef BASE_METRICS_FIELD_TRIAL_H_ | 74 #ifndef BASE_METRICS_FIELD_TRIAL_H_ |
75 #define BASE_METRICS_FIELD_TRIAL_H_ | 75 #define BASE_METRICS_FIELD_TRIAL_H_ |
76 #pragma once | 76 #pragma once |
77 | 77 |
78 #include <map> | 78 #include <map> |
79 #include <string> | 79 #include <string> |
80 | 80 |
| 81 #include "base/base_api.h" |
81 #include "base/gtest_prod_util.h" | 82 #include "base/gtest_prod_util.h" |
82 #include "base/ref_counted.h" | 83 #include "base/ref_counted.h" |
83 #include "base/synchronization/lock.h" | 84 #include "base/synchronization/lock.h" |
84 #include "base/time.h" | 85 #include "base/time.h" |
85 | 86 |
86 namespace base { | 87 namespace base { |
87 | 88 |
88 class FieldTrialList; | 89 class FieldTrialList; |
89 | 90 |
90 class FieldTrial : public RefCounted<FieldTrial> { | 91 class BASE_API FieldTrial : public RefCounted<FieldTrial> { |
91 public: | 92 public: |
92 typedef int Probability; // Probability type for being selected in a trial. | 93 typedef int Probability; // Probability type for being selected in a trial. |
93 | 94 |
94 // A return value to indicate that a given instance has not yet had a group | 95 // A return value to indicate that a given instance has not yet had a group |
95 // assignment (and hence is not yet participating in the trial). | 96 // assignment (and hence is not yet participating in the trial). |
96 static const int kNotFinalized; | 97 static const int kNotFinalized; |
97 | 98 |
98 // This is the group number of the 'default' group. This provides an easy way | 99 // This is the group number of the 'default' group. This provides an easy way |
99 // to assign all the remaining probability to a group ('default'). | 100 // to assign all the remaining probability to a group ('default'). |
100 static const int kDefaultGroupNumber; | 101 static const int kDefaultGroupNumber; |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 // group. | 204 // group. |
204 static bool enable_benchmarking_; | 205 static bool enable_benchmarking_; |
205 | 206 |
206 DISALLOW_COPY_AND_ASSIGN(FieldTrial); | 207 DISALLOW_COPY_AND_ASSIGN(FieldTrial); |
207 }; | 208 }; |
208 | 209 |
209 //------------------------------------------------------------------------------ | 210 //------------------------------------------------------------------------------ |
210 // Class with a list of all active field trials. A trial is active if it has | 211 // Class with a list of all active field trials. A trial is active if it has |
211 // been registered, which includes evaluating its state based on its probaility. | 212 // been registered, which includes evaluating its state based on its probaility. |
212 // Only one instance of this class exists. | 213 // Only one instance of this class exists. |
213 class FieldTrialList { | 214 class BASE_API FieldTrialList { |
214 public: | 215 public: |
215 // Define a separator charactor to use when creating a persistent form of an | 216 // Define a separator charactor to use when creating a persistent form of an |
216 // instance. This is intended for use as a command line argument, passed to a | 217 // instance. This is intended for use as a command line argument, passed to a |
217 // second process to mimic our state (i.e., provide the same group name). | 218 // second process to mimic our state (i.e., provide the same group name). |
218 static const char kPersistentStringSeparator; // Currently a slash. | 219 static const char kPersistentStringSeparator; // Currently a slash. |
219 | 220 |
220 // This singleton holds the global list of registered FieldTrials. | 221 // This singleton holds the global list of registered FieldTrials. |
221 FieldTrialList(); | 222 FieldTrialList(); |
222 // Destructor Release()'s references to all registered FieldTrial instances. | 223 // Destructor Release()'s references to all registered FieldTrial instances. |
223 ~FieldTrialList(); | 224 ~FieldTrialList(); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 base::Lock lock_; | 288 base::Lock lock_; |
288 RegistrationList registered_; | 289 RegistrationList registered_; |
289 | 290 |
290 DISALLOW_COPY_AND_ASSIGN(FieldTrialList); | 291 DISALLOW_COPY_AND_ASSIGN(FieldTrialList); |
291 }; | 292 }; |
292 | 293 |
293 } // namespace base | 294 } // namespace base |
294 | 295 |
295 #endif // BASE_METRICS_FIELD_TRIAL_H_ | 296 #endif // BASE_METRICS_FIELD_TRIAL_H_ |
296 | 297 |
OLD | NEW |