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

Unified Diff: base/metrics/sparse_histogram.h

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.h
===================================================================
--- base/metrics/sparse_histogram.h (revision 0)
+++ base/metrics/sparse_histogram.h (revision 0)
@@ -0,0 +1,51 @@
+// 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.
+
+#ifndef BASE_METRICS_SPARSE_HISTOGRAM_H_
+#define BASE_METRICS_SPARSE_HISTOGRAM_H_
+
+#include <map>
+#include <string>
+
+#include "base/base_export.h"
+#include "base/compiler_specific.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/metrics/histogram_base.h"
+
+namespace base {
+
+class Lock;
+
+class BASE_EXPORT_PRIVATE SparseHistogram : public HistogramBase {
Ilya Sherman 2012/08/04 01:18:35 Can you help satisfy my curiosity and explain how
kaiwang 2012/08/08 03:59:33 Definitions are exactly the same... But I have to
+ public:
+ typedef std::map<Sample, Count> SampleCounts;
Ilya Sherman 2012/08/04 01:18:35 nit: I strongly prefer not to typedef this; you're
kaiwang 2012/08/08 03:59:33 ok I don't like this kind of typedefs either. Just
+
+ // If there's one with same name, return the existing one. If not, create a
+ // new one.
+ static HistogramBase* FactoryGet(const std::string& name, Flags flags);
+
+ virtual ~SparseHistogram();
+
+ virtual void Add(Sample value) OVERRIDE;
+
+ virtual void SnapshotSample(SampleCounts* sample) const;
Ilya Sherman 2012/08/04 01:18:35 nit: Who will be calling this method? It seems od
Ilya Sherman 2012/08/04 01:18:35 nit: This method's name is confusing, since elsewh
kaiwang 2012/08/08 03:59:33 This is a temporary method.. Keep it for testing b
Ilya Sherman 2012/08/08 05:00:29 Ok. In that case, please add a comment indicating
+ virtual void WriteHTMLGraph(std::string* output) const OVERRIDE;
+ virtual void WriteAscii(std::string* output) const OVERRIDE;
+
+ protected:
+ // Clients should always use FactoryGet to create SparseHistogram.
+ SparseHistogram(const std::string& name);
+
+ private:
+ friend class SparseHistogramTest; // For constuctor calling.
+
+ SampleCounts sample_;
+
+ // Protects access to above map.
+ scoped_ptr<base::Lock> lock_;
Ilya Sherman 2012/08/04 01:18:35 nit: Why is this heap-allocated? It seems more na
kaiwang 2012/08/08 03:59:33 Tried to limit header file dependencies. But I thi
+};
Ilya Sherman 2012/08/04 01:18:35 nit: DISALLOW_COPY_AND_ASSIGN?
kaiwang 2012/08/08 03:59:33 Done.
+
+} // namespace base
+
+#endif // BASE_METRICS_SPARSE_HISTOGRAM_H_
Property changes on: base/metrics/sparse_histogram.h
___________________________________________________________________
Added: svn:eol-style
+ LF

Powered by Google App Engine
This is Rietveld 408576698