diff options
author | rtenneti@chromium.org <rtenneti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-19 04:02:42 +0000 |
---|---|---|
committer | rtenneti@chromium.org <rtenneti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-19 04:02:42 +0000 |
commit | 492fbbb2e23f4323af17413419c7401dcbeea7ed (patch) | |
tree | 87d6940ef5281d8ad8ed68921bac1f1134d96068 /base/metrics | |
parent | afbb80036f3f52f8f1d94ebf7f05df47172f734f (diff) | |
download | chromium_src-492fbbb2e23f4323af17413419c7401dcbeea7ed.zip chromium_src-492fbbb2e23f4323af17413419c7401dcbeea7ed.tar.gz chromium_src-492fbbb2e23f4323af17413419c7401dcbeea7ed.tar.bz2 |
Avoid racy construction of statics unless StatsTable is enabled.
BUG=76092
TEST=unit tests of network stack
R=jar
Review URL: http://codereview.chromium.org/6685106
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@78810 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/metrics')
-rw-r--r-- | base/metrics/stats_counters.cc | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/base/metrics/stats_counters.cc b/base/metrics/stats_counters.cc index 958f048..f763220 100644 --- a/base/metrics/stats_counters.cc +++ b/base/metrics/stats_counters.cc @@ -9,8 +9,12 @@ namespace base { StatsCounter::StatsCounter(const std::string& name) : counter_id_(-1) { // We prepend the name with 'c:' to indicate that it is a counter. - name_ = "c:"; - name_.append(name); + if (StatsTable::current()) { + // TODO(mbelshe): name_ construction is racy and it may corrupt memory for + // static. + name_ = "c:"; + name_.append(name); + } } StatsCounter::~StatsCounter() { @@ -61,8 +65,12 @@ int* StatsCounter::GetPtr() { StatsCounterTimer::StatsCounterTimer(const std::string& name) { // we prepend the name with 't:' to indicate that it is a timer. - name_ = "t:"; - name_.append(name); + if (StatsTable::current()) { + // TODO(mbelshe): name_ construction is racy and it may corrupt memory for + // static. + name_ = "t:"; + name_.append(name); + } } StatsCounterTimer::~StatsCounterTimer() { |