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 #include "base/metrics/sparse_histogram.h" |
| 6 |
| 7 #include "base/metrics/statistics_recorder.h" |
| 8 |
| 9 using std::string; |
| 10 |
| 11 namespace base { |
| 12 |
| 13 // static |
| 14 HistogramBase* SparseHistogram::FactoryGet(const string& name, |
| 15 int32 flags) { |
| 16 // TODO(kaiwang): Register and get SparseHistogram with StatisticsRecorder. |
| 17 HistogramBase* histogram = new SparseHistogram(name); |
| 18 histogram->SetFlags(flags); |
| 19 return histogram; |
| 20 } |
| 21 |
| 22 SparseHistogram::~SparseHistogram() {} |
| 23 |
| 24 void SparseHistogram::Add(Sample value) { |
| 25 base::AutoLock auto_lock(lock_); |
| 26 samples_[value]++; |
| 27 } |
| 28 |
| 29 void SparseHistogram::SnapshotSample(std::map<Sample, Count>* samples) const { |
| 30 base::AutoLock auto_lock(lock_); |
| 31 *samples = samples_; |
| 32 } |
| 33 |
| 34 void SparseHistogram::WriteHTMLGraph(string* output) const { |
| 35 // TODO(kaiwang): Implement. |
| 36 } |
| 37 |
| 38 void SparseHistogram::WriteAscii(string* output) const { |
| 39 // TODO(kaiwang): Implement. |
| 40 } |
| 41 |
| 42 SparseHistogram::SparseHistogram(const string& name) |
| 43 : HistogramBase(name) {} |
| 44 |
| 45 } // namespace base |
OLD | NEW |