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/logging.h" | 9 #include "base/logging.h" |
10 #include "base/json/json_string_value_serializer.h" | 10 #include "base/json/json_string_value_serializer.h" |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 void HistogramBase::AddBoolean(bool value) { | 93 void HistogramBase::AddBoolean(bool value) { |
94 Add(value ? 1 : 0); | 94 Add(value ? 1 : 0); |
95 } | 95 } |
96 | 96 |
97 bool HistogramBase::SerializeInfo(Pickle* pickle) const { | 97 bool HistogramBase::SerializeInfo(Pickle* pickle) const { |
98 if (!pickle->WriteInt(GetHistogramType())) | 98 if (!pickle->WriteInt(GetHistogramType())) |
99 return false; | 99 return false; |
100 return SerializeInfoImpl(pickle); | 100 return SerializeInfoImpl(pickle); |
101 } | 101 } |
102 | 102 |
| 103 int HistogramBase::FindCorruption(const HistogramSamples& samples) const { |
| 104 // Not supported by default. |
| 105 return NO_INCONSISTENCIES; |
| 106 } |
| 107 |
103 void HistogramBase::WriteJSON(std::string* output) const { | 108 void HistogramBase::WriteJSON(std::string* output) const { |
104 Count count; | 109 Count count; |
105 scoped_ptr<ListValue> buckets(new ListValue()); | 110 scoped_ptr<ListValue> buckets(new ListValue()); |
106 GetCountAndBucketData(&count, buckets.get()); | 111 GetCountAndBucketData(&count, buckets.get()); |
107 scoped_ptr<DictionaryValue> parameters(new DictionaryValue()); | 112 scoped_ptr<DictionaryValue> parameters(new DictionaryValue()); |
108 GetParameters(parameters.get()); | 113 GetParameters(parameters.get()); |
109 | 114 |
110 JSONStringValueSerializer serializer(output); | 115 JSONStringValueSerializer serializer(output); |
111 DictionaryValue root; | 116 DictionaryValue root; |
112 root.SetString("name", histogram_name()); | 117 root.SetString("name", histogram_name()); |
113 root.SetInteger("count", count); | 118 root.SetInteger("count", count); |
114 root.SetInteger("flags", flags()); | 119 root.SetInteger("flags", flags()); |
115 root.Set("params", parameters.release()); | 120 root.Set("params", parameters.release()); |
116 root.Set("buckets", buckets.release()); | 121 root.Set("buckets", buckets.release()); |
117 serializer.Serialize(root); | 122 serializer.Serialize(root); |
118 } | 123 } |
119 | 124 |
120 } // namespace base | 125 } // namespace base |
OLD | NEW |