diff options
author | jar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-30 16:00:41 +0000 |
---|---|---|
committer | jar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-30 16:00:41 +0000 |
commit | 05a81412f30cc6ee91dc2ffb3205f24deaaac54d (patch) | |
tree | 6fa2d8657e8daaf4af3d995cb0a04224561e6155 /base/metrics | |
parent | 23e152e917c70e0399770433d564fe2f54c5ea95 (diff) | |
download | chromium_src-05a81412f30cc6ee91dc2ffb3205f24deaaac54d.zip chromium_src-05a81412f30cc6ee91dc2ffb3205f24deaaac54d.tar.gz chromium_src-05a81412f30cc6ee91dc2ffb3205f24deaaac54d.tar.bz2 |
Move flags initialization into block before sharing across threads
We re-initialized the flags after we shared the histograms, so
there was a potential race for multiple simultaneous initializations.
This change completes the basic setting of the flags prior to
registration, which in turn shares the histogram across threads.
There was a potential race with the (later) setting of the flag
during an upload from the renderer. With the new code, the flag
is const except for its potential change by the renderer-serialization
routine, which is also the only consumer of this flag (in
the renderer).
I also made the corresponding change to stats_histogram, even
though the code was already at least as correct, as I wanted
the patterns of use to remain analagous.
r=rvargas,rtenneti
BUG=77760
Review URL: http://codereview.chromium.org/6731074
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@79835 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/metrics')
-rw-r--r-- | base/metrics/histogram.cc | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/base/metrics/histogram.cc b/base/metrics/histogram.cc index cc49f4a..bf765c2 100644 --- a/base/metrics/histogram.cc +++ b/base/metrics/histogram.cc @@ -86,12 +86,12 @@ scoped_refptr<Histogram> Histogram::FactoryGet(const std::string& name, if (!StatisticsRecorder::FindHistogram(name, &histogram)) { histogram = new Histogram(name, minimum, maximum, bucket_count); histogram->InitializeBucketRange(); + histogram->SetFlags(flags); StatisticsRecorder::RegisterOrDiscardDuplicate(&histogram); } DCHECK_EQ(HISTOGRAM, histogram->histogram_type()); DCHECK(histogram->HasConstructorArguments(minimum, maximum, bucket_count)); - histogram->SetFlags(flags); return histogram; } @@ -778,12 +778,12 @@ scoped_refptr<Histogram> LinearHistogram::FactoryGet(const std::string& name, new LinearHistogram(name, minimum, maximum, bucket_count); linear_histogram->InitializeBucketRange(); histogram = linear_histogram; + histogram->SetFlags(flags); StatisticsRecorder::RegisterOrDiscardDuplicate(&histogram); } DCHECK_EQ(LINEAR_HISTOGRAM, histogram->histogram_type()); DCHECK(histogram->HasConstructorArguments(minimum, maximum, bucket_count)); - histogram->SetFlags(flags); return histogram; } @@ -870,11 +870,11 @@ scoped_refptr<Histogram> BooleanHistogram::FactoryGet(const std::string& name, BooleanHistogram* boolean_histogram = new BooleanHistogram(name); boolean_histogram->InitializeBucketRange(); histogram = boolean_histogram; + histogram->SetFlags(flags); StatisticsRecorder::RegisterOrDiscardDuplicate(&histogram); } DCHECK_EQ(BOOLEAN_HISTOGRAM, histogram->histogram_type()); - histogram->SetFlags(flags); return histogram; } @@ -917,13 +917,13 @@ scoped_refptr<Histogram> CustomHistogram::FactoryGet( CustomHistogram* custom_histogram = new CustomHistogram(name, ranges); custom_histogram->InitializedCustomBucketRange(ranges); histogram = custom_histogram; + histogram->SetFlags(flags); StatisticsRecorder::RegisterOrDiscardDuplicate(&histogram); } DCHECK_EQ(histogram->histogram_type(), CUSTOM_HISTOGRAM); DCHECK(histogram->HasConstructorArguments(ranges[1], ranges.back(), ranges.size())); - histogram->SetFlags(flags); return histogram; } |