Chromium Code Reviews
|
| 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/compiler_specific.h" | |
| 13 #include "base/memory/scoped_ptr.h" | |
| 14 #include "base/metrics/histogram_base.h" | |
| 15 | |
| 16 namespace base { | |
| 17 | |
| 18 class Lock; | |
| 19 | |
| 20 class BASE_EXPORT_PRIVATE SparseHistogram : public HistogramBase { | |
|
Ilya Sherman
2012/08/04 01:18:35
Can you help satisfy my curiosity and explain how
kaiwang
2012/08/08 03:59:33
Definitions are exactly the same... But I have to
| |
| 21 public: | |
| 22 typedef std::map<Sample, Count> SampleCounts; | |
|
Ilya Sherman
2012/08/04 01:18:35
nit: I strongly prefer not to typedef this; you're
kaiwang
2012/08/08 03:59:33
ok
I don't like this kind of typedefs either. Just
| |
| 23 | |
| 24 // If there's one with same name, return the existing one. If not, create a | |
| 25 // new one. | |
| 26 static HistogramBase* FactoryGet(const std::string& name, Flags flags); | |
| 27 | |
| 28 virtual ~SparseHistogram(); | |
| 29 | |
| 30 virtual void Add(Sample value) OVERRIDE; | |
| 31 | |
| 32 virtual void SnapshotSample(SampleCounts* sample) const; | |
|
Ilya Sherman
2012/08/04 01:18:35
nit: Who will be calling this method? It seems od
Ilya Sherman
2012/08/04 01:18:35
nit: This method's name is confusing, since elsewh
kaiwang
2012/08/08 03:59:33
This is a temporary method.. Keep it for testing b
Ilya Sherman
2012/08/08 05:00:29
Ok. In that case, please add a comment indicating
| |
| 33 virtual void WriteHTMLGraph(std::string* output) const OVERRIDE; | |
| 34 virtual void WriteAscii(std::string* output) const OVERRIDE; | |
| 35 | |
| 36 protected: | |
| 37 // Clients should always use FactoryGet to create SparseHistogram. | |
| 38 SparseHistogram(const std::string& name); | |
| 39 | |
| 40 private: | |
| 41 friend class SparseHistogramTest; // For constuctor calling. | |
| 42 | |
| 43 SampleCounts sample_; | |
| 44 | |
| 45 // Protects access to above map. | |
| 46 scoped_ptr<base::Lock> lock_; | |
|
Ilya Sherman
2012/08/04 01:18:35
nit: Why is this heap-allocated? It seems more na
kaiwang
2012/08/08 03:59:33
Tried to limit header file dependencies. But I thi
| |
| 47 }; | |
|
Ilya Sherman
2012/08/04 01:18:35
nit: DISALLOW_COPY_AND_ASSIGN?
kaiwang
2012/08/08 03:59:33
Done.
| |
| 48 | |
| 49 } // namespace base | |
| 50 | |
| 51 #endif // BASE_METRICS_SPARSE_HISTOGRAM_H_ | |
| OLD | NEW |