OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 |
11 #ifndef NET_DISK_CACHE_HISTOGRAM_MACROS_H_ | 11 #ifndef NET_DISK_CACHE_HISTOGRAM_MACROS_H_ |
12 #define NET_DISK_CACHE_HISTOGRAM_MACROS_H_ | 12 #define NET_DISK_CACHE_HISTOGRAM_MACROS_H_ |
13 | 13 |
14 // HISTOGRAM_HOURS will collect time related data with a granularity of hours | 14 // HISTOGRAM_HOURS will collect time related data with a granularity of hours |
15 // and normal values of a few months. | 15 // and normal values of a few months. |
16 #define UMA_HISTOGRAM_HOURS UMA_HISTOGRAM_COUNTS_10000 | 16 #define UMA_HISTOGRAM_HOURS UMA_HISTOGRAM_COUNTS_10000 |
17 | 17 |
18 // HISTOGRAM_AGE will collect time elapsed since |initial_time|, with a | 18 // HISTOGRAM_AGE will collect time elapsed since |initial_time|, with a |
19 // granularity of hours and normal values of a few months. | 19 // granularity of hours and normal values of a few months. |
20 #define UMA_HISTOGRAM_AGE(name, initial_time)\ | 20 #define UMA_HISTOGRAM_AGE(name, initial_time)\ |
21 UMA_HISTOGRAM_COUNTS_10000(name, (Time::Now() - initial_time).InHours()) | 21 UMA_HISTOGRAM_COUNTS_10000(name, (Time::Now() - initial_time).InHours()) |
22 | 22 |
23 // HISTOGRAM_AGE_MS will collect time elapsed since |initial_time|, with the | 23 // HISTOGRAM_AGE_MS will collect time elapsed since |initial_time|, with the |
24 // normal resolution of the UMA_HISTOGRAM_TIMES. | 24 // normal resolution of the UMA_HISTOGRAM_TIMES. |
25 #define UMA_HISTOGRAM_AGE_MS(name, initial_time)\ | 25 #define UMA_HISTOGRAM_AGE_MS(name, initial_time)\ |
26 UMA_HISTOGRAM_TIMES(name, Time::Now() - initial_time) | 26 UMA_HISTOGRAM_TIMES(name, Time::Now() - initial_time) |
27 | 27 |
28 #define UMA_HISTOGRAM_CACHE_ERROR(name, sample) do { \ | 28 #define UMA_HISTOGRAM_CACHE_ERROR(name, sample) \ |
29 static scoped_refptr<Histogram> counter = \ | 29 UMA_HISTOGRAM_ENUMERATION(name, sample, 50) |
30 LinearHistogram::LinearHistogramFactoryGet(\ | |
31 (name), 1, 49, 50); \ | |
32 counter->SetFlags(kUmaTargetedHistogramFlag); \ | |
33 counter->Add(sample); \ | |
34 } while (0) | |
35 | 30 |
36 #ifdef NET_DISK_CACHE_BACKEND_IMPL_CC_ | 31 #ifdef NET_DISK_CACHE_BACKEND_IMPL_CC_ |
37 #define BACKEND_OBJ this | 32 #define BACKEND_OBJ this |
38 #else | 33 #else |
39 #define BACKEND_OBJ backend_ | 34 #define BACKEND_OBJ backend_ |
40 #endif | 35 #endif |
41 | 36 |
42 // Generates a UMA histogram of the given type, generating the proper name for | 37 // Generates a UMA histogram of the given type, generating the proper name for |
43 // it (asking backend_->HistogramName), and adding the provided sample. | 38 // it (asking backend_->HistogramName), and adding the provided sample. |
44 // For example, to generate a regualar UMA_HISTOGRAM_COUNTS, this macro would | 39 // For example, to generate a regualar UMA_HISTOGRAM_COUNTS, this macro would |
(...skipping 13 matching lines...) Expand all Loading... |
58 case net::MEDIA_CACHE:\ | 53 case net::MEDIA_CACHE:\ |
59 UMA_HISTOGRAM_##type(my_name.data(), sample);\ | 54 UMA_HISTOGRAM_##type(my_name.data(), sample);\ |
60 break;\ | 55 break;\ |
61 default:\ | 56 default:\ |
62 NOTREACHED();\ | 57 NOTREACHED();\ |
63 break;\ | 58 break;\ |
64 }\ | 59 }\ |
65 } | 60 } |
66 | 61 |
67 #endif // NET_DISK_CACHE_HISTOGRAM_MACROS_H_ | 62 #endif // NET_DISK_CACHE_HISTOGRAM_MACROS_H_ |
OLD | NEW |