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

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

Issue 11783033: Fix problem where field trials using kExpirationYearInFuture could get disabled. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 11 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/build_time.h" 7 #include "base/build_time.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/rand_util.h" 10 #include "base/rand_util.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 } // namespace 42 } // namespace
43 43
44 static const char kHistogramFieldTrialSeparator('_'); 44 static const char kHistogramFieldTrialSeparator('_');
45 45
46 // statics 46 // statics
47 const int FieldTrial::kNotFinalized = -1; 47 const int FieldTrial::kNotFinalized = -1;
48 const int FieldTrial::kDefaultGroupNumber = 0; 48 const int FieldTrial::kDefaultGroupNumber = 0;
49 bool FieldTrial::enable_benchmarking_ = false; 49 bool FieldTrial::enable_benchmarking_ = false;
50 50
51 const char FieldTrialList::kPersistentStringSeparator('/'); 51 const char FieldTrialList::kPersistentStringSeparator('/');
52 int FieldTrialList::kExpirationYearInFuture = 0; 52 int FieldTrialList::kExpirationYearNotExpired = 0;
53 53
54 //------------------------------------------------------------------------------ 54 //------------------------------------------------------------------------------
55 // FieldTrial methods and members. 55 // FieldTrial methods and members.
56 56
57 FieldTrial::FieldTrial(const std::string& trial_name, 57 FieldTrial::FieldTrial(const std::string& trial_name,
58 const Probability total_probability, 58 const Probability total_probability,
59 const std::string& default_group_name) 59 const std::string& default_group_name)
60 : trial_name_(trial_name), 60 : trial_name_(trial_name),
61 divisor_(total_probability), 61 divisor_(total_probability),
62 default_group_name_(default_group_name), 62 default_group_name_(default_group_name),
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 237
238 FieldTrialList::FieldTrialList( 238 FieldTrialList::FieldTrialList(
239 const FieldTrial::EntropyProvider* entropy_provider) 239 const FieldTrial::EntropyProvider* entropy_provider)
240 : entropy_provider_(entropy_provider), 240 : entropy_provider_(entropy_provider),
241 observer_list_(new ObserverListThreadSafe<FieldTrialList::Observer>( 241 observer_list_(new ObserverListThreadSafe<FieldTrialList::Observer>(
242 ObserverListBase<FieldTrialList::Observer>::NOTIFY_EXISTING_ONLY)) { 242 ObserverListBase<FieldTrialList::Observer>::NOTIFY_EXISTING_ONLY)) {
243 DCHECK(!global_); 243 DCHECK(!global_);
244 DCHECK(!used_without_global_); 244 DCHECK(!used_without_global_);
245 global_ = this; 245 global_ = this;
246 246
247 Time two_years_from_build_time = GetBuildTime() + TimeDelta::FromDays(730);
247 Time::Exploded exploded; 248 Time::Exploded exploded;
248 Time two_years_from_now = 249 two_years_from_build_time.LocalExplode(&exploded);
249 Time::NowFromSystemTime() + TimeDelta::FromDays(730); 250 kExpirationYearNotExpired = exploded.year;
250 two_years_from_now.LocalExplode(&exploded);
251 kExpirationYearInFuture = exploded.year;
252 } 251 }
253 252
254 FieldTrialList::~FieldTrialList() { 253 FieldTrialList::~FieldTrialList() {
255 AutoLock auto_lock(lock_); 254 AutoLock auto_lock(lock_);
256 while (!registered_.empty()) { 255 while (!registered_.empty()) {
257 RegistrationList::iterator it = registered_.begin(); 256 RegistrationList::iterator it = registered_.begin();
258 it->second->Release(); 257 it->second->Release();
259 registered_.erase(it->first); 258 registered_.erase(it->first);
260 } 259 }
261 DCHECK_EQ(this, global_); 260 DCHECK_EQ(this, global_);
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 used_without_global_ = true; 485 used_without_global_ = true;
487 return; 486 return;
488 } 487 }
489 AutoLock auto_lock(global_->lock_); 488 AutoLock auto_lock(global_->lock_);
490 DCHECK(!global_->PreLockedFind(trial->trial_name())); 489 DCHECK(!global_->PreLockedFind(trial->trial_name()));
491 trial->AddRef(); 490 trial->AddRef();
492 global_->registered_[trial->trial_name()] = trial; 491 global_->registered_[trial->trial_name()] = trial;
493 } 492 }
494 493
495 } // namespace base 494 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698