diff options
author | jar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-17 19:46:51 +0000 |
---|---|---|
committer | jar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-17 19:46:51 +0000 |
commit | cc82864b32ed75d814d02abe343c23910e3fc5d3 (patch) | |
tree | ac4e06c519d164934afe25aa409211b0ef159dc8 | |
parent | 5bba4dc2e195c986116bc18f7cffea1d31b9faf2 (diff) | |
download | chromium_src-cc82864b32ed75d814d02abe343c23910e3fc5d3.zip chromium_src-cc82864b32ed75d814d02abe343c23910e3fc5d3.tar.gz chromium_src-cc82864b32ed75d814d02abe343c23910e3fc5d3.tar.bz2 |
Handle race to create histogram more cleanly
Two threads are currently allowed to attempt
to define the same histogram at the same time.
A factory class sorts out which one was first,
and ensures that only the winner remains
registered. An old DCHECK used to assert
that only one caller (constructor) could
register a given histogram. This CL
removes that DCHECK, and leaves the
first to register as the winner.
BUG=52394
r=eroman
Review URL: http://codereview.chromium.org/3107018
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@56402 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | base/histogram.cc | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/base/histogram.cc b/base/histogram.cc index 31cc6a5..896867f 100644 --- a/base/histogram.cc +++ b/base/histogram.cc @@ -819,10 +819,9 @@ void StatisticsRecorder::Register(Histogram* histogram) { return; const std::string name = histogram->histogram_name(); AutoLock auto_lock(*lock_); - DCHECK(histograms_->end() == histograms_->find(name)); - - (*histograms_)[name] = histogram; - return; + // Avoid overwriting a previous registration. + if (histograms_->end() == histograms_->find(name)) + (*histograms_)[name] = histogram; } // static |