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

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

Issue 1647803004: Move base to DEPS (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 4 years, 10 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef BASE_METRICS_SPARSE_HISTOGRAM_H_
6 #define BASE_METRICS_SPARSE_HISTOGRAM_H_
7
8 #include <map>
9 #include <string>
10
11 #include "base/base_export.h"
12 #include "base/basictypes.h"
13 #include "base/compiler_specific.h"
14 #include "base/logging.h"
15 #include "base/memory/scoped_ptr.h"
16 #include "base/metrics/histogram_base.h"
17 #include "base/metrics/sample_map.h"
18 #include "base/synchronization/lock.h"
19
20 namespace base {
21
22 #define UMA_HISTOGRAM_SPARSE_SLOWLY(name, sample) \
23 do { \
24 base::HistogramBase* histogram = base::SparseHistogram::FactoryGet( \
25 name, base::HistogramBase::kUmaTargetedHistogramFlag); \
26 histogram->Add(sample); \
27 } while (0)
28
29 class HistogramSamples;
30
31 class BASE_EXPORT_PRIVATE SparseHistogram : public HistogramBase {
32 public:
33 // If there's one with same name, return the existing one. If not, create a
34 // new one.
35 static HistogramBase* FactoryGet(const std::string& name, int32 flags);
36
37 ~SparseHistogram() override;
38
39 // HistogramBase implementation:
40 HistogramType GetHistogramType() const override;
41 bool HasConstructionArguments(Sample expected_minimum,
42 Sample expected_maximum,
43 size_t expected_bucket_count) const override;
44 void Add(Sample value) override;
45 void AddSamples(const HistogramSamples& samples) override;
46 bool AddSamplesFromPickle(base::PickleIterator* iter) override;
47 scoped_ptr<HistogramSamples> SnapshotSamples() const override;
48 void WriteHTMLGraph(std::string* output) const override;
49 void WriteAscii(std::string* output) const override;
50
51 protected:
52 // HistogramBase implementation:
53 bool SerializeInfoImpl(base::Pickle* pickle) const override;
54
55 private:
56 // Clients should always use FactoryGet to create SparseHistogram.
57 explicit SparseHistogram(const std::string& name);
58
59 friend BASE_EXPORT_PRIVATE HistogramBase* DeserializeHistogramInfo(
60 base::PickleIterator* iter);
61 static HistogramBase* DeserializeInfoImpl(base::PickleIterator* iter);
62
63 void GetParameters(DictionaryValue* params) const override;
64 void GetCountAndBucketData(Count* count,
65 int64* sum,
66 ListValue* buckets) const override;
67
68 // Helpers for emitting Ascii graphic. Each method appends data to output.
69 void WriteAsciiImpl(bool graph_it,
70 const std::string& newline,
71 std::string* output) const;
72
73 // Write a common header message describing this histogram.
74 void WriteAsciiHeader(const Count total_count,
75 std::string* output) const;
76
77 // For constuctor calling.
78 friend class SparseHistogramTest;
79
80 // Protects access to |samples_|.
81 mutable base::Lock lock_;
82
83 SampleMap samples_;
84
85 DISALLOW_COPY_AND_ASSIGN(SparseHistogram);
86 };
87
88 } // namespace base
89
90 #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