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

Side by Side Diff: base/metrics/sparse_histogram.h

Issue 1538743002: Switch to standard integer types in base/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: DEPS roll too Created 4 years, 12 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
« no previous file with comments | « base/metrics/sample_vector_unittest.cc ('k') | base/metrics/sparse_histogram.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) 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 #ifndef BASE_METRICS_SPARSE_HISTOGRAM_H_ 5 #ifndef BASE_METRICS_SPARSE_HISTOGRAM_H_
6 #define BASE_METRICS_SPARSE_HISTOGRAM_H_ 6 #define BASE_METRICS_SPARSE_HISTOGRAM_H_
7 7
8 #include <stddef.h>
9 #include <stdint.h>
10
8 #include <map> 11 #include <map>
9 #include <string> 12 #include <string>
10 13
11 #include "base/base_export.h" 14 #include "base/base_export.h"
12 #include "base/basictypes.h"
13 #include "base/compiler_specific.h" 15 #include "base/compiler_specific.h"
14 #include "base/logging.h" 16 #include "base/logging.h"
17 #include "base/macros.h"
15 #include "base/memory/scoped_ptr.h" 18 #include "base/memory/scoped_ptr.h"
16 #include "base/metrics/histogram_base.h" 19 #include "base/metrics/histogram_base.h"
17 #include "base/metrics/sample_map.h" 20 #include "base/metrics/sample_map.h"
18 #include "base/synchronization/lock.h" 21 #include "base/synchronization/lock.h"
19 22
20 namespace base { 23 namespace base {
21 24
22 #define UMA_HISTOGRAM_SPARSE_SLOWLY(name, sample) \ 25 #define UMA_HISTOGRAM_SPARSE_SLOWLY(name, sample) \
23 do { \ 26 do { \
24 base::HistogramBase* histogram = base::SparseHistogram::FactoryGet( \ 27 base::HistogramBase* histogram = base::SparseHistogram::FactoryGet( \
25 name, base::HistogramBase::kUmaTargetedHistogramFlag); \ 28 name, base::HistogramBase::kUmaTargetedHistogramFlag); \
26 histogram->Add(sample); \ 29 histogram->Add(sample); \
27 } while (0) 30 } while (0)
28 31
29 class HistogramSamples; 32 class HistogramSamples;
30 33
31 class BASE_EXPORT SparseHistogram : public HistogramBase { 34 class BASE_EXPORT SparseHistogram : public HistogramBase {
32 public: 35 public:
33 // If there's one with same name, return the existing one. If not, create a 36 // If there's one with same name, return the existing one. If not, create a
34 // new one. 37 // new one.
35 static HistogramBase* FactoryGet(const std::string& name, int32 flags); 38 static HistogramBase* FactoryGet(const std::string& name, int32_t flags);
36 39
37 ~SparseHistogram() override; 40 ~SparseHistogram() override;
38 41
39 // HistogramBase implementation: 42 // HistogramBase implementation:
40 uint64_t name_hash() const override; 43 uint64_t name_hash() const override;
41 HistogramType GetHistogramType() const override; 44 HistogramType GetHistogramType() const override;
42 bool HasConstructionArguments(Sample expected_minimum, 45 bool HasConstructionArguments(Sample expected_minimum,
43 Sample expected_maximum, 46 Sample expected_maximum,
44 size_t expected_bucket_count) const override; 47 size_t expected_bucket_count) const override;
45 void Add(Sample value) override; 48 void Add(Sample value) override;
(...skipping 11 matching lines...) Expand all
57 private: 60 private:
58 // Clients should always use FactoryGet to create SparseHistogram. 61 // Clients should always use FactoryGet to create SparseHistogram.
59 explicit SparseHistogram(const std::string& name); 62 explicit SparseHistogram(const std::string& name);
60 63
61 friend BASE_EXPORT HistogramBase* DeserializeHistogramInfo( 64 friend BASE_EXPORT HistogramBase* DeserializeHistogramInfo(
62 base::PickleIterator* iter); 65 base::PickleIterator* iter);
63 static HistogramBase* DeserializeInfoImpl(base::PickleIterator* iter); 66 static HistogramBase* DeserializeInfoImpl(base::PickleIterator* iter);
64 67
65 void GetParameters(DictionaryValue* params) const override; 68 void GetParameters(DictionaryValue* params) const override;
66 void GetCountAndBucketData(Count* count, 69 void GetCountAndBucketData(Count* count,
67 int64* sum, 70 int64_t* sum,
68 ListValue* buckets) const override; 71 ListValue* buckets) const override;
69 72
70 // Helpers for emitting Ascii graphic. Each method appends data to output. 73 // Helpers for emitting Ascii graphic. Each method appends data to output.
71 void WriteAsciiImpl(bool graph_it, 74 void WriteAsciiImpl(bool graph_it,
72 const std::string& newline, 75 const std::string& newline,
73 std::string* output) const; 76 std::string* output) const;
74 77
75 // Write a common header message describing this histogram. 78 // Write a common header message describing this histogram.
76 void WriteAsciiHeader(const Count total_count, 79 void WriteAsciiHeader(const Count total_count,
77 std::string* output) const; 80 std::string* output) const;
78 81
79 // For constuctor calling. 82 // For constuctor calling.
80 friend class SparseHistogramTest; 83 friend class SparseHistogramTest;
81 84
82 // Protects access to |samples_|. 85 // Protects access to |samples_|.
83 mutable base::Lock lock_; 86 mutable base::Lock lock_;
84 87
85 SampleMap samples_; 88 SampleMap samples_;
86 89
87 DISALLOW_COPY_AND_ASSIGN(SparseHistogram); 90 DISALLOW_COPY_AND_ASSIGN(SparseHistogram);
88 }; 91 };
89 92
90 } // namespace base 93 } // namespace base
91 94
92 #endif // BASE_METRICS_SPARSE_HISTOGRAM_H_ 95 #endif // BASE_METRICS_SPARSE_HISTOGRAM_H_
OLDNEW
« no previous file with comments | « base/metrics/sample_vector_unittest.cc ('k') | base/metrics/sparse_histogram.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698