OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // This file contains macros to simplify histogram reporting from the disk | 5 // This file contains macros to simplify histogram reporting from the disk |
6 // cache. The main issue is that we want to have separate histograms for each | 6 // cache. The main issue is that we want to have separate histograms for each |
7 // type of cache (regular vs. media, etc), without adding the complexity of | 7 // type of cache (regular vs. media, etc), without adding the complexity of |
8 // keeping track of a potentially large number of histogram objects that have to | 8 // keeping track of a potentially large number of histogram objects that have to |
9 // survive the backend object that created them. | 9 // survive the backend object that created them. |
10 | 10 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 (base::Time::Now() - initial_time).InHours()) | 77 (base::Time::Now() - initial_time).InHours()) |
78 | 78 |
79 // HISTOGRAM_AGE_MS will collect time elapsed since |initial_time|, with the | 79 // HISTOGRAM_AGE_MS will collect time elapsed since |initial_time|, with the |
80 // normal resolution of the UMA_HISTOGRAM_TIMES. | 80 // normal resolution of the UMA_HISTOGRAM_TIMES. |
81 #define CACHE_HISTOGRAM_AGE_MS(name, initial_time)\ | 81 #define CACHE_HISTOGRAM_AGE_MS(name, initial_time)\ |
82 CACHE_HISTOGRAM_TIMES(name, base::TimeTicks::Now() - initial_time) | 82 CACHE_HISTOGRAM_TIMES(name, base::TimeTicks::Now() - initial_time) |
83 | 83 |
84 #define CACHE_HISTOGRAM_CACHE_ERROR(name, sample) \ | 84 #define CACHE_HISTOGRAM_CACHE_ERROR(name, sample) \ |
85 CACHE_HISTOGRAM_ENUMERATION(name, sample, 50) | 85 CACHE_HISTOGRAM_ENUMERATION(name, sample, 50) |
86 | 86 |
87 #ifdef NET_DISK_CACHE_BACKEND_IMPL_CC_ | |
88 #define BACKEND_OBJ this | |
89 #else | |
90 #define BACKEND_OBJ backend_ | |
91 #endif | |
92 | |
93 // Generates a UMA histogram of the given type, generating the proper name for | 87 // Generates a UMA histogram of the given type, generating the proper name for |
94 // it (asking backend_->HistogramName), and adding the provided sample. | 88 // it (asking backend_->HistogramName), and adding the provided sample. |
95 // For example, to generate a regualar UMA_HISTOGRAM_COUNTS, this macro would | 89 // For example, to generate a regualar UMA_HISTOGRAM_COUNTS, this macro would |
96 // be used as: | 90 // be used as: |
97 // CACHE_UMA(COUNTS, "MyName", 0, 20); | 91 // CACHE_UMA(COUNTS, "MyName", 0, 20); |
98 // CACHE_UMA(COUNTS, "MyExperiment", 530, 55); | 92 // CACHE_UMA(COUNTS, "MyExperiment", 530, 55); |
99 // which roughly translates to: | 93 // which roughly translates to: |
100 // UMA_HISTOGRAM_COUNTS("DiskCache.2.MyName", 20); // "2" is the CacheType. | 94 // UMA_HISTOGRAM_COUNTS("DiskCache.2.MyName", 20); // "2" is the CacheType. |
101 // UMA_HISTOGRAM_COUNTS("DiskCache.2.MyExperiment_530", 55); | 95 // UMA_HISTOGRAM_COUNTS("DiskCache.2.MyExperiment_530", 55); |
102 // | 96 // |
103 #define CACHE_UMA(type, name, experiment, sample) {\ | 97 #define CACHE_UMA(type, name, experiment, sample) {\ |
104 const std::string my_name = BACKEND_OBJ->HistogramName(name, experiment);\ | 98 const std::string my_name =\ |
105 switch (BACKEND_OBJ->cache_type()) {\ | 99 CACHE_UMA_BACKEND_IMPL_OBJ->HistogramName(name, experiment);\ |
| 100 switch (CACHE_UMA_BACKEND_IMPL_OBJ->cache_type()) {\ |
106 case net::DISK_CACHE:\ | 101 case net::DISK_CACHE:\ |
107 CACHE_HISTOGRAM_##type(my_name.data(), sample);\ | 102 CACHE_HISTOGRAM_##type(my_name.data(), sample);\ |
108 break;\ | 103 break;\ |
109 case net::MEDIA_CACHE:\ | 104 case net::MEDIA_CACHE:\ |
110 CACHE_HISTOGRAM_##type(my_name.data(), sample);\ | 105 CACHE_HISTOGRAM_##type(my_name.data(), sample);\ |
111 break;\ | 106 break;\ |
112 case net::APP_CACHE:\ | 107 case net::APP_CACHE:\ |
113 CACHE_HISTOGRAM_##type(my_name.data(), sample);\ | 108 CACHE_HISTOGRAM_##type(my_name.data(), sample);\ |
114 break;\ | 109 break;\ |
115 case net::SHADER_CACHE:\ | 110 case net::SHADER_CACHE:\ |
116 CACHE_HISTOGRAM_##type(my_name.data(), sample);\ | 111 CACHE_HISTOGRAM_##type(my_name.data(), sample);\ |
117 break;\ | 112 break;\ |
118 case net::PNACL_CACHE:\ | 113 case net::PNACL_CACHE:\ |
119 CACHE_HISTOGRAM_##type(my_name.data(), sample);\ | 114 CACHE_HISTOGRAM_##type(my_name.data(), sample);\ |
120 break;\ | 115 break;\ |
121 default:\ | 116 default:\ |
122 NOTREACHED();\ | 117 NOTREACHED();\ |
123 break;\ | 118 break;\ |
124 }\ | 119 }\ |
125 } | 120 } |
126 | 121 |
127 #endif // NET_DISK_CACHE_HISTOGRAM_MACROS_H_ | 122 #endif // NET_DISK_CACHE_HISTOGRAM_MACROS_H_ |
OLD | NEW |