Fix clang error caused by lack of OVERRIDE in r161270.
[chromium-blink-merge.git] / base / metrics / sparse_histogram.cc
blob236a19e1b54086635089876d45466a33415b2f5e
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.
5 #include "base/metrics/sparse_histogram.h"
7 #include "base/metrics/statistics_recorder.h"
8 #include "base/synchronization/lock.h"
10 using std::map;
11 using std::string;
13 namespace base {
15 typedef HistogramBase::Count Count;
16 typedef HistogramBase::Sample Sample;
18 // static
19 HistogramBase* SparseHistogram::FactoryGet(const string& name, int32 flags) {
20 // TODO(kaiwang): Register and get SparseHistogram with StatisticsRecorder.
21 HistogramBase* histogram = new SparseHistogram(name);
22 histogram->SetFlags(flags);
23 return histogram;
26 SparseHistogram::~SparseHistogram() {}
28 void SparseHistogram::Add(Sample value) {
29 base::AutoLock auto_lock(lock_);
30 sample_counts_[value]++;
31 redundant_count_ += 1;
34 scoped_ptr<SampleMap> SparseHistogram::SnapshotSamples() const {
35 scoped_ptr<SampleMap> snapshot(new SampleMap());
37 base::AutoLock auto_lock(lock_);
38 for(map<Sample, Count>::const_iterator it = sample_counts_.begin();
39 it != sample_counts_.end();
40 ++it) {
41 snapshot->Accumulate(it->first, it->second);
43 snapshot->ResetRedundantCount(redundant_count_);
44 return snapshot.Pass();
47 void SparseHistogram::WriteHTMLGraph(string* output) const {
48 // TODO(kaiwang): Implement.
51 void SparseHistogram::WriteAscii(string* output) const {
52 // TODO(kaiwang): Implement.
55 SparseHistogram::SparseHistogram(const string& name)
56 : HistogramBase(name),
57 redundant_count_(0) {}
59 void SparseHistogram::GetParameters(DictionaryValue* params) const {
60 // TODO(kaiwang): Implement. (See HistogramBase::WriteJSON.)
63 void SparseHistogram::GetCountAndBucketData(Count* count,
64 ListValue* buckets) const {
65 // TODO(kaiwang): Implement. (See HistogramBase::WriteJSON.)
68 } // namespace base