| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #include "chrome/browser/stack_sampling_configuration.h" | 5 #include "chrome/browser/stack_sampling_configuration.h" |
| 6 | 6 |
| 7 #include "base/rand_util.h" | 7 #include "base/rand_util.h" |
| 8 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h" | 8 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h" |
| 9 #include "chrome/common/channel_info.h" | 9 #include "chrome/common/channel_info.h" |
| 10 #include "components/version_info/version_info.h" | 10 #include "components/version_info/version_info.h" |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 // Enable according to the variations below in canary and dev. | 126 // Enable according to the variations below in canary and dev. |
| 127 if (chrome::GetChannel() == version_info::Channel::CANARY || | 127 if (chrome::GetChannel() == version_info::Channel::CANARY || |
| 128 chrome::GetChannel() == version_info::Channel::DEV) { | 128 chrome::GetChannel() == version_info::Channel::DEV) { |
| 129 struct Variation { | 129 struct Variation { |
| 130 ProfileConfiguration config; | 130 ProfileConfiguration config; |
| 131 int weight; | 131 int weight; |
| 132 }; | 132 }; |
| 133 | 133 |
| 134 // Generate a configuration according to the associated weights. | 134 // Generate a configuration according to the associated weights. |
| 135 const Variation variations[] = { | 135 const Variation variations[] = { |
| 136 { PROFILE_10HZ, 50}, | 136 { PROFILE_10HZ, 15}, |
| 137 { PROFILE_CONTROL, 50}, | 137 { PROFILE_CONTROL, 15}, |
| 138 { PROFILE_DISABLED, 0} | 138 { PROFILE_DISABLED, 70} |
| 139 }; | 139 }; |
| 140 | 140 |
| 141 int total_weight = 0; | 141 int total_weight = 0; |
| 142 for (const Variation& variation : variations) | 142 for (const Variation& variation : variations) |
| 143 total_weight += variation.weight; | 143 total_weight += variation.weight; |
| 144 DCHECK_EQ(100, total_weight); | 144 DCHECK_EQ(100, total_weight); |
| 145 | 145 |
| 146 int chosen = base::RandInt(0, total_weight - 1); // Max is inclusive. | 146 int chosen = base::RandInt(0, total_weight - 1); // Max is inclusive. |
| 147 int cumulative_weight = 0; | 147 int cumulative_weight = 0; |
| 148 for (const Variation& variation : variations) { | 148 for (const Variation& variation : variations) { |
| 149 if (chosen >= cumulative_weight && | 149 if (chosen >= cumulative_weight && |
| 150 chosen < cumulative_weight + variation.weight) { | 150 chosen < cumulative_weight + variation.weight) { |
| 151 return variation.config; | 151 return variation.config; |
| 152 } | 152 } |
| 153 cumulative_weight += variation.weight; | 153 cumulative_weight += variation.weight; |
| 154 } | 154 } |
| 155 NOTREACHED(); | 155 NOTREACHED(); |
| 156 } | 156 } |
| 157 | 157 |
| 158 return PROFILE_DISABLED; | 158 return PROFILE_DISABLED; |
| 159 } | 159 } |
| OLD | NEW |