diff options
author | kaiwang@chromium.org <kaiwang@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-09 05:14:15 +0000 |
---|---|---|
committer | kaiwang@chromium.org <kaiwang@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-09 05:14:15 +0000 |
commit | 7c7a4275f74bda63046b613686471fc2b8f14ac8 (patch) | |
tree | d22de02d2ca409683ceb313a9aac41fd9c564a33 /base/metrics/sparse_histogram.cc | |
parent | 5bdebd9ecaaaada3e1632efa27ed986be2cd61a9 (diff) | |
download | chromium_src-7c7a4275f74bda63046b613686471fc2b8f14ac8.zip chromium_src-7c7a4275f74bda63046b613686471fc2b8f14ac8.tar.gz chromium_src-7c7a4275f74bda63046b613686471fc2b8f14ac8.tar.bz2 |
Skeleton code of SparseHistogram
Review URL: https://chromiumcodereview.appspot.com/10830156
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@150736 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/metrics/sparse_histogram.cc')
-rw-r--r-- | base/metrics/sparse_histogram.cc | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/base/metrics/sparse_histogram.cc b/base/metrics/sparse_histogram.cc new file mode 100644 index 0000000..05a68b5 --- /dev/null +++ b/base/metrics/sparse_histogram.cc @@ -0,0 +1,45 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "base/metrics/sparse_histogram.h" + +#include "base/metrics/statistics_recorder.h" + +using std::string; + +namespace base { + +// static +HistogramBase* SparseHistogram::FactoryGet(const string& name, + int32 flags) { + // TODO(kaiwang): Register and get SparseHistogram with StatisticsRecorder. + HistogramBase* histogram = new SparseHistogram(name); + histogram->SetFlags(flags); + return histogram; +} + +SparseHistogram::~SparseHistogram() {} + +void SparseHistogram::Add(Sample value) { + base::AutoLock auto_lock(lock_); + samples_[value]++; +} + +void SparseHistogram::SnapshotSample(std::map<Sample, Count>* samples) const { + base::AutoLock auto_lock(lock_); + *samples = samples_; +} + +void SparseHistogram::WriteHTMLGraph(string* output) const { + // TODO(kaiwang): Implement. +} + +void SparseHistogram::WriteAscii(string* output) const { + // TODO(kaiwang): Implement. +} + +SparseHistogram::SparseHistogram(const string& name) + : HistogramBase(name) {} + +} // namespace base |