OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "net/base/connection_type_histograms.h" |
| 6 |
| 7 #include "base/histogram.h" |
| 8 |
| 9 namespace net { |
| 10 |
| 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 |
| 13 // deviation of the histograms because they are meaningless. |
| 14 // |
| 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 |
| 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 |
| 19 // that session. |
| 20 void UpdateConnectionTypeHistograms(ConnectionType type) { |
| 21 static bool had_connection_type[NUM_OF_CONNECTION_TYPES]; |
| 22 static LinearHistogram counter1(L"Net.HadConnectionType", |
| 23 1, NUM_OF_CONNECTION_TYPES - 1, |
| 24 NUM_OF_CONNECTION_TYPES); |
| 25 static LinearHistogram counter2(L"Net.ConnectionTypeCount", |
| 26 1, NUM_OF_CONNECTION_TYPES - 1, |
| 27 NUM_OF_CONNECTION_TYPES); |
| 28 |
| 29 if (type >= 0 && type < NUM_OF_CONNECTION_TYPES) { |
| 30 if (!had_connection_type[type]) { |
| 31 had_connection_type[type] = true; |
| 32 counter1.Add(type); |
| 33 } |
| 34 } |
| 35 counter2.Add(type); |
| 36 } |
| 37 |
| 38 } // namespace net |
OLD | NEW |