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

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

Issue 167343002: Make code generated for histogram macros more compact. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 6 years, 10 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 unified diff | Download patch | Annotate | Revision Log
« base/metrics/histogram.h ('K') | « base/metrics/histogram_base.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/json/json_string_value_serializer.h" 9 #include "base/json/json_string_value_serializer.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/metrics/histogram.h" 12 #include "base/metrics/histogram.h"
13 #include "base/metrics/histogram_samples.h" 13 #include "base/metrics/histogram_samples.h"
14 #include "base/metrics/sparse_histogram.h" 14 #include "base/metrics/sparse_histogram.h"
15 #include "base/pickle.h" 15 #include "base/pickle.h"
16 #include "base/process/process_handle.h" 16 #include "base/process/process_handle.h"
17 #include "base/strings/stringprintf.h" 17 #include "base/strings/stringprintf.h"
18 #include "base/values.h" 18 #include "base/values.h"
19 19
20 namespace base { 20 namespace base {
21 21
22 std::string HistogramTypeToString(HistogramType type) { 22 std::string HistogramTypeToString(HistogramType type) {
23 switch(type) { 23 switch (type) {
24 case HISTOGRAM: 24 case HISTOGRAM:
25 return "HISTOGRAM"; 25 return "HISTOGRAM";
26 case LINEAR_HISTOGRAM: 26 case LINEAR_HISTOGRAM:
27 return "LINEAR_HISTOGRAM"; 27 return "LINEAR_HISTOGRAM";
28 case BOOLEAN_HISTOGRAM: 28 case BOOLEAN_HISTOGRAM:
29 return "BOOLEAN_HISTOGRAM"; 29 return "BOOLEAN_HISTOGRAM";
30 case CUSTOM_HISTOGRAM: 30 case CUSTOM_HISTOGRAM:
31 return "CUSTOM_HISTOGRAM"; 31 return "CUSTOM_HISTOGRAM";
32 case SPARSE_HISTOGRAM: 32 case SPARSE_HISTOGRAM:
33 return "SPARSE_HISTOGRAM"; 33 return "SPARSE_HISTOGRAM";
(...skipping 25 matching lines...) Expand all
59 } 59 }
60 60
61 const HistogramBase::Sample HistogramBase::kSampleType_MAX = INT_MAX; 61 const HistogramBase::Sample HistogramBase::kSampleType_MAX = INT_MAX;
62 62
63 HistogramBase::HistogramBase(const std::string& name) 63 HistogramBase::HistogramBase(const std::string& name)
64 : histogram_name_(name), 64 : histogram_name_(name),
65 flags_(kNoFlags) {} 65 flags_(kNoFlags) {}
66 66
67 HistogramBase::~HistogramBase() {} 67 HistogramBase::~HistogramBase() {}
68 68
69 void HistogramBase::CheckName(const StringPiece& name) const {
70 DCHECK_EQ(histogram_name(), name);
71 }
72
69 void HistogramBase::SetFlags(int32 flags) { 73 void HistogramBase::SetFlags(int32 flags) {
70 flags_ |= flags; 74 flags_ |= flags;
71 } 75 }
72 76
73 void HistogramBase::ClearFlags(int32 flags) { 77 void HistogramBase::ClearFlags(int32 flags) {
74 flags_ &= ~flags; 78 flags_ &= ~flags;
75 } 79 }
76 80
77 void HistogramBase::AddTime(const TimeDelta& time) { 81 void HistogramBase::AddTime(const TimeDelta& time) {
78 Add(static_cast<Sample>(time.InMilliseconds())); 82 Add(static_cast<Sample>(time.InMilliseconds()));
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 return result; 142 return result;
139 } 143 }
140 144
141 void HistogramBase::WriteAsciiBucketValue(Count current, 145 void HistogramBase::WriteAsciiBucketValue(Count current,
142 double scaled_sum, 146 double scaled_sum,
143 std::string* output) const { 147 std::string* output) const {
144 StringAppendF(output, " (%d = %3.1f%%)", current, current/scaled_sum); 148 StringAppendF(output, " (%d = %3.1f%%)", current, current/scaled_sum);
145 } 149 }
146 150
147 } // namespace base 151 } // namespace base
OLDNEW
« base/metrics/histogram.h ('K') | « base/metrics/histogram_base.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698