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/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
8 #include "content/browser/browser_thread.h" | |
8 | 9 |
9 namespace net { | 10 namespace net { |
10 | 11 |
11 // We're using a histogram as a group of counters. We're only interested in | 12 // 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 | 13 // the values of the counters. Ignore the shape, average, and standard |
13 // deviation of the histograms because they are meaningless. | 14 // deviation of the histograms because they are meaningless. |
14 // | 15 // |
15 // We use two groups of counters. In the first group (counter1), each counter | 16 // 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 | 17 // 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 | 18 // 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 | 19 // counter is the number of connections of that type the user has seen during |
19 // that session. | 20 // that session. |
20 // | 21 // |
21 // Each histogram has an unused bucket at the end to allow seamless future | 22 // Each histogram has an unused bucket at the end to allow seamless future |
22 // expansion. | 23 // expansion. |
23 void UpdateConnectionTypeHistograms(ConnectionType type) { | 24 void UpdateConnectionTypeHistograms(ConnectionType type) { |
24 static bool had_connection_type[NUM_OF_CONNECTION_TYPES]; | 25 static bool had_connection_type[NUM_OF_CONNECTION_TYPES]; |
26 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
willchan no longer on Chromium
2011/03/04 19:15:34
Unfortunately, net/ is not aware of browser stuff.
| |
25 | 27 |
26 if (type >= 0 && type < NUM_OF_CONNECTION_TYPES) { | 28 if (type >= 0 && type < NUM_OF_CONNECTION_TYPES) { |
27 if (!had_connection_type[type]) { | 29 if (!had_connection_type[type]) { |
28 had_connection_type[type] = true; | 30 had_connection_type[type] = true; |
29 UMA_HISTOGRAM_ENUMERATION("Net.HadConnectionType3", | 31 UMA_HISTOGRAM_ENUMERATION("Net.HadConnectionType3", |
30 type, NUM_OF_CONNECTION_TYPES); | 32 type, NUM_OF_CONNECTION_TYPES); |
31 } | 33 } |
32 | 34 |
33 UMA_HISTOGRAM_ENUMERATION("Net.ConnectionTypeCount3", | 35 UMA_HISTOGRAM_ENUMERATION("Net.ConnectionTypeCount3", |
34 type, NUM_OF_CONNECTION_TYPES); | 36 type, NUM_OF_CONNECTION_TYPES); |
35 } else { | 37 } else { |
36 NOTREACHED(); // Someone's logging an invalid type! | 38 NOTREACHED(); // Someone's logging an invalid type! |
37 } | 39 } |
38 } | 40 } |
39 | 41 |
40 } // namespace net | 42 } // namespace net |
OLD | NEW |