| OLD | NEW |
| 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 #include <vector> | 80 #include <vector> |
| 81 | 81 |
| 82 #include "base/base_export.h" | 82 #include "base/base_export.h" |
| 83 #include "base/gtest_prod_util.h" | 83 #include "base/gtest_prod_util.h" |
| 84 #include "base/memory/ref_counted.h" | 84 #include "base/memory/ref_counted.h" |
| 85 #include "base/observer_list.h" | 85 #include "base/observer_list_threadsafe.h" |
| 86 #include "base/synchronization/lock.h" | 86 #include "base/synchronization/lock.h" |
| 87 #include "base/time.h" | 87 #include "base/time.h" |
| 88 | 88 |
| 89 namespace base { | 89 namespace base { |
| 90 | 90 |
| 91 class FieldTrialList; | 91 class FieldTrialList; |
| 92 | 92 |
| 93 class BASE_EXPORT FieldTrial : public RefCounted<FieldTrial> { | 93 class BASE_EXPORT FieldTrial : public RefCounted<FieldTrial> { |
| 94 public: | 94 public: |
| 95 typedef int Probability; // Probability type for being selected in a trial. | 95 typedef int Probability; // Probability type for being selected in a trial. |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 public: | 249 public: |
| 250 // Define a separator character to use when creating a persistent form of an | 250 // Define a separator character to use when creating a persistent form of an |
| 251 // instance. This is intended for use as a command line argument, passed to a | 251 // instance. This is intended for use as a command line argument, passed to a |
| 252 // second process to mimic our state (i.e., provide the same group name). | 252 // second process to mimic our state (i.e., provide the same group name). |
| 253 static const char kPersistentStringSeparator; // Currently a slash. | 253 static const char kPersistentStringSeparator; // Currently a slash. |
| 254 | 254 |
| 255 // Define expiration year in future. It is initialized to two years from Now. | 255 // Define expiration year in future. It is initialized to two years from Now. |
| 256 static int kExpirationYearInFuture; | 256 static int kExpirationYearInFuture; |
| 257 | 257 |
| 258 // Observer is notified when a FieldTrial's group is selected. | 258 // Observer is notified when a FieldTrial's group is selected. |
| 259 class Observer { | 259 class BASE_EXPORT Observer { |
| 260 public: | 260 public: |
| 261 // Notify observers when FieldTrials's group is selected. | 261 // Notify observers when FieldTrials's group is selected. |
| 262 virtual void OnFieldTrialGroupFinalized(const std::string& trial_name, | 262 virtual void OnFieldTrialGroupFinalized(const std::string& trial_name, |
| 263 const std::string& group_name) = 0; | 263 const std::string& group_name) = 0; |
| 264 | 264 |
| 265 protected: | 265 protected: |
| 266 virtual ~Observer() {} | 266 virtual ~Observer() {} |
| 267 }; | 267 }; |
| 268 | 268 |
| 269 // This singleton holds the global list of registered FieldTrials. | 269 // This singleton holds the global list of registered FieldTrials. |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 | 416 |
| 417 // Lock for access to registered_. | 417 // Lock for access to registered_. |
| 418 base::Lock lock_; | 418 base::Lock lock_; |
| 419 RegistrationList registered_; | 419 RegistrationList registered_; |
| 420 | 420 |
| 421 // An opaque, diverse ID for this client that does not change | 421 // An opaque, diverse ID for this client that does not change |
| 422 // between sessions, or the empty string if not initialized. | 422 // between sessions, or the empty string if not initialized. |
| 423 std::string client_id_; | 423 std::string client_id_; |
| 424 | 424 |
| 425 // List of observers to be notified when a group is selected for a FieldTrial. | 425 // List of observers to be notified when a group is selected for a FieldTrial. |
| 426 ObserverList<Observer> observer_list_; | 426 scoped_refptr<ObserverListThreadSafe<Observer> > observer_list_; |
| 427 | 427 |
| 428 DISALLOW_COPY_AND_ASSIGN(FieldTrialList); | 428 DISALLOW_COPY_AND_ASSIGN(FieldTrialList); |
| 429 }; | 429 }; |
| 430 | 430 |
| 431 } // namespace base | 431 } // namespace base |
| 432 | 432 |
| 433 #endif // BASE_METRICS_FIELD_TRIAL_H_ | 433 #endif // BASE_METRICS_FIELD_TRIAL_H_ |
| OLD | NEW |