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

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

Issue 6869009: Introduce the ANNOTATE_LEAKING_OBJECT_PTR annotation that can be used to mark (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 8 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
« no previous file with comments | « base/debug/leak_annotations.h ('k') | net/disk_cache/stats.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 // Histogram is an object that aggregates statistics, and can summarize them in 5 // Histogram is an object that aggregates statistics, and can summarize them in
6 // various forms, including ASCII graphical, HTML, and numerically (as a 6 // various forms, including ASCII graphical, HTML, and numerically (as a
7 // vector of numbers corresponding to each of the aggregating buckets). 7 // vector of numbers corresponding to each of the aggregating buckets).
8 // See header file for details and examples. 8 // See header file for details and examples.
9 9
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
11 11
12 #include <math.h> 12 #include <math.h>
13 13
14 #include <algorithm> 14 #include <algorithm>
15 #include <string> 15 #include <string>
16 16
17 #include "base/debug/leak_annotations.h"
17 #include "base/logging.h" 18 #include "base/logging.h"
18 #include "base/pickle.h" 19 #include "base/pickle.h"
19 #include "base/stringprintf.h" 20 #include "base/stringprintf.h"
20 #include "base/synchronization/lock.h" 21 #include "base/synchronization/lock.h"
21 22
22 namespace base { 23 namespace base {
23 24
24 // Static table of checksums for all possible 8 bit bytes. 25 // Static table of checksums for all possible 8 bit bytes.
25 const uint32 Histogram::kCrcTable[256] = {0x0, 0x77073096L, 0xee0e612cL, 26 const uint32 Histogram::kCrcTable[256] = {0x0, 0x77073096L, 0xee0e612cL,
26 0x990951baL, 0x76dc419L, 0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0xedb8832L, 27 0x990951baL, 0x76dc419L, 0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0xedb8832L,
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 Histogram* tentative_histogram = 95 Histogram* tentative_histogram =
95 new Histogram(name, minimum, maximum, bucket_count); 96 new Histogram(name, minimum, maximum, bucket_count);
96 tentative_histogram->InitializeBucketRange(); 97 tentative_histogram->InitializeBucketRange();
97 tentative_histogram->SetFlags(flags); 98 tentative_histogram->SetFlags(flags);
98 histogram = 99 histogram =
99 StatisticsRecorder::RegisterOrDeleteDuplicate(tentative_histogram); 100 StatisticsRecorder::RegisterOrDeleteDuplicate(tentative_histogram);
100 } 101 }
101 102
102 DCHECK_EQ(HISTOGRAM, histogram->histogram_type()); 103 DCHECK_EQ(HISTOGRAM, histogram->histogram_type());
103 DCHECK(histogram->HasConstructorArguments(minimum, maximum, bucket_count)); 104 DCHECK(histogram->HasConstructorArguments(minimum, maximum, bucket_count));
105 ANNOTATE_LEAKING_OBJECT_PTR(histogram); // see crbug.com/79322
104 return histogram; 106 return histogram;
105 } 107 }
106 108
107 Histogram* Histogram::FactoryTimeGet(const std::string& name, 109 Histogram* Histogram::FactoryTimeGet(const std::string& name,
108 TimeDelta minimum, 110 TimeDelta minimum,
109 TimeDelta maximum, 111 TimeDelta maximum,
110 size_t bucket_count, 112 size_t bucket_count,
111 Flags flags) { 113 Flags flags) {
112 return FactoryGet(name, minimum.InMilliseconds(), maximum.InMilliseconds(), 114 return FactoryGet(name, minimum.InMilliseconds(), maximum.InMilliseconds(),
113 bucket_count, flags); 115 bucket_count, flags);
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after
787 LinearHistogram* tentative_histogram = 789 LinearHistogram* tentative_histogram =
788 new LinearHistogram(name, minimum, maximum, bucket_count); 790 new LinearHistogram(name, minimum, maximum, bucket_count);
789 tentative_histogram->InitializeBucketRange(); 791 tentative_histogram->InitializeBucketRange();
790 tentative_histogram->SetFlags(flags); 792 tentative_histogram->SetFlags(flags);
791 histogram = 793 histogram =
792 StatisticsRecorder::RegisterOrDeleteDuplicate(tentative_histogram); 794 StatisticsRecorder::RegisterOrDeleteDuplicate(tentative_histogram);
793 } 795 }
794 796
795 DCHECK_EQ(LINEAR_HISTOGRAM, histogram->histogram_type()); 797 DCHECK_EQ(LINEAR_HISTOGRAM, histogram->histogram_type());
796 DCHECK(histogram->HasConstructorArguments(minimum, maximum, bucket_count)); 798 DCHECK(histogram->HasConstructorArguments(minimum, maximum, bucket_count));
799 ANNOTATE_LEAKING_OBJECT_PTR(histogram); // see crbug.com/79322
797 return histogram; 800 return histogram;
798 } 801 }
799 802
800 Histogram* LinearHistogram::FactoryTimeGet(const std::string& name, 803 Histogram* LinearHistogram::FactoryTimeGet(const std::string& name,
801 TimeDelta minimum, 804 TimeDelta minimum,
802 TimeDelta maximum, 805 TimeDelta maximum,
803 size_t bucket_count, 806 size_t bucket_count,
804 Flags flags) { 807 Flags flags) {
805 return FactoryGet(name, minimum.InMilliseconds(), maximum.InMilliseconds(), 808 return FactoryGet(name, minimum.InMilliseconds(), maximum.InMilliseconds(),
806 bucket_count, flags); 809 bucket_count, flags);
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
877 if (!StatisticsRecorder::FindHistogram(name, &histogram)) { 880 if (!StatisticsRecorder::FindHistogram(name, &histogram)) {
878 // To avoid racy destruction at shutdown, the following will be leaked. 881 // To avoid racy destruction at shutdown, the following will be leaked.
879 BooleanHistogram* tentative_histogram = new BooleanHistogram(name); 882 BooleanHistogram* tentative_histogram = new BooleanHistogram(name);
880 tentative_histogram->InitializeBucketRange(); 883 tentative_histogram->InitializeBucketRange();
881 tentative_histogram->SetFlags(flags); 884 tentative_histogram->SetFlags(flags);
882 histogram = 885 histogram =
883 StatisticsRecorder::RegisterOrDeleteDuplicate(tentative_histogram); 886 StatisticsRecorder::RegisterOrDeleteDuplicate(tentative_histogram);
884 } 887 }
885 888
886 DCHECK_EQ(BOOLEAN_HISTOGRAM, histogram->histogram_type()); 889 DCHECK_EQ(BOOLEAN_HISTOGRAM, histogram->histogram_type());
890 ANNOTATE_LEAKING_OBJECT_PTR(histogram); // see crbug.com/79322
887 return histogram; 891 return histogram;
888 } 892 }
889 893
890 Histogram::ClassType BooleanHistogram::histogram_type() const { 894 Histogram::ClassType BooleanHistogram::histogram_type() const {
891 return BOOLEAN_HISTOGRAM; 895 return BOOLEAN_HISTOGRAM;
892 } 896 }
893 897
894 void BooleanHistogram::AddBoolean(bool value) { 898 void BooleanHistogram::AddBoolean(bool value) {
895 Add(value ? 1 : 0); 899 Add(value ? 1 : 0);
896 } 900 }
(...skipping 29 matching lines...) Expand all
926 CustomHistogram* tentative_histogram = new CustomHistogram(name, ranges); 930 CustomHistogram* tentative_histogram = new CustomHistogram(name, ranges);
927 tentative_histogram->InitializedCustomBucketRange(ranges); 931 tentative_histogram->InitializedCustomBucketRange(ranges);
928 tentative_histogram->SetFlags(flags); 932 tentative_histogram->SetFlags(flags);
929 histogram = 933 histogram =
930 StatisticsRecorder::RegisterOrDeleteDuplicate(tentative_histogram); 934 StatisticsRecorder::RegisterOrDeleteDuplicate(tentative_histogram);
931 } 935 }
932 936
933 DCHECK_EQ(histogram->histogram_type(), CUSTOM_HISTOGRAM); 937 DCHECK_EQ(histogram->histogram_type(), CUSTOM_HISTOGRAM);
934 DCHECK(histogram->HasConstructorArguments(ranges[1], ranges.back(), 938 DCHECK(histogram->HasConstructorArguments(ranges[1], ranges.back(),
935 ranges.size())); 939 ranges.size()));
940 ANNOTATE_LEAKING_OBJECT_PTR(histogram); // see crbug.com/79322
936 return histogram; 941 return histogram;
937 } 942 }
938 943
939 Histogram::ClassType CustomHistogram::histogram_type() const { 944 Histogram::ClassType CustomHistogram::histogram_type() const {
940 return CUSTOM_HISTOGRAM; 945 return CUSTOM_HISTOGRAM;
941 } 946 }
942 947
943 CustomHistogram::CustomHistogram(const std::string& name, 948 CustomHistogram::CustomHistogram(const std::string& name,
944 const std::vector<Sample>& custom_ranges) 949 const std::vector<Sample>& custom_ranges)
945 : Histogram(name, custom_ranges[1], custom_ranges.back(), 950 : Histogram(name, custom_ranges[1], custom_ranges.back(),
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
1122 } 1127 }
1123 1128
1124 // static 1129 // static
1125 StatisticsRecorder::HistogramMap* StatisticsRecorder::histograms_ = NULL; 1130 StatisticsRecorder::HistogramMap* StatisticsRecorder::histograms_ = NULL;
1126 // static 1131 // static
1127 base::Lock* StatisticsRecorder::lock_ = NULL; 1132 base::Lock* StatisticsRecorder::lock_ = NULL;
1128 // static 1133 // static
1129 bool StatisticsRecorder::dump_on_exit_ = false; 1134 bool StatisticsRecorder::dump_on_exit_ = false;
1130 1135
1131 } // namespace base 1136 } // namespace base
OLDNEW
« no previous file with comments | « base/debug/leak_annotations.h ('k') | net/disk_cache/stats.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698