|
OLD | NEW |
---|---|
(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/metrics/histogram_base.h" | |
15 #include "base/synchronization/lock.h" | |
16 | |
17 namespace base { | |
18 | |
19 class Lock; | |
Ilya Sherman
2012/08/08 05:00:30
nit: No need for this anymore.
kaiwang
2012/08/08 22:17:08
Done.
| |
20 | |
21 class BASE_EXPORT_PRIVATE SparseHistogram : public HistogramBase { | |
22 public: | |
23 // If there's one with same name, return the existing one. If not, create a | |
24 // new one. | |
25 static HistogramBase* FactoryGet(const std::string& name, int32 flags); | |
26 | |
27 virtual ~SparseHistogram(); | |
28 | |
29 virtual void Add(Sample value) OVERRIDE; | |
30 | |
31 virtual void SnapshotSample(std::map<Sample, Count>* sample) const; | |
32 virtual void WriteHTMLGraph(std::string* output) const OVERRIDE; | |
33 virtual void WriteAscii(std::string* output) const OVERRIDE; | |
34 | |
35 protected: | |
36 // Clients should always use FactoryGet to create SparseHistogram. | |
37 SparseHistogram(const std::string& name); | |
38 | |
39 private: | |
40 friend class SparseHistogramTest; // For constuctor calling. | |
41 | |
42 std::map<Sample, Count> sample_; | |
Ilya Sherman
2012/08/08 05:00:30
nit: Perhaps "samples_"?
kaiwang
2012/08/08 22:17:08
Done.
| |
43 | |
44 // Protects access to above map. | |
45 mutable base::Lock lock_; | |
46 | |
47 DISALLOW_COPY_AND_ASSIGN(SparseHistogram); | |
48 }; | |
49 | |
50 } // namespace base | |
51 | |
52 #endif // BASE_METRICS_SPARSE_HISTOGRAM_H_ | |
OLD | NEW |