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

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

Issue 2358723002: Convert FieldTrialList to Accept a std::unique_ptr (Closed)
Patch Set: Change Comment nullptr to null Created 4 years, 3 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
« no previous file with comments | « base/metrics/field_trial.h ('k') | chrome/browser/autocomplete/search_provider_unittest.cc » ('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) 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 <algorithm> 7 #include <algorithm>
8 #include <utility>
8 9
9 #include "base/build_time.h" 10 #include "base/build_time.h"
10 #include "base/logging.h" 11 #include "base/logging.h"
11 #include "base/rand_util.h" 12 #include "base/rand_util.h"
12 #include "base/strings/string_number_conversions.h" 13 #include "base/strings/string_number_conversions.h"
13 #include "base/strings/string_util.h" 14 #include "base/strings/string_util.h"
14 #include "base/strings/stringprintf.h" 15 #include "base/strings/stringprintf.h"
15 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
16 17
17 namespace base { 18 namespace base {
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 // static 302 // static
302 FieldTrialList* FieldTrialList::global_ = NULL; 303 FieldTrialList* FieldTrialList::global_ = NULL;
303 304
304 // static 305 // static
305 bool FieldTrialList::used_without_global_ = false; 306 bool FieldTrialList::used_without_global_ = false;
306 307
307 FieldTrialList::Observer::~Observer() { 308 FieldTrialList::Observer::~Observer() {
308 } 309 }
309 310
310 FieldTrialList::FieldTrialList( 311 FieldTrialList::FieldTrialList(
311 const FieldTrial::EntropyProvider* entropy_provider) 312 std::unique_ptr<const FieldTrial::EntropyProvider> entropy_provider)
312 : entropy_provider_(entropy_provider), 313 : entropy_provider_(std::move(entropy_provider)),
313 observer_list_(new ObserverListThreadSafe<FieldTrialList::Observer>( 314 observer_list_(new ObserverListThreadSafe<FieldTrialList::Observer>(
314 ObserverListBase<FieldTrialList::Observer>::NOTIFY_EXISTING_ONLY)) { 315 ObserverListBase<FieldTrialList::Observer>::NOTIFY_EXISTING_ONLY)) {
315 DCHECK(!global_); 316 DCHECK(!global_);
316 DCHECK(!used_without_global_); 317 DCHECK(!used_without_global_);
317 global_ = this; 318 global_ = this;
318 319
319 Time two_years_from_build_time = GetBuildTime() + TimeDelta::FromDays(730); 320 Time two_years_from_build_time = GetBuildTime() + TimeDelta::FromDays(730);
320 Time::Exploded exploded; 321 Time::Exploded exploded;
321 two_years_from_build_time.LocalExplode(&exploded); 322 two_years_from_build_time.LocalExplode(&exploded);
322 kNoExpirationYear = exploded.year; 323 kNoExpirationYear = exploded.year;
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 return; 650 return;
650 } 651 }
651 AutoLock auto_lock(global_->lock_); 652 AutoLock auto_lock(global_->lock_);
652 CHECK(!global_->PreLockedFind(trial->trial_name())) << trial->trial_name(); 653 CHECK(!global_->PreLockedFind(trial->trial_name())) << trial->trial_name();
653 trial->AddRef(); 654 trial->AddRef();
654 trial->SetTrialRegistered(); 655 trial->SetTrialRegistered();
655 global_->registered_[trial->trial_name()] = trial; 656 global_->registered_[trial->trial_name()] = trial;
656 } 657 }
657 658
658 } // namespace base 659 } // namespace base
OLDNEW
« no previous file with comments | « base/metrics/field_trial.h ('k') | chrome/browser/autocomplete/search_provider_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698