OLD | NEW |
1 // Copyright (c) 2009 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 #include "net/base/connection_type_histograms.h" | 5 #include "net/base/connection_type_histograms.h" |
6 | 6 |
7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/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) { | 23 void UpdateConnectionTypeHistograms(ConnectionType type) { |
24 // TODO(wtc): Bug 74467 Move these stats up to a higher level, where the | 24 // TODO(wtc): Bug 74467 Move these stats up to a higher level. |
25 // explicit static (shown below) and the implicit statics (inside the | 25 static bool had_connection_type[NUM_OF_CONNECTION_TYPES]; // Default false. |
26 // HISTOGRAM macros) will be thread safe. | |
27 #if 0 // Don't do anything for now. | |
28 | |
29 static bool had_connection_type[NUM_OF_CONNECTION_TYPES]; | |
30 | 26 |
31 if (type >= 0 && type < NUM_OF_CONNECTION_TYPES) { | 27 if (type >= 0 && type < NUM_OF_CONNECTION_TYPES) { |
32 if (!had_connection_type[type]) { | 28 if (!had_connection_type[type]) { |
33 had_connection_type[type] = true; | 29 had_connection_type[type] = true; |
34 UMA_HISTOGRAM_ENUMERATION("Net.HadConnectionType3", | 30 UMA_HISTOGRAM_ENUMERATION("Net.HadConnectionType3", |
35 type, NUM_OF_CONNECTION_TYPES); | 31 type, NUM_OF_CONNECTION_TYPES); |
36 } | 32 } |
37 | 33 |
38 UMA_HISTOGRAM_ENUMERATION("Net.ConnectionTypeCount3", | 34 UMA_HISTOGRAM_ENUMERATION("Net.ConnectionTypeCount3", |
39 type, NUM_OF_CONNECTION_TYPES); | 35 type, NUM_OF_CONNECTION_TYPES); |
40 } else { | 36 } else { |
41 NOTREACHED(); // Someone's logging an invalid type! | 37 NOTREACHED(); // Someone's logging an invalid type! |
42 } | 38 } |
43 #endif // 0 | |
44 } | 39 } |
45 | 40 |
46 } // namespace net | 41 } // namespace net |
OLD | NEW |