OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/metrics/statistics_recorder.h" | 5 #include "base/metrics/statistics_recorder.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/at_exit.h" | 9 #include "base/at_exit.h" |
10 #include "base/debug/leak_annotations.h" | 10 #include "base/debug/leak_annotations.h" |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
278 for (const auto& range_entry : *entry.second) { | 278 for (const auto& range_entry : *entry.second) { |
279 output->push_back(range_entry); | 279 output->push_back(range_entry); |
280 } | 280 } |
281 } | 281 } |
282 } | 282 } |
283 | 283 |
284 // static | 284 // static |
285 HistogramBase* StatisticsRecorder::FindHistogram(base::StringPiece name) { | 285 HistogramBase* StatisticsRecorder::FindHistogram(base::StringPiece name) { |
286 if (lock_ == NULL) | 286 if (lock_ == NULL) |
287 return NULL; | 287 return NULL; |
288 base::AutoLock auto_lock(*lock_); | |
289 if (histograms_ == NULL) | |
290 return NULL; | |
291 | 288 |
292 // Import histograms from known persistent storage. Histograms could have | 289 // Import histograms from known persistent storage. Histograms could have |
293 // been added by other processes and they must be fetched and recognized | 290 // been added by other processes and they must be fetched and recognized |
294 // locally. If the persistent memory segment is not shared between processes, | 291 // locally. If the persistent memory segment is not shared between processes, |
295 // this call does nothing. | 292 // this call does nothing. |
296 GlobalHistogramAllocator* allocator = GlobalHistogramAllocator::Get(); | 293 GlobalHistogramAllocator* allocator = GlobalHistogramAllocator::Get(); |
297 if (allocator) | 294 if (allocator) |
298 allocator->ImportHistogramsToStatisticsRecorder(); | 295 allocator->ImportHistogramsToStatisticsRecorder(); |
299 | 296 |
297 base::AutoLock auto_lock(*lock_); | |
Alexei Svitkine (slow)
2016/04/08 14:51:48
Add a comment for why this is done here and not at
bcwhite
2016/04/08 15:06:08
Done.
| |
298 if (histograms_ == NULL) | |
299 return NULL; | |
300 | |
300 HistogramMap::iterator it = histograms_->find(name); | 301 HistogramMap::iterator it = histograms_->find(name); |
301 if (histograms_->end() == it) | 302 if (histograms_->end() == it) |
302 return NULL; | 303 return NULL; |
303 return it->second; | 304 return it->second; |
304 } | 305 } |
305 | 306 |
306 // static | 307 // static |
307 StatisticsRecorder::HistogramIterator StatisticsRecorder::begin( | 308 StatisticsRecorder::HistogramIterator StatisticsRecorder::begin( |
308 bool include_persistent) { | 309 bool include_persistent) { |
309 return HistogramIterator(histograms_->begin(), include_persistent); | 310 return HistogramIterator(histograms_->begin(), include_persistent); |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
461 // static | 462 // static |
462 StatisticsRecorder::HistogramMap* StatisticsRecorder::histograms_ = NULL; | 463 StatisticsRecorder::HistogramMap* StatisticsRecorder::histograms_ = NULL; |
463 // static | 464 // static |
464 StatisticsRecorder::CallbackMap* StatisticsRecorder::callbacks_ = NULL; | 465 StatisticsRecorder::CallbackMap* StatisticsRecorder::callbacks_ = NULL; |
465 // static | 466 // static |
466 StatisticsRecorder::RangesMap* StatisticsRecorder::ranges_ = NULL; | 467 StatisticsRecorder::RangesMap* StatisticsRecorder::ranges_ = NULL; |
467 // static | 468 // static |
468 base::Lock* StatisticsRecorder::lock_ = NULL; | 469 base::Lock* StatisticsRecorder::lock_ = NULL; |
469 | 470 |
470 } // namespace base | 471 } // namespace base |
OLD | NEW |