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

Side by Side Diff: base/field_trial.cc

Issue 18535: Decrements FieldTrialList::constructor_count_ in the destructor. I'm... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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
« no previous file with comments | « base/field_trial.h ('k') | base/field_trial_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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 5
6 #include "base/field_trial.h" 6 #include "base/field_trial.h"
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/rand_util.h" 8 #include "base/rand_util.h"
9 9
10 using base::Time; 10 using base::Time;
11 11
12 //------------------------------------------------------------------------------ 12 //------------------------------------------------------------------------------
13 // FieldTrialList methods and members. 13 // FieldTrialList methods and members.
14 14
15 // static 15 // static
16 FieldTrialList* FieldTrialList::global_ = NULL; 16 FieldTrialList* FieldTrialList::global_ = NULL;
17 17
18 // static
19 int FieldTrialList::constructor_count_ = 0;
20
21 FieldTrialList::FieldTrialList() 18 FieldTrialList::FieldTrialList()
22 : application_start_time_(Time::Now()) { 19 : application_start_time_(Time::Now()) {
23 DCHECK(!constructor_count_); 20 DCHECK(!global_);
24 ++constructor_count_;
25 global_ = this; 21 global_ = this;
26 } 22 }
27 23
28 FieldTrialList::~FieldTrialList() { 24 FieldTrialList::~FieldTrialList() {
29 while (!registered_.empty()) { 25 while (!registered_.empty()) {
30 RegistrationList::iterator it = registered_.begin(); 26 RegistrationList::iterator it = registered_.begin();
31 it->second->Release(); 27 it->second->Release();
32 registered_.erase(it->first); 28 registered_.erase(it->first);
33 } 29 }
34 DCHECK(this == global_); 30 DCHECK(this == global_);
(...skipping 20 matching lines...) Expand all
55 //------------------------------------------------------------------------------ 51 //------------------------------------------------------------------------------
56 // FieldTrial methods and members. 52 // FieldTrial methods and members.
57 53
58 FieldTrial::FieldTrial(const std::wstring& name, double probability) 54 FieldTrial::FieldTrial(const std::wstring& name, double probability)
59 : name_(name) { 55 : name_(name) {
60 double rand = base::RandDouble(); 56 double rand = base::RandDouble();
61 DCHECK(rand >= 0.0 && rand < 1.0); 57 DCHECK(rand >= 0.0 && rand < 1.0);
62 boolean_value_ = rand < probability; 58 boolean_value_ = rand < probability;
63 FieldTrialList::Register(this); 59 FieldTrialList::Register(this);
64 } 60 }
OLDNEW
« no previous file with comments | « base/field_trial.h ('k') | base/field_trial_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698