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

Side by Side Diff: base/metrics/histogram_base.cc

Issue 11342060: Histogram type support in HistogramBase and remove SetRangeDescription function (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/metrics/histogram_base.h" 5 #include "base/metrics/histogram_base.h"
6 6
7 #include <climits> 7 #include <climits>
8 8
9 #include "base/logging.h"
9 #include "base/json/json_string_value_serializer.h" 10 #include "base/json/json_string_value_serializer.h"
10 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
11 #include "base/values.h" 12 #include "base/values.h"
12 13
13 namespace base { 14 namespace base {
14 15
16 std::string HistogramTypeName(HistogramType type) {
17 switch(type) {
18 case HISTOGRAM:
19 return "HISTOGRAM";
20 break;
21 case LINEAR_HISTOGRAM:
22 return "LINEAR_HISTOGRAM";
23 break;
24 case BOOLEAN_HISTOGRAM:
25 return "BOOLEAN_HISTOGRAM";
26 break;
27 case CUSTOM_HISTOGRAM:
28 return "CUSTOM_HISTOGRAM";
29 break;
30 case SPARSE_HISTOGRAM:
31 return "SPARSE_HISTOGRAM";
32 break;
33 default:
34 NOTREACHED();
35 break;
Ilya Sherman 2012/10/31 00:35:19 nit: No need for any break stmts in this switch, s
kaiwang 2012/10/31 01:12:56 Done.
36 }
37 return "UNKNOWN";
38 }
39
15 const HistogramBase::Sample HistogramBase::kSampleType_MAX = INT_MAX; 40 const HistogramBase::Sample HistogramBase::kSampleType_MAX = INT_MAX;
16 41
17 HistogramBase::HistogramBase(const std::string& name) 42 HistogramBase::HistogramBase(const std::string& name)
18 : histogram_name_(name), 43 : histogram_name_(name),
19 flags_(kNoFlags) {} 44 flags_(kNoFlags) {}
20 45
21 HistogramBase::~HistogramBase() {} 46 HistogramBase::~HistogramBase() {}
22 47
23 void HistogramBase::SetFlags(int32 flags) { 48 void HistogramBase::SetFlags(int32 flags) {
24 flags_ |= flags; 49 flags_ |= flags;
(...skipping 14 matching lines...) Expand all
39 DictionaryValue root; 64 DictionaryValue root;
40 root.SetString("name", histogram_name()); 65 root.SetString("name", histogram_name());
41 root.SetInteger("count", count); 66 root.SetInteger("count", count);
42 root.SetInteger("flags", flags()); 67 root.SetInteger("flags", flags());
43 root.Set("params", parameters.release()); 68 root.Set("params", parameters.release());
44 root.Set("buckets", buckets.release()); 69 root.Set("buckets", buckets.release());
45 serializer.Serialize(root); 70 serializer.Serialize(root);
46 } 71 }
47 72
48 } // namespace base 73 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698