| 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/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 HistogramTypeToString(HistogramType type) { |
| 17 switch(type) { |
| 18 case HISTOGRAM: |
| 19 return "HISTOGRAM"; |
| 20 case LINEAR_HISTOGRAM: |
| 21 return "LINEAR_HISTOGRAM"; |
| 22 case BOOLEAN_HISTOGRAM: |
| 23 return "BOOLEAN_HISTOGRAM"; |
| 24 case CUSTOM_HISTOGRAM: |
| 25 return "CUSTOM_HISTOGRAM"; |
| 26 case SPARSE_HISTOGRAM: |
| 27 return "SPARSE_HISTOGRAM"; |
| 28 default: |
| 29 NOTREACHED(); |
| 30 } |
| 31 return "UNKNOWN"; |
| 32 } |
| 33 |
| 15 const HistogramBase::Sample HistogramBase::kSampleType_MAX = INT_MAX; | 34 const HistogramBase::Sample HistogramBase::kSampleType_MAX = INT_MAX; |
| 16 | 35 |
| 17 HistogramBase::HistogramBase(const std::string& name) | 36 HistogramBase::HistogramBase(const std::string& name) |
| 18 : histogram_name_(name), | 37 : histogram_name_(name), |
| 19 flags_(kNoFlags) {} | 38 flags_(kNoFlags) {} |
| 20 | 39 |
| 21 HistogramBase::~HistogramBase() {} | 40 HistogramBase::~HistogramBase() {} |
| 22 | 41 |
| 23 void HistogramBase::SetFlags(int32 flags) { | 42 void HistogramBase::SetFlags(int32 flags) { |
| 24 flags_ |= flags; | 43 flags_ |= flags; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 39 DictionaryValue root; | 58 DictionaryValue root; |
| 40 root.SetString("name", histogram_name()); | 59 root.SetString("name", histogram_name()); |
| 41 root.SetInteger("count", count); | 60 root.SetInteger("count", count); |
| 42 root.SetInteger("flags", flags()); | 61 root.SetInteger("flags", flags()); |
| 43 root.Set("params", parameters.release()); | 62 root.Set("params", parameters.release()); |
| 44 root.Set("buckets", buckets.release()); | 63 root.Set("buckets", buckets.release()); |
| 45 serializer.Serialize(root); | 64 serializer.Serialize(root); |
| 46 } | 65 } |
| 47 | 66 |
| 48 } // namespace base | 67 } // namespace base |
| OLD | NEW |