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 #ifndef COMPONENTS_SYNC_BASE_DATA_TYPE_HISTOGRAM_H_ | 5 #ifndef COMPONENTS_SYNC_BASE_DATA_TYPE_HISTOGRAM_H_ |
6 #define COMPONENTS_SYNC_BASE_DATA_TYPE_HISTOGRAM_H_ | 6 #define COMPONENTS_SYNC_BASE_DATA_TYPE_HISTOGRAM_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
12 #include "components/sync/base/model_type.h" | 12 #include "components/sync/base/model_type.h" |
13 | 13 |
| 14 // Prefix for histogram recording datatype's memory usage. |
| 15 extern const char kModelTypeMemoryHistogramPrefix[]; |
| 16 |
14 // This function adds |value| to |sample| bucket of histogram |name|. |value| | 17 // This function adds |value| to |sample| bucket of histogram |name|. |value| |
15 // should be greater or equal to 1 and |name| can be variable. DataTypes are | 18 // should be greater or equal to 1 and |name| can be variable. DataTypes are |
16 // mapped to proper |sample| bucket by using ModelTypeToHistogramInt() function. | 19 // mapped to proper |sample| bucket by using ModelTypeToHistogramInt() function. |
17 // So different DataTypes play the role of different buckets in this histogram. | 20 // So different DataTypes play the role of different buckets in this histogram. |
18 void SyncRecordDatatypeBin(const std::string& name, int sample, int value); | 21 void SyncRecordDatatypeBin(const std::string& name, int sample, int value); |
19 | 22 |
| 23 // Converts memory size |value| into kilobytes and records it into |model_type| |
| 24 // related histogram with prefix |histogram_name_prefix|. |
| 25 void SyncRecordMemoryKbHistogram(const std::string& histogram_name_prefix, |
| 26 syncer::ModelType model_type, |
| 27 size_t value); |
| 28 |
20 // For now, this just implements UMA_HISTOGRAM_LONG_TIMES. This can be adjusted | 29 // For now, this just implements UMA_HISTOGRAM_LONG_TIMES. This can be adjusted |
21 // if we feel the min, max, or bucket count amount are not appropriate. | 30 // if we feel the min, max, or bucket count amount are not appropriate. |
22 #define SYNC_FREQ_HISTOGRAM(name, time) \ | 31 #define SYNC_FREQ_HISTOGRAM(name, time) \ |
23 UMA_HISTOGRAM_CUSTOM_TIMES(name, time, base::TimeDelta::FromMilliseconds(1), \ | 32 UMA_HISTOGRAM_CUSTOM_TIMES(name, time, base::TimeDelta::FromMilliseconds(1), \ |
24 base::TimeDelta::FromHours(1), 50) | 33 base::TimeDelta::FromHours(1), 50) |
25 | 34 |
26 // Helper macro for datatype specific histograms. For each datatype, invokes | 35 // Helper macro for datatype specific histograms. For each datatype, invokes |
27 // a pre-defined PER_DATA_TYPE_MACRO(type_str), where |type_str| is the string | 36 // a pre-defined PER_DATA_TYPE_MACRO(type_str), where |type_str| is the string |
28 // version of the datatype. | 37 // version of the datatype. |
29 // | 38 // |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 case ::syncer::EXPERIMENTS: \ | 167 case ::syncer::EXPERIMENTS: \ |
159 PER_DATA_TYPE_MACRO("Experiments"); \ | 168 PER_DATA_TYPE_MACRO("Experiments"); \ |
160 break; \ | 169 break; \ |
161 default: \ | 170 default: \ |
162 NOTREACHED() << "Unknown datatype " \ | 171 NOTREACHED() << "Unknown datatype " \ |
163 << ::syncer::ModelTypeToString(datatype); \ | 172 << ::syncer::ModelTypeToString(datatype); \ |
164 } \ | 173 } \ |
165 } while (0) | 174 } while (0) |
166 | 175 |
167 #endif // COMPONENTS_SYNC_BASE_DATA_TYPE_HISTOGRAM_H_ | 176 #endif // COMPONENTS_SYNC_BASE_DATA_TYPE_HISTOGRAM_H_ |
OLD | NEW |