Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/metrics/metrics_state_manager.h" | 5 #include "components/metrics/metrics_state_manager.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/guid.h" | 8 #include "base/guid.h" |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/metrics/sparse_histogram.h" | 10 #include "base/metrics/sparse_histogram.h" |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 154 // entropy source. | 154 // entropy source. |
| 155 // This has two useful properties: | 155 // This has two useful properties: |
| 156 // 1) It makes the entropy source less identifiable for parties that do not | 156 // 1) It makes the entropy source less identifiable for parties that do not |
| 157 // know the low entropy source. | 157 // know the low entropy source. |
| 158 // 2) It makes the final entropy source resettable. | 158 // 2) It makes the final entropy source resettable. |
| 159 const int low_entropy_source_value = GetLowEntropySource(); | 159 const int low_entropy_source_value = GetLowEntropySource(); |
| 160 UMA_HISTOGRAM_SPARSE_SLOWLY("UMA.LowEntropySourceValue", | 160 UMA_HISTOGRAM_SPARSE_SLOWLY("UMA.LowEntropySourceValue", |
| 161 low_entropy_source_value); | 161 low_entropy_source_value); |
| 162 if (IsMetricsReportingEnabled()) { | 162 if (IsMetricsReportingEnabled()) { |
| 163 if (entropy_source_returned_ == ENTROPY_SOURCE_NONE) | 163 if (entropy_source_returned_ == ENTROPY_SOURCE_NONE) |
| 164 entropy_source_returned_ = ENTROPY_SOURCE_HIGH; | 164 entropy_source_returned_ = ENTROPY_SOURCE_HIGH; |
|
Ilya Sherman
2014/08/19 21:04:14
Is this if stmt, as well as the one below, still c
Alexei Svitkine (slow)
2014/08/19 21:10:25
Yes, the field is documented to track the first va
| |
| 165 DCHECK_EQ(ENTROPY_SOURCE_HIGH, entropy_source_returned_); | |
| 166 const std::string high_entropy_source = | 165 const std::string high_entropy_source = |
| 167 client_id_ + base::IntToString(low_entropy_source_value); | 166 client_id_ + base::IntToString(low_entropy_source_value); |
| 168 return scoped_ptr<const base::FieldTrial::EntropyProvider>( | 167 return scoped_ptr<const base::FieldTrial::EntropyProvider>( |
| 169 new SHA1EntropyProvider(high_entropy_source)); | 168 new SHA1EntropyProvider(high_entropy_source)); |
| 170 } | 169 } |
| 171 | 170 |
| 172 if (entropy_source_returned_ == ENTROPY_SOURCE_NONE) | 171 if (entropy_source_returned_ == ENTROPY_SOURCE_NONE) |
| 173 entropy_source_returned_ = ENTROPY_SOURCE_LOW; | 172 entropy_source_returned_ = ENTROPY_SOURCE_LOW; |
| 174 DCHECK_EQ(ENTROPY_SOURCE_LOW, entropy_source_returned_); | |
| 175 | 173 |
| 176 #if defined(OS_ANDROID) || defined(OS_IOS) | 174 #if defined(OS_ANDROID) || defined(OS_IOS) |
| 177 return scoped_ptr<const base::FieldTrial::EntropyProvider>( | 175 return scoped_ptr<const base::FieldTrial::EntropyProvider>( |
| 178 new CachingPermutedEntropyProvider(local_state_, | 176 new CachingPermutedEntropyProvider(local_state_, |
| 179 low_entropy_source_value, | 177 low_entropy_source_value, |
| 180 kMaxLowEntropySize)); | 178 kMaxLowEntropySize)); |
| 181 #else | 179 #else |
| 182 return scoped_ptr<const base::FieldTrial::EntropyProvider>( | 180 return scoped_ptr<const base::FieldTrial::EntropyProvider>( |
| 183 new PermutedEntropyProvider(low_entropy_source_value, | 181 new PermutedEntropyProvider(low_entropy_source_value, |
| 184 kMaxLowEntropySize)); | 182 kMaxLowEntropySize)); |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 304 | 302 |
| 305 local_state_->ClearPref(prefs::kMetricsClientID); | 303 local_state_->ClearPref(prefs::kMetricsClientID); |
| 306 local_state_->ClearPref(prefs::kMetricsLowEntropySource); | 304 local_state_->ClearPref(prefs::kMetricsLowEntropySource); |
| 307 local_state_->ClearPref(prefs::kMetricsResetIds); | 305 local_state_->ClearPref(prefs::kMetricsResetIds); |
| 308 | 306 |
| 309 // Also clear the backed up client info. | 307 // Also clear the backed up client info. |
| 310 store_client_info_.Run(ClientInfo()); | 308 store_client_info_.Run(ClientInfo()); |
| 311 } | 309 } |
| 312 | 310 |
| 313 } // namespace metrics | 311 } // namespace metrics |
| OLD | NEW |