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

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

Issue 6577038: Minor fixes in FieldTrial. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 10 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 | « base/metrics/field_trial.h ('k') | no next file » | 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/stringprintf.h" 9 #include "base/stringprintf.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 23 matching lines...) Expand all
34 const int year, 34 const int year,
35 const int month, 35 const int month,
36 const int day_of_month) 36 const int day_of_month)
37 : name_(name), 37 : name_(name),
38 divisor_(total_probability), 38 divisor_(total_probability),
39 default_group_name_(default_group_name), 39 default_group_name_(default_group_name),
40 random_(static_cast<Probability>(divisor_ * base::RandDouble())), 40 random_(static_cast<Probability>(divisor_ * base::RandDouble())),
41 accumulated_group_probability_(0), 41 accumulated_group_probability_(0),
42 next_group_number_(kDefaultGroupNumber+1), 42 next_group_number_(kDefaultGroupNumber+1),
43 group_(kNotFinalized) { 43 group_(kNotFinalized) {
44 DCHECK_GT(total_probability, 0);
44 DCHECK(!default_group_name_.empty()); 45 DCHECK(!default_group_name_.empty());
45 FieldTrialList::Register(this); 46 FieldTrialList::Register(this);
46 47
47 DCHECK_GT(year, 1970); 48 DCHECK_GT(year, 1970);
48 DCHECK_GT(month, 0); 49 DCHECK_GT(month, 0);
49 DCHECK_LT(month, 13); 50 DCHECK_LT(month, 13);
50 DCHECK_GT(day_of_month, 0); 51 DCHECK_GT(day_of_month, 0);
51 DCHECK_LT(day_of_month, 32); 52 DCHECK_LT(day_of_month, 32);
52 53
53 base::Time::Exploded exploded; 54 base::Time::Exploded exploded;
54 exploded.year = year; 55 exploded.year = year;
55 exploded.month = month; 56 exploded.month = month;
56 exploded.day_of_week = 0; // Should be unusued. 57 exploded.day_of_week = 0; // Should be unused.
57 exploded.day_of_month = day_of_month; 58 exploded.day_of_month = day_of_month;
58 exploded.hour = 0; 59 exploded.hour = 0;
59 exploded.minute = 0; 60 exploded.minute = 0;
60 exploded.second = 0; 61 exploded.second = 0;
61 exploded.millisecond = 0; 62 exploded.millisecond = 0;
62 63
63 base::Time expiration_time = Time::FromLocalExploded(exploded); 64 base::Time expiration_time = Time::FromLocalExploded(exploded);
64 disable_field_trial_ = (GetBuildTime() > expiration_time) ? true : false; 65 disable_field_trial_ = (GetBuildTime() > expiration_time) ? true : false;
65 } 66 }
66 67
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 } 264 }
264 265
265 FieldTrial* FieldTrialList::PreLockedFind(const std::string& name) { 266 FieldTrial* FieldTrialList::PreLockedFind(const std::string& name) {
266 RegistrationList::iterator it = registered_.find(name); 267 RegistrationList::iterator it = registered_.find(name);
267 if (registered_.end() == it) 268 if (registered_.end() == it)
268 return NULL; 269 return NULL;
269 return it->second; 270 return it->second;
270 } 271 }
271 272
272 } // namespace base 273 } // namespace base
OLDNEW
« no previous file with comments | « base/metrics/field_trial.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698