Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(222)

Side by Side Diff: base/metrics/statistics_recorder.cc

Issue 12207058: Connect SparseHistogram with the rest of stats system (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 27 matching lines...) Expand all
38 38
39 // static 39 // static
40 bool StatisticsRecorder::IsActive() { 40 bool StatisticsRecorder::IsActive() {
41 if (lock_ == NULL) 41 if (lock_ == NULL)
42 return false; 42 return false;
43 base::AutoLock auto_lock(*lock_); 43 base::AutoLock auto_lock(*lock_);
44 return NULL != histograms_; 44 return NULL != histograms_;
45 } 45 }
46 46
47 // static 47 // static
48 Histogram* StatisticsRecorder::RegisterOrDeleteDuplicate(Histogram* histogram) { 48 HistogramBase* StatisticsRecorder::RegisterOrDeleteDuplicate(
49 HistogramBase* histogram) {
49 // As per crbug.com/79322 the histograms are intentionally leaked, so we need 50 // As per crbug.com/79322 the histograms are intentionally leaked, so we need
50 // to annotate them. Because ANNOTATE_LEAKING_OBJECT_PTR may be used only once 51 // to annotate them. Because ANNOTATE_LEAKING_OBJECT_PTR may be used only once
51 // for an object, the duplicates should not be annotated. 52 // for an object, the duplicates should not be annotated.
52 // Callers are responsible for not calling RegisterOrDeleteDuplicate(ptr) 53 // Callers are responsible for not calling RegisterOrDeleteDuplicate(ptr)
53 // twice if (lock_ == NULL) || (!histograms_). 54 // twice if (lock_ == NULL) || (!histograms_).
54 if (lock_ == NULL) { 55 if (lock_ == NULL) {
55 ANNOTATE_LEAKING_OBJECT_PTR(histogram); // see crbug.com/79322 56 ANNOTATE_LEAKING_OBJECT_PTR(histogram); // see crbug.com/79322
56 return histogram; 57 return histogram;
57 } 58 }
58 59
59 Histogram* histogram_to_delete = NULL; 60 HistogramBase* histogram_to_delete = NULL;
60 Histogram* histogram_to_return = NULL; 61 HistogramBase* histogram_to_return = NULL;
61 { 62 {
62 base::AutoLock auto_lock(*lock_); 63 base::AutoLock auto_lock(*lock_);
63 if (histograms_ == NULL) { 64 if (histograms_ == NULL) {
64 histogram_to_return = histogram; 65 histogram_to_return = histogram;
65 } else { 66 } else {
66 const string& name = histogram->histogram_name(); 67 const string& name = histogram->histogram_name();
67 HistogramMap::iterator it = histograms_->find(name); 68 HistogramMap::iterator it = histograms_->find(name);
68 if (histograms_->end() == it) { 69 if (histograms_->end() == it) {
69 (*histograms_)[name] = histogram; 70 (*histograms_)[name] = histogram;
70 ANNOTATE_LEAKING_OBJECT_PTR(histogram); // see crbug.com/79322 71 ANNOTATE_LEAKING_OBJECT_PTR(histogram); // see crbug.com/79322
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 list<const BucketRanges*>::iterator ranges_list_it; 248 list<const BucketRanges*>::iterator ranges_list_it;
248 for (ranges_list_it = ranges_list->begin(); 249 for (ranges_list_it = ranges_list->begin();
249 ranges_list_it != ranges_list->end(); 250 ranges_list_it != ranges_list->end();
250 ++ranges_list_it) { 251 ++ranges_list_it) {
251 output->push_back(*ranges_list_it); 252 output->push_back(*ranges_list_it);
252 } 253 }
253 } 254 }
254 } 255 }
255 256
256 // static 257 // static
257 Histogram* StatisticsRecorder::FindHistogram(const std::string& name) { 258 HistogramBase* StatisticsRecorder::FindHistogram(const std::string& name) {
258 if (lock_ == NULL) 259 if (lock_ == NULL)
259 return NULL; 260 return NULL;
260 base::AutoLock auto_lock(*lock_); 261 base::AutoLock auto_lock(*lock_);
261 if (histograms_ == NULL) 262 if (histograms_ == NULL)
262 return NULL; 263 return NULL;
263 264
264 HistogramMap::iterator it = histograms_->find(name); 265 HistogramMap::iterator it = histograms_->find(name);
265 if (histograms_->end() == it) 266 if (histograms_->end() == it)
266 return NULL; 267 return NULL;
267 return it->second; 268 return it->second;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 // static 331 // static
331 StatisticsRecorder::HistogramMap* StatisticsRecorder::histograms_ = NULL; 332 StatisticsRecorder::HistogramMap* StatisticsRecorder::histograms_ = NULL;
332 // static 333 // static
333 StatisticsRecorder::RangesMap* StatisticsRecorder::ranges_ = NULL; 334 StatisticsRecorder::RangesMap* StatisticsRecorder::ranges_ = NULL;
334 // static 335 // static
335 base::Lock* StatisticsRecorder::lock_ = NULL; 336 base::Lock* StatisticsRecorder::lock_ = NULL;
336 // static 337 // static
337 bool StatisticsRecorder::dump_on_exit_ = false; 338 bool StatisticsRecorder::dump_on_exit_ = false;
338 339
339 } // namespace base 340 } // namespace base
OLDNEW
« no previous file with comments | « base/metrics/statistics_recorder.h ('k') | chrome/browser/chrome_browser_application_mac_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698