Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(474)

Side by Side Diff: base/metrics/field_trial.cc

Issue 7972024: Update SHA1_LENGTH -> kSHA1Length to match previous change to SHA256_LENGTH. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « DEPS ('k') | base/sha1.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 } 163 }
164 164
165 // static 165 // static
166 double FieldTrial::HashClientId(const std::string& client_id, 166 double FieldTrial::HashClientId(const std::string& client_id,
167 const std::string& trial_name) { 167 const std::string& trial_name) {
168 // SHA-1 is designed to produce a uniformly random spread in its output space, 168 // 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 169 // 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 170 // and trial_name we get into something with a uniform distribution, which
171 // is desirable so that we don't skew any part of the 0-100% spectrum. 171 // is desirable so that we don't skew any part of the 0-100% spectrum.
172 std::string input(client_id + trial_name); 172 std::string input(client_id + trial_name);
173 unsigned char sha1_hash[SHA1_LENGTH]; 173 unsigned char sha1_hash[kSHA1Length];
174 SHA1HashBytes(reinterpret_cast<const unsigned char*>(input.c_str()), 174 SHA1HashBytes(reinterpret_cast<const unsigned char*>(input.c_str()),
175 input.size(), 175 input.size(),
176 sha1_hash); 176 sha1_hash);
177 177
178 COMPILE_ASSERT(sizeof(uint64) < sizeof(sha1_hash), need_more_data); 178 COMPILE_ASSERT(sizeof(uint64) < sizeof(sha1_hash), need_more_data);
179 uint64* bits = reinterpret_cast<uint64*>(&sha1_hash[0]); 179 uint64* bits = reinterpret_cast<uint64*>(&sha1_hash[0]);
180 180
181 return BitsToOpenEndedUnitInterval(*bits); 181 return BitsToOpenEndedUnitInterval(*bits);
182 } 182 }
183 183
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 } 386 }
387 387
388 FieldTrial* FieldTrialList::PreLockedFind(const std::string& name) { 388 FieldTrial* FieldTrialList::PreLockedFind(const std::string& name) {
389 RegistrationList::iterator it = registered_.find(name); 389 RegistrationList::iterator it = registered_.find(name);
390 if (registered_.end() == it) 390 if (registered_.end() == it)
391 return NULL; 391 return NULL;
392 return it->second; 392 return it->second;
393 } 393 }
394 394
395 } // namespace base 395 } // namespace base
OLDNEW
« no previous file with comments | « DEPS ('k') | base/sha1.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698