| 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 "base/debug/leak_annotations.h" | 7 #include "base/debug/leak_annotations.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 if (lock_ == NULL) { | 54 if (lock_ == NULL) { |
| 55 ANNOTATE_LEAKING_OBJECT_PTR(histogram); // see crbug.com/79322 | 55 ANNOTATE_LEAKING_OBJECT_PTR(histogram); // see crbug.com/79322 |
| 56 return histogram; | 56 return histogram; |
| 57 } | 57 } |
| 58 | 58 |
| 59 Histogram* histogram_to_delete = NULL; | 59 Histogram* histogram_to_delete = NULL; |
| 60 Histogram* histogram_to_return = NULL; | 60 Histogram* histogram_to_return = NULL; |
| 61 { | 61 { |
| 62 base::AutoLock auto_lock(*lock_); | 62 base::AutoLock auto_lock(*lock_); |
| 63 if (histograms_ == NULL) { | 63 if (histograms_ == NULL) { |
| 64 ANNOTATE_LEAKING_OBJECT_PTR(histogram); // see crbug.com/79322 | |
| 65 histogram_to_return = histogram; | 64 histogram_to_return = histogram; |
| 66 } else { | 65 } else { |
| 67 const string& name = histogram->histogram_name(); | 66 const string& name = histogram->histogram_name(); |
| 68 HistogramMap::iterator it = histograms_->find(name); | 67 HistogramMap::iterator it = histograms_->find(name); |
| 69 if (histograms_->end() == it) { | 68 if (histograms_->end() == it) { |
| 70 (*histograms_)[name] = histogram; | 69 (*histograms_)[name] = histogram; |
| 71 ANNOTATE_LEAKING_OBJECT_PTR(histogram); // see crbug.com/79322 | 70 ANNOTATE_LEAKING_OBJECT_PTR(histogram); // see crbug.com/79322 |
| 72 ++number_of_histograms_; | 71 ++number_of_histograms_; |
| 73 histogram_to_return = histogram; | 72 histogram_to_return = histogram; |
| 74 } else if (histogram == it->second) { | 73 } else if (histogram == it->second) { |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 // static | 330 // static |
| 332 StatisticsRecorder::HistogramMap* StatisticsRecorder::histograms_ = NULL; | 331 StatisticsRecorder::HistogramMap* StatisticsRecorder::histograms_ = NULL; |
| 333 // static | 332 // static |
| 334 StatisticsRecorder::RangesMap* StatisticsRecorder::ranges_ = NULL; | 333 StatisticsRecorder::RangesMap* StatisticsRecorder::ranges_ = NULL; |
| 335 // static | 334 // static |
| 336 base::Lock* StatisticsRecorder::lock_ = NULL; | 335 base::Lock* StatisticsRecorder::lock_ = NULL; |
| 337 // static | 336 // static |
| 338 bool StatisticsRecorder::dump_on_exit_ = false; | 337 bool StatisticsRecorder::dump_on_exit_ = false; |
| 339 | 338 |
| 340 } // namespace base | 339 } // namespace base |
| OLD | NEW |