Index: base/metrics/histogram.cc |
diff --git a/base/metrics/histogram.cc b/base/metrics/histogram.cc |
index fbe66d05d29fd3c2896f8499dd1dc07d9793d095..2ae444e3c9f4f86b2f94063da22418402a02da14 100644 |
--- a/base/metrics/histogram.cc |
+++ b/base/metrics/histogram.cc |
@@ -110,7 +110,16 @@ HistogramBase* Histogram::FactoryGet(const string& name, |
} |
DCHECK_EQ(HISTOGRAM, histogram->GetHistogramType()); |
- CHECK(histogram->HasConstructionArguments(minimum, maximum, bucket_count)); |
+ if (!histogram->HasConstructionArguments(minimum, maximum, bucket_count)) { |
+ // The construction arguments do not match the existing histogram. This can |
+ // come about if an extension updates in the middle of a chrome run and has |
+ // changed one of them. We return a dummy object here instead of crashing |
+ // so poor use of extension/Pepper APIs do not cause crashes in Chrome. |
+ DLOG(ERROR) << "Histogram " << name << " has bad construction arguments"; |
+ DummyHistogram* tentative_histogram = new DummyHistogram; |
+ histogram = |
+ StatisticsRecorder::RegisterOrDeleteDuplicate(tentative_histogram); |
+ } |
return histogram; |
} |
@@ -567,7 +576,16 @@ HistogramBase* LinearHistogram::FactoryGetWithRangeDescription( |
} |
DCHECK_EQ(LINEAR_HISTOGRAM, histogram->GetHistogramType()); |
- CHECK(histogram->HasConstructionArguments(minimum, maximum, bucket_count)); |
+ if (!histogram->HasConstructionArguments(minimum, maximum, bucket_count)) { |
+ // The construction arguments do not match the existing histogram. This can |
+ // come about if an extension updates in the middle of a chrome run and has |
+ // changed one of them. We return a dummy object here instead of crashing |
+ // so poor use of extension/Pepper APIs do not cause crashes in Chrome. |
+ DLOG(ERROR) << "Histogram " << name << " has bad construction arguments"; |
+ DummyHistogram* tentative_histogram = new DummyHistogram; |
+ histogram = |
+ StatisticsRecorder::RegisterOrDeleteDuplicate(tentative_histogram); |
+ } |
return histogram; |
} |
@@ -831,4 +849,10 @@ BucketRanges* CustomHistogram::CreateBucketRangesFromCustomRanges( |
return bucket_ranges; |
} |
+bool DummyHistogram::AddSamplesFromPickle(PickleIterator* iter) { |
+ return false; |
+} |
+ |
+DummyHistogram::DummyHistogram() : Histogram("Dummy", 0, 1, NULL) {} |
+ |
} // namespace base |