| 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 #include "base/metrics/field_trial.h" | 5 #include "base/metrics/field_trial.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/rand_util.h" | 8 #include "base/rand_util.h" |
| 9 #include "base/sha1.h" | 9 #include "base/sha1.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 DCHECK_EQ(0u, FieldTrialList::GetFieldTrialCount()); | 150 DCHECK_EQ(0u, FieldTrialList::GetFieldTrialCount()); |
| 151 enable_benchmarking_ = true; | 151 enable_benchmarking_ = true; |
| 152 } | 152 } |
| 153 | 153 |
| 154 FieldTrial::~FieldTrial() {} | 154 FieldTrial::~FieldTrial() {} |
| 155 | 155 |
| 156 // static | 156 // static |
| 157 Time FieldTrial::GetBuildTime() { | 157 Time FieldTrial::GetBuildTime() { |
| 158 Time integral_build_time; | 158 Time integral_build_time; |
| 159 const char* kDateTime = __DATE__ " " __TIME__; | 159 const char* kDateTime = __DATE__ " " __TIME__; |
| 160 bool result = Time::FromString(kDateTime, &integral_build_time); | 160 bool result = Time::FromString(ASCIIToWide(kDateTime).c_str(), |
| 161 &integral_build_time); |
| 161 DCHECK(result); | 162 DCHECK(result); |
| 162 return integral_build_time; | 163 return integral_build_time; |
| 163 } | 164 } |
| 164 | 165 |
| 165 // static | 166 // static |
| 166 double FieldTrial::HashClientId(const std::string& client_id, | 167 double FieldTrial::HashClientId(const std::string& client_id, |
| 167 const std::string& trial_name) { | 168 const std::string& trial_name) { |
| 168 // SHA-1 is designed to produce a uniformly random spread in its output space, | 169 // SHA-1 is designed to produce a uniformly random spread in its output space, |
| 169 // even for nearly-identical inputs, so it helps massage whatever client_id | 170 // even for nearly-identical inputs, so it helps massage whatever client_id |
| 170 // and trial_name we get into something with a uniform distribution, which | 171 // and trial_name we get into something with a uniform distribution, which |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 } | 387 } |
| 387 | 388 |
| 388 FieldTrial* FieldTrialList::PreLockedFind(const std::string& name) { | 389 FieldTrial* FieldTrialList::PreLockedFind(const std::string& name) { |
| 389 RegistrationList::iterator it = registered_.find(name); | 390 RegistrationList::iterator it = registered_.find(name); |
| 390 if (registered_.end() == it) | 391 if (registered_.end() == it) |
| 391 return NULL; | 392 return NULL; |
| 392 return it->second; | 393 return it->second; |
| 393 } | 394 } |
| 394 | 395 |
| 395 } // namespace base | 396 } // namespace base |
| OLD | NEW |