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) do { \ |
29 static LinearHistogram counter((name), 0, 49, 50); \ | 29 static scoped_refptr<Histogram> counter = \ |
30 counter.SetFlags(kUmaTargetedHistogramFlag); \ | 30 LinearHistogram::LinearHistogramFactoryGet(\ |
31 counter.Add(sample); \ | 31 (name), 1, 49, 50); \ |
| 32 counter->SetFlags(kUmaTargetedHistogramFlag); \ |
| 33 counter->Add(sample); \ |
32 } while (0) | 34 } while (0) |
33 | 35 |
34 #ifdef NET_DISK_CACHE_BACKEND_IMPL_CC_ | 36 #ifdef NET_DISK_CACHE_BACKEND_IMPL_CC_ |
35 #define BACKEND_OBJ this | 37 #define BACKEND_OBJ this |
36 #else | 38 #else |
37 #define BACKEND_OBJ backend_ | 39 #define BACKEND_OBJ backend_ |
38 #endif | 40 #endif |
39 | 41 |
40 // Generates a UMA histogram of the given type, generating the proper name for | 42 // Generates a UMA histogram of the given type, generating the proper name for |
41 // it (asking backend_->HistogramName), and adding the provided sample. | 43 // it (asking backend_->HistogramName), and adding the provided sample. |
(...skipping 14 matching lines...) Expand all Loading... |
56 case net::MEDIA_CACHE:\ | 58 case net::MEDIA_CACHE:\ |
57 UMA_HISTOGRAM_##type(my_name.data(), sample);\ | 59 UMA_HISTOGRAM_##type(my_name.data(), sample);\ |
58 break;\ | 60 break;\ |
59 default:\ | 61 default:\ |
60 NOTREACHED();\ | 62 NOTREACHED();\ |
61 break;\ | 63 break;\ |
62 }\ | 64 }\ |
63 } | 65 } |
64 | 66 |
65 #endif // NET_DISK_CACHE_HISTOGRAM_MACROS_H_ | 67 #endif // NET_DISK_CACHE_HISTOGRAM_MACROS_H_ |
OLD | NEW |