| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 | 56 |
| 57 #include <stddef.h> | 57 #include <stddef.h> |
| 58 #include <stdint.h> | 58 #include <stdint.h> |
| 59 | 59 |
| 60 #include <map> | 60 #include <map> |
| 61 #include <memory> | 61 #include <memory> |
| 62 #include <set> | 62 #include <set> |
| 63 #include <string> | 63 #include <string> |
| 64 #include <vector> | 64 #include <vector> |
| 65 | 65 |
| 66 #include "base/atomicops.h" |
| 66 #include "base/base_export.h" | 67 #include "base/base_export.h" |
| 67 #include "base/command_line.h" | 68 #include "base/command_line.h" |
| 68 #include "base/feature_list.h" | 69 #include "base/feature_list.h" |
| 69 #include "base/files/file.h" | 70 #include "base/files/file.h" |
| 70 #include "base/gtest_prod_util.h" | 71 #include "base/gtest_prod_util.h" |
| 71 #include "base/macros.h" | 72 #include "base/macros.h" |
| 72 #include "base/memory/ref_counted.h" | 73 #include "base/memory/ref_counted.h" |
| 73 #include "base/memory/shared_memory.h" | 74 #include "base/memory/shared_memory.h" |
| 74 #include "base/metrics/persistent_memory_allocator.h" | 75 #include "base/metrics/persistent_memory_allocator.h" |
| 75 #include "base/observer_list_threadsafe.h" | 76 #include "base/observer_list_threadsafe.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 | 137 |
| 137 // We create one FieldTrialEntry per field trial in shared memory, via | 138 // We create one FieldTrialEntry per field trial in shared memory, via |
| 138 // AddToAllocatorWhileLocked. The FieldTrialEntry is followed by a | 139 // AddToAllocatorWhileLocked. The FieldTrialEntry is followed by a |
| 139 // base::Pickle object that we unpickle and read from. Any changes to this | 140 // base::Pickle object that we unpickle and read from. Any changes to this |
| 140 // structure requires a bump in kFieldTrialType id defined in the .cc file. | 141 // structure requires a bump in kFieldTrialType id defined in the .cc file. |
| 141 struct BASE_EXPORT FieldTrialEntry { | 142 struct BASE_EXPORT FieldTrialEntry { |
| 142 // Expected size for 32/64-bit check. | 143 // Expected size for 32/64-bit check. |
| 143 static constexpr size_t kExpectedInstanceSize = 8; | 144 static constexpr size_t kExpectedInstanceSize = 8; |
| 144 | 145 |
| 145 // Whether or not this field trial is activated. This is really just a | 146 // Whether or not this field trial is activated. This is really just a |
| 146 // boolean but marked as a uint32_t for portability reasons. | 147 // boolean but using a 32 bit value for portability reasons. It should be |
| 147 uint32_t activated; | 148 // accessed via NoBarrier_Load()/NoBarrier_Store() to prevent the compiler |
| 149 // from doing unexpected optimizations because it thinks that only one |
| 150 // thread is accessing the memory location. |
| 151 subtle::Atomic32 activated; |
| 148 | 152 |
| 149 // Size of the pickled structure, NOT the total size of this entry. | 153 // Size of the pickled structure, NOT the total size of this entry. |
| 150 uint32_t pickle_size; | 154 uint32_t pickle_size; |
| 151 | 155 |
| 152 // Calling this is only valid when the entry is initialized. That is, it | 156 // Calling this is only valid when the entry is initialized. That is, it |
| 153 // resides in shared memory and has a pickle containing the trial name and | 157 // resides in shared memory and has a pickle containing the trial name and |
| 154 // group name following it. | 158 // group name following it. |
| 155 bool GetTrialAndGroupName(StringPiece* trial_name, | 159 bool GetTrialAndGroupName(StringPiece* trial_name, |
| 156 StringPiece* group_name) const; | 160 StringPiece* group_name) const; |
| 157 | 161 |
| (...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 726 | 730 |
| 727 // Tracks whether CreateTrialsFromCommandLine() has been called. | 731 // Tracks whether CreateTrialsFromCommandLine() has been called. |
| 728 bool create_trials_from_command_line_called_ = false; | 732 bool create_trials_from_command_line_called_ = false; |
| 729 | 733 |
| 730 DISALLOW_COPY_AND_ASSIGN(FieldTrialList); | 734 DISALLOW_COPY_AND_ASSIGN(FieldTrialList); |
| 731 }; | 735 }; |
| 732 | 736 |
| 733 } // namespace base | 737 } // namespace base |
| 734 | 738 |
| 735 #endif // BASE_METRICS_FIELD_TRIAL_H_ | 739 #endif // BASE_METRICS_FIELD_TRIAL_H_ |
| OLD | NEW |