Index: base/metrics/statistics_recorder.cc |
diff --git a/base/metrics/statistics_recorder.cc b/base/metrics/statistics_recorder.cc |
index b19a897a96c1ab6e2d7737bd2648100c9bd10281..404a6554a0a237d3289a0bd9e7c5f60d82e4f69e 100644 |
--- a/base/metrics/statistics_recorder.cc |
+++ b/base/metrics/statistics_recorder.cc |
@@ -285,18 +285,22 @@ void StatisticsRecorder::GetBucketRanges( |
HistogramBase* StatisticsRecorder::FindHistogram(base::StringPiece name) { |
if (lock_ == NULL) |
return NULL; |
- base::AutoLock auto_lock(*lock_); |
- if (histograms_ == NULL) |
- return NULL; |
// Import histograms from known persistent storage. Histograms could have |
// been added by other processes and they must be fetched and recognized |
// locally. If the persistent memory segment is not shared between processes, |
// this call does nothing. |
+ // This must be called *before* the lock is acquired below because it will |
+ // call back into this object to register histograms. Those called methods |
+ // will acquire the lock at that time. |
GlobalHistogramAllocator* allocator = GlobalHistogramAllocator::Get(); |
if (allocator) |
allocator->ImportHistogramsToStatisticsRecorder(); |
+ base::AutoLock auto_lock(*lock_); |
+ if (histograms_ == NULL) |
+ return NULL; |
+ |
HistogramMap::iterator it = histograms_->find(name); |
if (histograms_->end() == it) |
return NULL; |