OLD | NEW |
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" |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 int64 sum; | 102 int64 sum; |
103 scoped_ptr<ListValue> buckets(new ListValue()); | 103 scoped_ptr<ListValue> buckets(new ListValue()); |
104 GetCountAndBucketData(&count, &sum, buckets.get()); | 104 GetCountAndBucketData(&count, &sum, buckets.get()); |
105 scoped_ptr<DictionaryValue> parameters(new DictionaryValue()); | 105 scoped_ptr<DictionaryValue> parameters(new DictionaryValue()); |
106 GetParameters(parameters.get()); | 106 GetParameters(parameters.get()); |
107 | 107 |
108 JSONStringValueSerializer serializer(output); | 108 JSONStringValueSerializer serializer(output); |
109 DictionaryValue root; | 109 DictionaryValue root; |
110 root.SetString("name", histogram_name()); | 110 root.SetString("name", histogram_name()); |
111 root.SetInteger("count", count); | 111 root.SetInteger("count", count); |
112 root.SetDouble("sum", sum); | 112 root.SetDouble("sum", static_cast<double>(sum)); |
113 root.SetInteger("flags", flags()); | 113 root.SetInteger("flags", flags()); |
114 root.Set("params", parameters.release()); | 114 root.Set("params", parameters.release()); |
115 root.Set("buckets", buckets.release()); | 115 root.Set("buckets", buckets.release()); |
116 root.SetInteger("pid", GetCurrentProcId()); | 116 root.SetInteger("pid", GetCurrentProcId()); |
117 serializer.Serialize(root); | 117 serializer.Serialize(root); |
118 } | 118 } |
119 | 119 |
120 void HistogramBase::WriteAsciiBucketGraph(double current_size, | 120 void HistogramBase::WriteAsciiBucketGraph(double current_size, |
121 double max_size, | 121 double max_size, |
122 std::string* output) const { | 122 std::string* output) const { |
(...skipping 19 matching lines...) Expand all Loading... |
142 return result; | 142 return result; |
143 } | 143 } |
144 | 144 |
145 void HistogramBase::WriteAsciiBucketValue(Count current, | 145 void HistogramBase::WriteAsciiBucketValue(Count current, |
146 double scaled_sum, | 146 double scaled_sum, |
147 std::string* output) const { | 147 std::string* output) const { |
148 StringAppendF(output, " (%d = %3.1f%%)", current, current/scaled_sum); | 148 StringAppendF(output, " (%d = %3.1f%%)", current, current/scaled_sum); |
149 } | 149 } |
150 | 150 |
151 } // namespace base | 151 } // namespace base |
OLD | NEW |