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 #include "net/base/connection_type_histograms.h" | 5 #include "net/base/connection_type_histograms.h" |
6 | 6 |
7 #include "base/histogram.h" | 7 #include "base/histogram.h" |
8 | 8 |
9 namespace net { | 9 namespace net { |
10 | 10 |
11 // We're using a histogram as a group of counters. We're only interested in | 11 // We're using a histogram as a group of counters. We're only interested in |
12 // the values of the counters. Ignore the shape, average, and standard | 12 // the values of the counters. Ignore the shape, average, and standard |
13 // deviation of the histograms because they are meaningless. | 13 // deviation of the histograms because they are meaningless. |
14 // | 14 // |
15 // We use two groups of counters. In the first group (counter1), each counter | 15 // We use two groups of counters. In the first group (counter1), each counter |
16 // is a boolean (0 or 1) that indicates whether the user has seen a connection | 16 // is a boolean (0 or 1) that indicates whether the user has seen a connection |
17 // of that type during that session. In the second group (counter2), each | 17 // of that type during that session. In the second group (counter2), each |
18 // counter is the number of connections of that type the user has seen during | 18 // counter is the number of connections of that type the user has seen during |
19 // that session. | 19 // that session. |
20 // | 20 // |
21 // Each histogram has an unused bucket at the end to allow seamless future | 21 // Each histogram has an unused bucket at the end to allow seamless future |
22 // expansion. | 22 // expansion. |
23 void UpdateConnectionTypeHistograms(ConnectionType type, bool success) { | 23 void UpdateConnectionTypeHistograms(ConnectionType type, bool success) { |
24 static bool had_connection_type[NUM_OF_CONNECTION_TYPES]; | 24 static bool had_connection_type[NUM_OF_CONNECTION_TYPES]; |
25 static scoped_refptr<Histogram> had_histogram = | |
26 LinearHistogram::LinearHistogramFactoryGet("Net.HadConnectionType2", | |
27 1, NUM_OF_CONNECTION_TYPES, | |
28 NUM_OF_CONNECTION_TYPES + 1); | |
29 static scoped_refptr<Histogram> success_histogram = | |
30 LinearHistogram::LinearHistogramFactoryGet("Net.ConnectionTypeCount2", | |
31 1, NUM_OF_CONNECTION_TYPES, | |
32 NUM_OF_CONNECTION_TYPES + 1); | |
33 static scoped_refptr<Histogram> failed_histogram = | |
34 LinearHistogram::LinearHistogramFactoryGet("Net.ConnectionTypeFailCount2", | |
35 1, NUM_OF_CONNECTION_TYPES, | |
36 NUM_OF_CONNECTION_TYPES + 1); | |
37 | 25 |
38 if (type >= 0 && type < NUM_OF_CONNECTION_TYPES) { | 26 if (type >= 0 && type < NUM_OF_CONNECTION_TYPES) { |
39 if (!had_connection_type[type]) { | 27 if (!had_connection_type[type]) { |
40 had_connection_type[type] = true; | 28 had_connection_type[type] = true; |
41 had_histogram->SetFlags(kUmaTargetedHistogramFlag); | 29 UMA_HISTOGRAM_ENUMERATION("Net.HadConnectionType2", |
42 had_histogram->Add(type); | 30 type, NUM_OF_CONNECTION_TYPES); |
43 } | 31 } |
44 | 32 |
45 Histogram* histogram; | 33 if (success) |
46 histogram = success ? success_histogram.get() : failed_histogram.get(); | 34 UMA_HISTOGRAM_ENUMERATION("Net.ConnectionTypeCount2", |
47 histogram->SetFlags(kUmaTargetedHistogramFlag); | 35 type, NUM_OF_CONNECTION_TYPES); |
48 histogram->Add(type); | 36 else |
| 37 UMA_HISTOGRAM_ENUMERATION("Net.ConnectionTypeFailCount2", |
| 38 type, NUM_OF_CONNECTION_TYPES); |
49 } else { | 39 } else { |
50 NOTREACHED(); // Someone's logging an invalid type! | 40 NOTREACHED(); // Someone's logging an invalid type! |
51 } | 41 } |
52 } | 42 } |
53 | 43 |
54 } // namespace net | 44 } // namespace net |
OLD | NEW |