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

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
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"
+#include "base/synchronization/lock.h"
+
+using std::string;
Ilya Sherman 2012/08/04 01:18:35 nit: This sort of using statement is not permitted
kaiwang 2012/08/08 03:59:33 are you sure about this? This is allowed in google
Ilya Sherman 2012/08/08 05:00:29 Sorry, you're right, this sort of using statement
+
+namespace base {
+
+// static
+HistogramBase* SparseHistogram::FactoryGet(const string& name,
+ Flags flags) {
Ilya Sherman 2012/08/04 01:18:35 nit: Should this be |int32 flags|, as it is everyw
kaiwang 2012/08/08 03:59:33 Done. Good catch
+ HistogramBase* histogram = new SparseHistogram(name);
Ilya Sherman 2012/08/04 01:18:35 nit: I believe this is an intentional leak, right?
+ histogram->SetFlags(flags);
+ return histogram;
+}
Ilya Sherman 2012/08/04 01:18:35 Is this method eventually going to look up the his
kaiwang 2012/08/08 03:59:33 You are right. FactoryGet will eventually register
+
+SparseHistogram::~SparseHistogram() {}
+
+void SparseHistogram::Add(Sample value) {
+ base::AutoLock auto_lock(*lock_);
+ sample_[value]++;
+}
+
+void SparseHistogram::SnapshotSample(
+ SparseHistogram::SampleCounts* sample) const {
+ base::AutoLock auto_lock(*lock_);
+ *sample = sample_;
+}
+
+void SparseHistogram::WriteHTMLGraph(string* output) const {
Ilya Sherman 2012/08/04 01:18:35 nit: Please add a TODO, linked to a crbug, to impl
kaiwang 2012/08/08 03:59:33 Added todo. Most code is in histogram.cc. Seems no
+}
+
+void SparseHistogram::WriteAscii(string* output) const {
+}
+
+SparseHistogram::SparseHistogram(const string& name)
+ : HistogramBase(name),
+ lock_(new base::Lock()) {}
+
+} // namespace base
Property changes on: base/metrics/sparse_histogram.cc
___________________________________________________________________
Added: svn:eol-style
+ LF

Powered by Google App Engine
This is Rietveld 408576698