summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormbelshe@chromium.org <mbelshe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-22 17:36:07 +0000
committermbelshe@chromium.org <mbelshe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-22 17:36:07 +0000
commitf9ee3990f0eaf1bb340447bbd7d6c196e2178ab9 (patch)
tree00b9da6c1b32e5f435663e6c8626e0944b1f8735
parentc4058fb9d4e9203cec16ea7641d7ddc0fd07f2a4 (diff)
downloadchromium_src-f9ee3990f0eaf1bb340447bbd7d6c196e2178ab9.zip
chromium_src-f9ee3990f0eaf1bb340447bbd7d6c196e2178ab9.tar.gz
chromium_src-f9ee3990f0eaf1bb340447bbd7d6c196e2178ab9.tar.bz2
Safeguard histogram accesses against null pointers.
This can happen when various tasks run as the static destructors for histograms are concurrently running. BUG=none TEST=none Review URL: http://codereview.chromium.org/2873009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@50478 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--base/histogram.h20
1 files changed, 10 insertions, 10 deletions
diff --git a/base/histogram.h b/base/histogram.h
index edcb629..a11e293 100644
--- a/base/histogram.h
+++ b/base/histogram.h
@@ -61,7 +61,7 @@
static scoped_refptr<Histogram> counter = Histogram::FactoryGet( \
name, min, max, bucket_count, Histogram::kNoFlags); \
DCHECK_EQ(name, counter->histogram_name()); \
- counter->Add(sample); \
+ if (counter.get()) counter->Add(sample); \
} while (0)
#define HISTOGRAM_PERCENTAGE(name, under_one_hundred) \
@@ -73,7 +73,7 @@
static scoped_refptr<Histogram> counter = Histogram::FactoryTimeGet( \
name, min, max, bucket_count, Histogram::kNoFlags); \
DCHECK_EQ(name, counter->histogram_name()); \
- counter->AddTime(sample); \
+ if (counter.get()) counter->AddTime(sample); \
} while (0)
// DO NOT USE THIS. It is being phased out, in favor of HISTOGRAM_CUSTOM_TIMES.
@@ -81,7 +81,7 @@
static scoped_refptr<Histogram> counter = Histogram::FactoryTimeGet( \
name, min, max, bucket_count, Histogram::kNoFlags); \
DCHECK_EQ(name, counter->histogram_name()); \
- if ((sample) < (max)) counter->AddTime(sample); \
+ if ((sample) < (max) && counter.get()) counter->AddTime(sample); \
} while (0)
// Support histograming of an enumerated value. The samples should always be
@@ -91,14 +91,14 @@
static scoped_refptr<Histogram> counter = LinearHistogram::FactoryGet( \
name, 1, boundary_value, boundary_value + 1, Histogram::kNoFlags); \
DCHECK_EQ(name, counter->histogram_name()); \
- counter->Add(sample); \
+ if (counter.get()) counter->Add(sample); \
} while (0)
#define HISTOGRAM_CUSTOM_ENUMERATION(name, sample, custom_ranges) do { \
static scoped_refptr<Histogram> counter = CustomHistogram::FactoryGet( \
name, custom_ranges, Histogram::kNoFlags); \
DCHECK_EQ(name, counter->histogram_name()); \
- counter->Add(sample); \
+ if (counter.get()) counter->Add(sample); \
} while (0)
@@ -161,7 +161,7 @@
static scoped_refptr<Histogram> counter = Histogram::FactoryTimeGet( \
name, min, max, bucket_count, Histogram::kUmaTargetedHistogramFlag); \
DCHECK_EQ(name, counter->histogram_name()); \
- counter->AddTime(sample); \
+ if (counter.get()) counter->AddTime(sample); \
} while (0)
// DO NOT USE THIS. It is being phased out, in favor of HISTOGRAM_CUSTOM_TIMES.
@@ -169,7 +169,7 @@
static scoped_refptr<Histogram> counter = Histogram::FactoryTimeGet( \
name, min, max, bucket_count, Histogram::kUmaTargetedHistogramFlag); \
DCHECK_EQ(name, counter->histogram_name()); \
- if ((sample) < (max)) counter->AddTime(sample); \
+ if ((sample) < (max) && counter.get()) counter->AddTime(sample); \
} while (0)
#define UMA_HISTOGRAM_COUNTS(name, sample) UMA_HISTOGRAM_CUSTOM_COUNTS( \
@@ -185,7 +185,7 @@
static scoped_refptr<Histogram> counter = Histogram::FactoryGet( \
name, min, max, bucket_count, Histogram::kUmaTargetedHistogramFlag); \
DCHECK_EQ(name, counter->histogram_name()); \
- counter->Add(sample); \
+ if (counter.get()) counter->Add(sample); \
} while (0)
#define UMA_HISTOGRAM_MEMORY_KB(name, sample) UMA_HISTOGRAM_CUSTOM_COUNTS( \
@@ -202,14 +202,14 @@
name, 1, boundary_value, boundary_value + 1, \
Histogram::kUmaTargetedHistogramFlag); \
DCHECK_EQ(name, counter->histogram_name()); \
- counter->Add(sample); \
+ if (counter.get()) counter->Add(sample); \
} while (0)
#define UMA_HISTOGRAM_CUSTOM_ENUMERATION(name, sample, custom_ranges) do { \
static scoped_refptr<Histogram> counter = CustomHistogram::FactoryGet( \
name, custom_ranges, Histogram::kUmaTargetedHistogramFlag); \
DCHECK_EQ(name, counter->histogram_name()); \
- counter->Add(sample); \
+ if (counter.get()) counter->Add(sample); \
} while (0)
//------------------------------------------------------------------------------