Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1023)

Unified Diff: base/metrics/sparse_histogram.cc

Issue 10830156: Skeleton code of SparseHistogram (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/metrics/sparse_histogram.h ('k') | base/metrics/sparse_histogram_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/metrics/sparse_histogram.cc
===================================================================
--- base/metrics/sparse_histogram.cc (revision 0)
+++ base/metrics/sparse_histogram.cc (revision 0)
@@ -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
Property changes on: base/metrics/sparse_histogram.cc
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « base/metrics/sparse_histogram.h ('k') | base/metrics/sparse_histogram_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698