Thieu Le | ad1ec2c | 2012-01-05 23:39:48 +0000 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
Thieu Le | 48e6d6d | 2011-12-06 00:40:27 +0000 | [diff] [blame] | 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 "shill/metrics.h" |
| 6 | |
Ben Chan | a0ddf46 | 2014-02-06 11:32:42 -0800 | [diff] [blame] | 7 | #include <base/strings/string_util.h> |
| 8 | #include <base/strings/stringprintf.h> |
Thieu Le | ad1ec2c | 2012-01-05 23:39:48 +0000 | [diff] [blame] | 9 | #include <chromeos/dbus/service_constants.h> |
Darin Petkov | 58f0b6d | 2012-06-12 12:52:30 +0200 | [diff] [blame] | 10 | #include <metrics/bootstat.h> |
Thieu Le | 48e6d6d | 2011-12-06 00:40:27 +0000 | [diff] [blame] | 11 | |
Paul Stewart | ff845fc | 2012-08-07 07:28:44 -0700 | [diff] [blame] | 12 | #include "shill/link_monitor.h" |
Christopher Wiley | b691efd | 2012-08-09 13:51:51 -0700 | [diff] [blame] | 13 | #include "shill/logging.h" |
Thieu Le | 48e6d6d | 2011-12-06 00:40:27 +0000 | [diff] [blame] | 14 | |
| 15 | using std::string; |
Alex Vakulenko | 8a53229 | 2014-06-16 17:18:44 -0700 | [diff] [blame] | 16 | using std::shared_ptr; |
Thieu Le | 48e6d6d | 2011-12-06 00:40:27 +0000 | [diff] [blame] | 17 | |
| 18 | namespace shill { |
| 19 | |
Rebecca Silberstein | c9c31d8 | 2014-10-21 15:01:00 -0700 | [diff] [blame] | 20 | namespace Logging { |
| 21 | static auto kModuleLogScope = ScopeLogger::kMetrics; |
Paul Stewart | 8ae1874 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 22 | static string ObjectID(const Metrics* m) { return "(metrics)"; } |
Rebecca Silberstein | c9c31d8 | 2014-10-21 15:01:00 -0700 | [diff] [blame] | 23 | } |
| 24 | |
mukesh agrawal | 132e96f | 2014-04-24 11:49:42 -0700 | [diff] [blame] | 25 | static const char kMetricPrefix[] = "Network.Shill"; |
| 26 | |
Thieu Le | 48e6d6d | 2011-12-06 00:40:27 +0000 | [diff] [blame] | 27 | // static |
Thieu Le | c31e6f9 | 2012-08-03 13:08:58 -0700 | [diff] [blame] | 28 | // Our disconnect enumeration values are 0 (System Disconnect) and |
| 29 | // 1 (User Disconnect), see histograms.xml, but Chrome needs a minimum |
| 30 | // enum value of 1 and the minimum number of buckets needs to be 3 (see |
| 31 | // histogram.h). Instead of remapping System Disconnect to 1 and |
| 32 | // User Disconnect to 2, we can just leave the enumerated values as-is |
| 33 | // because Chrome implicitly creates a [0-1) bucket for us. Using Min=1, |
| 34 | // Max=2 and NumBuckets=3 gives us the following three buckets: |
| 35 | // [0-1), [1-2), [2-INT_MAX). We end up with an extra bucket [2-INT_MAX) |
| 36 | // that we can safely ignore. |
mukesh agrawal | 132e96f | 2014-04-24 11:49:42 -0700 | [diff] [blame] | 37 | const char Metrics::kMetricDisconnectSuffix[] = "Disconnect"; |
Thieu Le | c31e6f9 | 2012-08-03 13:08:58 -0700 | [diff] [blame] | 38 | const int Metrics::kMetricDisconnectMax = 2; |
| 39 | const int Metrics::kMetricDisconnectMin = 1; |
| 40 | const int Metrics::kMetricDisconnectNumBuckets = 3; |
Thieu Le | 67370f6 | 2012-02-14 23:01:42 +0000 | [diff] [blame] | 41 | |
mukesh agrawal | 132e96f | 2014-04-24 11:49:42 -0700 | [diff] [blame] | 42 | const char Metrics::kMetricSignalAtDisconnectSuffix[] = "SignalAtDisconnect"; |
Wade Guthrie | 9ec0806 | 2013-09-25 15:22:24 -0700 | [diff] [blame] | 43 | const int Metrics::kMetricSignalAtDisconnectMin = 0; |
| 44 | const int Metrics::kMetricSignalAtDisconnectMax = 200; |
| 45 | const int Metrics::kMetricSignalAtDisconnectNumBuckets = 40; |
| 46 | |
mukesh agrawal | 132e96f | 2014-04-24 11:49:42 -0700 | [diff] [blame] | 47 | const char Metrics::kMetricNetworkApModeSuffix[] = "ApMode"; |
| 48 | const char Metrics::kMetricNetworkChannelSuffix[] = "Channel"; |
Thieu Le | 48e6d6d | 2011-12-06 00:40:27 +0000 | [diff] [blame] | 49 | const int Metrics::kMetricNetworkChannelMax = Metrics::kWiFiChannelMax; |
mukesh agrawal | 132e96f | 2014-04-24 11:49:42 -0700 | [diff] [blame] | 50 | const char Metrics::kMetricNetworkEapInnerProtocolSuffix[] = "EapInnerProtocol"; |
Paul Stewart | 21f4096 | 2013-03-01 14:27:28 -0800 | [diff] [blame] | 51 | const int Metrics::kMetricNetworkEapInnerProtocolMax = |
| 52 | Metrics::kEapInnerProtocolMax; |
mukesh agrawal | 132e96f | 2014-04-24 11:49:42 -0700 | [diff] [blame] | 53 | const char Metrics::kMetricNetworkEapOuterProtocolSuffix[] = "EapOuterProtocol"; |
Paul Stewart | 21f4096 | 2013-03-01 14:27:28 -0800 | [diff] [blame] | 54 | const int Metrics::kMetricNetworkEapOuterProtocolMax = |
| 55 | Metrics::kEapOuterProtocolMax; |
mukesh agrawal | 132e96f | 2014-04-24 11:49:42 -0700 | [diff] [blame] | 56 | const char Metrics::kMetricNetworkPhyModeSuffix[] = "PhyMode"; |
Thieu Le | ad1ec2c | 2012-01-05 23:39:48 +0000 | [diff] [blame] | 57 | const int Metrics::kMetricNetworkPhyModeMax = Metrics::kWiFiNetworkPhyModeMax; |
mukesh agrawal | 132e96f | 2014-04-24 11:49:42 -0700 | [diff] [blame] | 58 | const char Metrics::kMetricNetworkSecuritySuffix[] = "Security"; |
Thieu Le | ad1ec2c | 2012-01-05 23:39:48 +0000 | [diff] [blame] | 59 | const int Metrics::kMetricNetworkSecurityMax = Metrics::kWiFiSecurityMax; |
Thieu Le | 48e6d6d | 2011-12-06 00:40:27 +0000 | [diff] [blame] | 60 | const char Metrics::kMetricNetworkServiceErrors[] = |
| 61 | "Network.Shill.ServiceErrors"; |
mukesh agrawal | 132e96f | 2014-04-24 11:49:42 -0700 | [diff] [blame] | 62 | const char Metrics::kMetricNetworkSignalStrengthSuffix[] = "SignalStrength"; |
Paul Stewart | 23b393a | 2012-09-25 21:21:06 -0700 | [diff] [blame] | 63 | const int Metrics::kMetricNetworkSignalStrengthMax = 200; |
| 64 | const int Metrics::kMetricNetworkSignalStrengthMin = 0; |
| 65 | const int Metrics::kMetricNetworkSignalStrengthNumBuckets = 40; |
Thieu Le | a20cbc2 | 2012-01-09 22:01:43 +0000 | [diff] [blame] | 66 | |
mukesh agrawal | facf7ad | 2014-09-30 15:25:44 -0700 | [diff] [blame] | 67 | constexpr char |
| 68 | Metrics::kMetricRememberedSystemWiFiNetworkCountBySecurityModeFormat[]; |
| 69 | constexpr char |
| 70 | Metrics::kMetricRememberedUserWiFiNetworkCountBySecurityModeFormat[]; |
| 71 | |
Paul Stewart | 4ef524d | 2014-07-23 13:11:29 -0700 | [diff] [blame] | 72 | const char Metrics::kMetricRememberedWiFiNetworkCount[] = |
| 73 | "Network.Shill.WiFi.RememberedNetworkCount"; |
| 74 | const int Metrics::kMetricRememberedWiFiNetworkCountMax = 1024; |
| 75 | const int Metrics::kMetricRememberedWiFiNetworkCountMin = 0; |
| 76 | const int Metrics::kMetricRememberedWiFiNetworkCountNumBuckets = 32; |
| 77 | |
mukesh agrawal | 132e96f | 2014-04-24 11:49:42 -0700 | [diff] [blame] | 78 | const char Metrics::kMetricTimeOnlineSecondsSuffix[] = "TimeOnline"; |
Thieu Le | a20cbc2 | 2012-01-09 22:01:43 +0000 | [diff] [blame] | 79 | const int Metrics::kMetricTimeOnlineSecondsMax = 8 * 60 * 60; // 8 hours |
| 80 | const int Metrics::kMetricTimeOnlineSecondsMin = 1; |
| 81 | |
mukesh agrawal | 132e96f | 2014-04-24 11:49:42 -0700 | [diff] [blame] | 82 | const char Metrics::kMetricTimeToConnectMillisecondsSuffix[] = "TimeToConnect"; |
Thieu Le | cdb5a21 | 2013-01-25 11:17:18 -0800 | [diff] [blame] | 83 | const int Metrics::kMetricTimeToConnectMillisecondsMax = |
| 84 | 60 * 1000; // 60 seconds |
| 85 | const int Metrics::kMetricTimeToConnectMillisecondsMin = 1; |
| 86 | const int Metrics::kMetricTimeToConnectMillisecondsNumBuckets = 60; |
| 87 | |
mukesh agrawal | 132e96f | 2014-04-24 11:49:42 -0700 | [diff] [blame] | 88 | const char Metrics::kMetricTimeToScanAndConnectMillisecondsSuffix[] = |
| 89 | "TimeToScanAndConnect"; |
Wade Guthrie | 44f290d | 2013-05-28 10:16:25 -0700 | [diff] [blame] | 90 | |
Thieu Le | a20cbc2 | 2012-01-09 22:01:43 +0000 | [diff] [blame] | 91 | const char Metrics::kMetricTimeToDropSeconds[] = "Network.Shill.TimeToDrop";; |
| 92 | const int Metrics::kMetricTimeToDropSecondsMax = 8 * 60 * 60; // 8 hours |
| 93 | const int Metrics::kMetricTimeToDropSecondsMin = 1; |
| 94 | |
mukesh agrawal | 132e96f | 2014-04-24 11:49:42 -0700 | [diff] [blame] | 95 | const char Metrics::kMetricTimeToDisableMillisecondsSuffix[] = "TimeToDisable"; |
Thieu Le | a2519bf | 2013-01-23 16:51:54 -0800 | [diff] [blame] | 96 | const int Metrics::kMetricTimeToDisableMillisecondsMax = |
| 97 | 60 * 1000; // 60 seconds |
| 98 | const int Metrics::kMetricTimeToDisableMillisecondsMin = 1; |
| 99 | const int Metrics::kMetricTimeToDisableMillisecondsNumBuckets = 60; |
| 100 | |
mukesh agrawal | 132e96f | 2014-04-24 11:49:42 -0700 | [diff] [blame] | 101 | const char Metrics::kMetricTimeToEnableMillisecondsSuffix[] = "TimeToEnable"; |
Thieu Le | ce4483e | 2013-01-23 15:12:03 -0800 | [diff] [blame] | 102 | const int Metrics::kMetricTimeToEnableMillisecondsMax = |
| 103 | 60 * 1000; // 60 seconds |
| 104 | const int Metrics::kMetricTimeToEnableMillisecondsMin = 1; |
| 105 | const int Metrics::kMetricTimeToEnableMillisecondsNumBuckets = 60; |
| 106 | |
mukesh agrawal | 132e96f | 2014-04-24 11:49:42 -0700 | [diff] [blame] | 107 | const char Metrics::kMetricTimeToInitializeMillisecondsSuffix[] = |
| 108 | "TimeToInitialize"; |
Thieu Le | 769d50d | 2013-01-23 17:11:59 -0800 | [diff] [blame] | 109 | const int Metrics::kMetricTimeToInitializeMillisecondsMax = |
| 110 | 30 * 1000; // 30 seconds |
Thieu Le | ce4483e | 2013-01-23 15:12:03 -0800 | [diff] [blame] | 111 | const int Metrics::kMetricTimeToInitializeMillisecondsMin = 1; |
Thieu Le | 769d50d | 2013-01-23 17:11:59 -0800 | [diff] [blame] | 112 | const int Metrics::kMetricTimeToInitializeMillisecondsNumBuckets = 30; |
Thieu Le | c8078a6 | 2013-01-22 18:01:12 -0800 | [diff] [blame] | 113 | |
mukesh agrawal | 132e96f | 2014-04-24 11:49:42 -0700 | [diff] [blame] | 114 | const char Metrics::kMetricTimeResumeToReadyMillisecondsSuffix[] = |
| 115 | "TimeResumeToReady"; |
| 116 | const char Metrics::kMetricTimeToConfigMillisecondsSuffix[] = "TimeToConfig"; |
| 117 | const char Metrics::kMetricTimeToJoinMillisecondsSuffix[] = "TimeToJoin"; |
| 118 | const char Metrics::kMetricTimeToOnlineMillisecondsSuffix[] = "TimeToOnline"; |
| 119 | const char Metrics::kMetricTimeToPortalMillisecondsSuffix[] = "TimeToPortal"; |
Thieu Le | 18c1107 | 2013-01-28 17:21:37 -0800 | [diff] [blame] | 120 | |
mukesh agrawal | 132e96f | 2014-04-24 11:49:42 -0700 | [diff] [blame] | 121 | const char Metrics::kMetricTimeToScanMillisecondsSuffix[] = "TimeToScan"; |
Thieu Le | 18c1107 | 2013-01-28 17:21:37 -0800 | [diff] [blame] | 122 | const int Metrics::kMetricTimeToScanMillisecondsMax = 180 * 1000; // 3 minutes |
| 123 | const int Metrics::kMetricTimeToScanMillisecondsMin = 1; |
| 124 | const int Metrics::kMetricTimeToScanMillisecondsNumBuckets = 90; |
| 125 | |
Thieu Le | a20cbc2 | 2012-01-09 22:01:43 +0000 | [diff] [blame] | 126 | const int Metrics::kTimerHistogramMillisecondsMax = 45 * 1000; |
| 127 | const int Metrics::kTimerHistogramMillisecondsMin = 1; |
Thieu Le | 48e6d6d | 2011-12-06 00:40:27 +0000 | [diff] [blame] | 128 | const int Metrics::kTimerHistogramNumBuckets = 50; |
| 129 | |
mukesh agrawal | 132e96f | 2014-04-24 11:49:42 -0700 | [diff] [blame] | 130 | const char Metrics::kMetricPortalAttemptsSuffix[] = "PortalAttempts"; |
Thieu Le | 85e050b | 2012-03-13 15:04:38 -0700 | [diff] [blame] | 131 | const int Metrics::kMetricPortalAttemptsMax = |
| 132 | PortalDetector::kMaxRequestAttempts; |
| 133 | const int Metrics::kMetricPortalAttemptsMin = 1; |
| 134 | const int Metrics::kMetricPortalAttemptsNumBuckets = |
| 135 | Metrics::kMetricPortalAttemptsMax; |
| 136 | |
mukesh agrawal | 132e96f | 2014-04-24 11:49:42 -0700 | [diff] [blame] | 137 | const char Metrics::kMetricPortalAttemptsToOnlineSuffix[] = |
| 138 | "PortalAttemptsToOnline"; |
Thieu Le | 85e050b | 2012-03-13 15:04:38 -0700 | [diff] [blame] | 139 | const int Metrics::kMetricPortalAttemptsToOnlineMax = 100; |
| 140 | const int Metrics::kMetricPortalAttemptsToOnlineMin = 1; |
| 141 | const int Metrics::kMetricPortalAttemptsToOnlineNumBuckets = 10; |
| 142 | |
mukesh agrawal | 132e96f | 2014-04-24 11:49:42 -0700 | [diff] [blame] | 143 | const char Metrics::kMetricPortalResultSuffix[] = "PortalResult"; |
Thieu Le | 85e050b | 2012-03-13 15:04:38 -0700 | [diff] [blame] | 144 | |
Wade Guthrie | 60a3706 | 2013-04-02 11:39:09 -0700 | [diff] [blame] | 145 | const char Metrics::kMetricFrequenciesConnectedEver[] = |
| 146 | "Network.Shill.WiFi.FrequenciesConnectedEver"; |
| 147 | const int Metrics::kMetricFrequenciesConnectedMax = 50; |
| 148 | const int Metrics::kMetricFrequenciesConnectedMin = 1; |
| 149 | const int Metrics::kMetricFrequenciesConnectedNumBuckets = 50; |
| 150 | |
Wade Guthrie | b9e0ee7 | 2013-05-31 09:23:30 -0700 | [diff] [blame] | 151 | const char Metrics::kMetricScanResult[] = |
| 152 | "Network.Shill.WiFi.ScanResult"; |
Wade Guthrie | f22681f | 2013-05-31 11:46:31 -0700 | [diff] [blame] | 153 | const char Metrics::kMetricWiFiScanTimeInEbusyMilliseconds[] = |
| 154 | "Network.Shill.WiFi.ScanTimeInEbusy"; |
| 155 | |
Samuel Tan | ea7dcda | 2015-01-05 14:32:50 -0800 | [diff] [blame] | 156 | const char Metrics::kMetricTerminationActionTimeTaken[] = |
| 157 | "Network.Shill.TerminationActionTimeTaken"; |
Samuel Tan | fbe8d2b | 2014-09-15 20:23:59 -0700 | [diff] [blame] | 158 | const char Metrics::kMetricTerminationActionResult[] = |
| 159 | "Network.Shill.TerminationActionResult"; |
Samuel Tan | ea7dcda | 2015-01-05 14:32:50 -0800 | [diff] [blame] | 160 | const int Metrics::kMetricTerminationActionTimeTakenMillisecondsMax = 20000; |
| 161 | const int Metrics::kMetricTerminationActionTimeTakenMillisecondsMin = 1; |
Arman Uguray | 6d528f1 | 2012-09-13 13:44:55 -0700 | [diff] [blame] | 162 | |
Samuel Tan | ea7dcda | 2015-01-05 14:32:50 -0800 | [diff] [blame] | 163 | const char Metrics::kMetricSuspendActionTimeTaken[] = |
| 164 | "Network.Shill.SuspendActionTimeTaken"; |
Samuel Tan | fbe8d2b | 2014-09-15 20:23:59 -0700 | [diff] [blame] | 165 | const char Metrics::kMetricSuspendActionResult[] = |
| 166 | "Network.Shill.SuspendActionResult"; |
Samuel Tan | ea7dcda | 2015-01-05 14:32:50 -0800 | [diff] [blame] | 167 | const int Metrics::kMetricSuspendActionTimeTakenMillisecondsMax = 20000; |
| 168 | const int Metrics::kMetricSuspendActionTimeTakenMillisecondsMin = 1; |
Samuel Tan | fbe8d2b | 2014-09-15 20:23:59 -0700 | [diff] [blame] | 169 | |
Samuel Tan | ea7dcda | 2015-01-05 14:32:50 -0800 | [diff] [blame] | 170 | const char Metrics::kMetricDarkResumeActionTimeTaken[] = |
| 171 | "Network.Shill.DarkResumeActionTimeTaken"; |
Samuel Tan | 68b73d2 | 2014-10-28 17:00:56 -0700 | [diff] [blame] | 172 | const char Metrics::kMetricDarkResumeActionResult[] = |
| 173 | "Network.Shill.DarkResumeActionResult"; |
Samuel Tan | ea7dcda | 2015-01-05 14:32:50 -0800 | [diff] [blame] | 174 | const int Metrics::kMetricDarkResumeActionTimeTakenMillisecondsMax = 20000; |
| 175 | const int Metrics::kMetricDarkResumeActionTimeTakenMillisecondsMin = 1; |
Samuel Tan | 0e0ac0d | 2014-12-29 16:03:42 -0800 | [diff] [blame] | 176 | const char Metrics::kMetricDarkResumeUnmatchedScanResultReceived[] = |
| 177 | "Network.Shill.WiFi.DarkResumeUnmatchedScanResultsReceived"; |
Samuel Tan | 68b73d2 | 2014-10-28 17:00:56 -0700 | [diff] [blame] | 178 | |
Samuel Tan | 66bddc6 | 2014-11-13 20:01:04 -0800 | [diff] [blame] | 179 | const char Metrics::kMetricWakeOnWiFiFeaturesEnabledState[] = |
Samuel Tan | 3294d46 | 2014-11-18 17:24:09 -0800 | [diff] [blame] | 180 | "Network.Shill.WiFi.WakeOnWiFiFeaturesEnabledState"; |
Samuel Tan | a493343 | 2015-02-06 18:20:41 -0800 | [diff] [blame] | 181 | const char Metrics::kMetricVerifyWakeOnWiFiSettingsResult[] = |
| 182 | "Network.Shill.WiFi.VerifyWakeOnWiFiSettingsResult"; |
| 183 | const char Metrics::kMetricWiFiConnectionStatusAfterWake[] = |
| 184 | "Network.Shill.WiFi.WiFiConnectionStatusAfterWake"; |
| 185 | const char Metrics::kMetricWakeOnWiFiThrottled[] = |
| 186 | "Network.Shill.WiFi.WakeOnWiFiThrottled"; |
| 187 | const char Metrics::kMetricWakeReasonReceivedBeforeOnDarkResume[] = |
| 188 | "Network.Shill.WiFi.WakeReasonReceivedBeforeOnDarkResume"; |
| 189 | const char Metrics::kMetricDarkResumeWakeReason[] = |
| 190 | "Network.Shill.WiFi.DarkResumeWakeReason"; |
Samuel Tan | d1bec5d | 2015-03-06 12:49:02 -0800 | [diff] [blame] | 191 | const char Metrics::kMetricDarkResumeScanType[] = |
| 192 | "Network.Shill.WiFi.DarkResumeScanType"; |
Samuel Tan | 029feac | 2015-03-27 16:53:01 -0700 | [diff] [blame] | 193 | const char Metrics::kMetricDarkResumeScanRetryResult[] = |
| 194 | "Network.Shill.WiFi.DarkResumeScanRetryResult"; |
| 195 | const char Metrics::kMetricDarkResumeScanNumRetries[] = |
| 196 | "Network.Shill.WiFi.DarkResumeScanNumRetries"; |
| 197 | const int Metrics::kMetricDarkResumeScanNumRetriesMax = 20; |
| 198 | const int Metrics::kMetricDarkResumeScanNumRetriesMin = 0; |
Samuel Tan | 66bddc6 | 2014-11-13 20:01:04 -0800 | [diff] [blame] | 199 | |
Thieu Le | 48e6d6d | 2011-12-06 00:40:27 +0000 | [diff] [blame] | 200 | // static |
mukesh agrawal | 132e96f | 2014-04-24 11:49:42 -0700 | [diff] [blame] | 201 | const char Metrics::kMetricServiceFixupEntriesSuffix[] = "ServiceFixupEntries"; |
Paul Stewart | 85aea15 | 2013-01-22 09:31:56 -0800 | [diff] [blame] | 202 | |
| 203 | // static |
Ben Chan | 7fab897 | 2014-08-10 17:14:46 -0700 | [diff] [blame] | 204 | const uint16_t Metrics::kWiFiBandwidth5MHz = 5; |
| 205 | const uint16_t Metrics::kWiFiBandwidth20MHz = 20; |
| 206 | const uint16_t Metrics::kWiFiFrequency2412 = 2412; |
| 207 | const uint16_t Metrics::kWiFiFrequency2472 = 2472; |
| 208 | const uint16_t Metrics::kWiFiFrequency2484 = 2484; |
| 209 | const uint16_t Metrics::kWiFiFrequency5170 = 5170; |
| 210 | const uint16_t Metrics::kWiFiFrequency5180 = 5180; |
| 211 | const uint16_t Metrics::kWiFiFrequency5230 = 5230; |
| 212 | const uint16_t Metrics::kWiFiFrequency5240 = 5240; |
| 213 | const uint16_t Metrics::kWiFiFrequency5320 = 5320; |
| 214 | const uint16_t Metrics::kWiFiFrequency5500 = 5500; |
| 215 | const uint16_t Metrics::kWiFiFrequency5700 = 5700; |
| 216 | const uint16_t Metrics::kWiFiFrequency5745 = 5745; |
| 217 | const uint16_t Metrics::kWiFiFrequency5825 = 5825; |
Thieu Le | 48e6d6d | 2011-12-06 00:40:27 +0000 | [diff] [blame] | 218 | |
Thieu Le | b84ba34 | 2012-03-02 15:15:19 -0800 | [diff] [blame] | 219 | // static |
| 220 | const char Metrics::kMetricPowerManagerKey[] = "metrics"; |
| 221 | |
Paul Stewart | ff845fc | 2012-08-07 07:28:44 -0700 | [diff] [blame] | 222 | // static |
mukesh agrawal | 132e96f | 2014-04-24 11:49:42 -0700 | [diff] [blame] | 223 | const char Metrics::kMetricLinkMonitorFailureSuffix[] = "LinkMonitorFailure"; |
| 224 | const char Metrics::kMetricLinkMonitorResponseTimeSampleSuffix[] = |
| 225 | "LinkMonitorResponseTimeSample"; |
Paul Stewart | f1961f8 | 2012-09-11 20:45:39 -0700 | [diff] [blame] | 226 | const int Metrics::kMetricLinkMonitorResponseTimeSampleMin = 0; |
| 227 | const int Metrics::kMetricLinkMonitorResponseTimeSampleMax = |
mukesh agrawal | bb2231c | 2013-07-17 16:32:24 -0700 | [diff] [blame] | 228 | LinkMonitor::kDefaultTestPeriodMilliseconds; |
Paul Stewart | ff845fc | 2012-08-07 07:28:44 -0700 | [diff] [blame] | 229 | const int Metrics::kMetricLinkMonitorResponseTimeSampleNumBuckets = 50; |
mukesh agrawal | 132e96f | 2014-04-24 11:49:42 -0700 | [diff] [blame] | 230 | const char Metrics::kMetricLinkMonitorSecondsToFailureSuffix[] = |
| 231 | "LinkMonitorSecondsToFailure"; |
Paul Stewart | f1961f8 | 2012-09-11 20:45:39 -0700 | [diff] [blame] | 232 | const int Metrics::kMetricLinkMonitorSecondsToFailureMin = 0; |
| 233 | const int Metrics::kMetricLinkMonitorSecondsToFailureMax = 7200; |
Paul Stewart | 0443aa5 | 2012-08-09 10:43:50 -0700 | [diff] [blame] | 234 | const int Metrics::kMetricLinkMonitorSecondsToFailureNumBuckets = 50; |
mukesh agrawal | 132e96f | 2014-04-24 11:49:42 -0700 | [diff] [blame] | 235 | const char Metrics::kMetricLinkMonitorBroadcastErrorsAtFailureSuffix[] = |
| 236 | "LinkMonitorBroadcastErrorsAtFailure"; |
| 237 | const char Metrics::kMetricLinkMonitorUnicastErrorsAtFailureSuffix[] = |
| 238 | "LinkMonitorUnicastErrorsAtFailure"; |
Paul Stewart | f1961f8 | 2012-09-11 20:45:39 -0700 | [diff] [blame] | 239 | const int Metrics::kMetricLinkMonitorErrorCountMin = 0; |
| 240 | const int Metrics::kMetricLinkMonitorErrorCountMax = |
Paul Stewart | 0443aa5 | 2012-08-09 10:43:50 -0700 | [diff] [blame] | 241 | LinkMonitor::kFailureThreshold; |
| 242 | const int Metrics::kMetricLinkMonitorErrorCountNumBuckets = |
| 243 | LinkMonitor::kFailureThreshold + 1; |
Paul Stewart | ff845fc | 2012-08-07 07:28:44 -0700 | [diff] [blame] | 244 | |
Wade Guthrie | d4977f2 | 2012-08-22 12:37:54 -0700 | [diff] [blame] | 245 | // static |
| 246 | const char Metrics::kMetricLinkClientDisconnectReason[] = |
| 247 | "Network.Shill.WiFi.ClientDisconnectReason"; |
| 248 | const char Metrics::kMetricLinkApDisconnectReason[] = |
| 249 | "Network.Shill.WiFi.ApDisconnectReason"; |
| 250 | const char Metrics::kMetricLinkClientDisconnectType[] = |
| 251 | "Network.Shill.WiFi.ClientDisconnectType"; |
| 252 | const char Metrics::kMetricLinkApDisconnectType[] = |
| 253 | "Network.Shill.WiFi.ApDisconnectType"; |
| 254 | |
Thieu Le | 26fc01b | 2013-01-28 12:08:48 -0800 | [diff] [blame] | 255 | // static |
Prathmesh Prabhu | 08757aa | 2013-05-15 17:17:33 -0700 | [diff] [blame] | 256 | const char Metrics::kMetricCellular3GPPRegistrationDelayedDrop[] = |
| 257 | "Network.Shill.Cellular.3GPPRegistrationDelayedDrop"; |
Thieu Le | 91fccf6 | 2013-04-22 15:23:16 -0700 | [diff] [blame] | 258 | const char Metrics::kMetricCellularAutoConnectTries[] = |
| 259 | "Network.Shill.Cellular.AutoConnectTries"; |
| 260 | const int Metrics::kMetricCellularAutoConnectTriesMax = 20; |
| 261 | const int Metrics::kMetricCellularAutoConnectTriesMin = 1; |
| 262 | const int Metrics::kMetricCellularAutoConnectTriesNumBuckets = 20; |
| 263 | const char Metrics::kMetricCellularAutoConnectTotalTime[] = |
| 264 | "Network.Shill.Cellular.AutoConnectTotalTime"; |
| 265 | const int Metrics::kMetricCellularAutoConnectTotalTimeMax = |
| 266 | 60 * 1000; // 60 seconds |
| 267 | const int Metrics::kMetricCellularAutoConnectTotalTimeMin = 0; |
| 268 | const int Metrics::kMetricCellularAutoConnectTotalTimeNumBuckets = 60; |
Thieu Le | 26fc01b | 2013-01-28 12:08:48 -0800 | [diff] [blame] | 269 | const char Metrics::kMetricCellularDrop[] = |
| 270 | "Network.Shill.Cellular.Drop"; |
Thieu Le | b7aa5f7 | 2013-01-31 15:57:48 -0800 | [diff] [blame] | 271 | // The format of FailureReason is different to other metrics because this |
| 272 | // name is prepended to the error message before the entire string is sent |
| 273 | // via SendUserActionToUMA. |
| 274 | const char Metrics::kMetricCellularFailureReason[] = |
| 275 | "Network.Shill.Cellular.FailureReason: "; |
Thieu Le | 91fccf6 | 2013-04-22 15:23:16 -0700 | [diff] [blame] | 276 | const char Metrics::kMetricCellularOutOfCreditsReason[] = |
| 277 | "Network.Shill.Cellular.OutOfCreditsReason"; |
Thieu Le | 26fc01b | 2013-01-28 12:08:48 -0800 | [diff] [blame] | 278 | const char Metrics::kMetricCellularSignalStrengthBeforeDrop[] = |
| 279 | "Network.Shill.Cellular.SignalStrengthBeforeDrop"; |
| 280 | const int Metrics::kMetricCellularSignalStrengthBeforeDropMax = 100; |
| 281 | const int Metrics::kMetricCellularSignalStrengthBeforeDropMin = 0; |
| 282 | const int Metrics::kMetricCellularSignalStrengthBeforeDropNumBuckets = 10; |
| 283 | |
Thieu Le | 6c1e3bb | 2013-02-06 15:20:35 -0800 | [diff] [blame] | 284 | // static |
Thieu Le | 5133b71 | 2013-02-19 14:47:21 -0800 | [diff] [blame] | 285 | const char Metrics::kMetricCorruptedProfile[] = |
| 286 | "Network.Shill.CorruptedProfile"; |
| 287 | |
| 288 | // static |
Paul Stewart | 91a43cb | 2013-03-02 21:34:15 -0800 | [diff] [blame] | 289 | const char Metrics::kMetricVpnDriver[] = |
| 290 | "Network.Shill.Vpn.Driver"; |
| 291 | const int Metrics::kMetricVpnDriverMax = Metrics::kVpnDriverMax; |
| 292 | const char Metrics::kMetricVpnRemoteAuthenticationType[] = |
| 293 | "Network.Shill.Vpn.RemoteAuthenticationType"; |
| 294 | const int Metrics::kMetricVpnRemoteAuthenticationTypeMax = |
| 295 | Metrics::kVpnRemoteAuthenticationTypeMax; |
| 296 | const char Metrics::kMetricVpnUserAuthenticationType[] = |
| 297 | "Network.Shill.Vpn.UserAuthenticationType"; |
| 298 | const int Metrics::kMetricVpnUserAuthenticationTypeMax = |
| 299 | Metrics::kVpnUserAuthenticationTypeMax; |
| 300 | |
mukesh agrawal | 132e96f | 2014-04-24 11:49:42 -0700 | [diff] [blame] | 301 | const char Metrics::kMetricExpiredLeaseLengthSecondsSuffix[] = |
| 302 | "ExpiredLeaseLengthSeconds"; |
Paul Stewart | 1f916e4 | 2013-12-23 09:52:54 -0800 | [diff] [blame] | 303 | const int Metrics::kMetricExpiredLeaseLengthSecondsMax = |
| 304 | 7 * 24 * 60 * 60; // 7 days |
| 305 | const int Metrics::kMetricExpiredLeaseLengthSecondsMin = 1; |
| 306 | const int Metrics::kMetricExpiredLeaseLengthSecondsNumBuckets = |
| 307 | Metrics::kMetricExpiredLeaseLengthSecondsMax; |
| 308 | |
Peter Qiu | 574996a | 2014-04-04 10:55:47 -0700 | [diff] [blame] | 309 | // static |
| 310 | const char Metrics::kMetricWifiAutoConnectableServices[] = |
Peter Qiu | 0dd90df | 2014-04-29 14:09:13 -0700 | [diff] [blame] | 311 | "Network.Shill.WiFi.AutoConnectableServices"; |
Peter Qiu | 574996a | 2014-04-04 10:55:47 -0700 | [diff] [blame] | 312 | const int Metrics::kMetricWifiAutoConnectableServicesMax = 50; |
| 313 | const int Metrics::kMetricWifiAutoConnectableServicesMin = 1; |
| 314 | const int Metrics::kMetricWifiAutoConnectableServicesNumBuckets = 10; |
| 315 | |
| 316 | // static |
| 317 | const char Metrics::kMetricWifiAvailableBSSes[] = |
Peter Qiu | 0dd90df | 2014-04-29 14:09:13 -0700 | [diff] [blame] | 318 | "Network.Shill.WiFi.AvailableBSSesAtConnect"; |
Peter Qiu | 574996a | 2014-04-04 10:55:47 -0700 | [diff] [blame] | 319 | const int Metrics::kMetricWifiAvailableBSSesMax = 50; |
| 320 | const int Metrics::kMetricWifiAvailableBSSesMin = 1; |
| 321 | const int Metrics::kMetricWifiAvailableBSSesNumBuckets = 10; |
| 322 | |
mukesh agrawal | f734873 | 2014-08-06 18:08:56 -0700 | [diff] [blame] | 323 | // static |
| 324 | const char Metrics::kMetricWifiStoppedTxQueueReason[] = |
| 325 | "Network.Shill.WiFi.StoppedTxQueueReason"; |
| 326 | // Values are defined in mac80211_monitor.h. |
| 327 | |
| 328 | // static |
| 329 | const char Metrics::kMetricWifiStoppedTxQueueLength[] = |
| 330 | "Network.Shill.WiFi.StoppedTxQueueLength"; |
| 331 | const int Metrics::kMetricWifiStoppedTxQueueLengthMax = 10000; |
| 332 | const int Metrics::kMetricWifiStoppedTxQueueLengthMin = 1; |
| 333 | const int Metrics::kMetricWifiStoppedTxQueueLengthNumBuckets = 50; |
| 334 | |
Peter Qiu | 39d4af0 | 2014-04-14 12:24:01 -0700 | [diff] [blame] | 335 | // Number of services associated with currently connected network. |
| 336 | const char Metrics::kMetricServicesOnSameNetwork[] = |
| 337 | "Network.Shill.ServicesOnSameNetwork"; |
| 338 | const int Metrics::kMetricServicesOnSameNetworkMax = 20; |
| 339 | const int Metrics::kMetricServicesOnSameNetworkMin = 1; |
| 340 | const int Metrics::kMetricServicesOnSameNetworkNumBuckets = 10; |
| 341 | |
Peter Qiu | e783f1c | 2014-05-02 11:42:33 -0700 | [diff] [blame] | 342 | // static |
| 343 | const char Metrics::kMetricUserInitiatedEvents[] = |
Peter Qiu | dc4e099 | 2014-05-01 10:02:52 -0700 | [diff] [blame] | 344 | "Network.Shill.UserInitiatedEvents"; |
Peter Qiu | e783f1c | 2014-05-02 11:42:33 -0700 | [diff] [blame] | 345 | |
Peter Qiu | b9256f3 | 2014-05-09 15:27:29 -0700 | [diff] [blame] | 346 | // static |
Peter Qiu | 8e43058 | 2014-04-30 14:12:37 -0700 | [diff] [blame] | 347 | const char Metrics::kMetricWifiTxBitrate[] = |
| 348 | "Network.Shill.WiFi.TransmitBitrateMbps"; |
| 349 | const int Metrics::kMetricWifiTxBitrateMax = 7000; |
| 350 | const int Metrics::kMetricWifiTxBitrateMin = 1; |
| 351 | const int Metrics::kMetricWifiTxBitrateNumBuckets = 100; |
| 352 | |
Peter Qiu | b9256f3 | 2014-05-09 15:27:29 -0700 | [diff] [blame] | 353 | // static |
Peter Qiu | dc4e099 | 2014-05-01 10:02:52 -0700 | [diff] [blame] | 354 | const char Metrics::kMetricWifiUserInitiatedConnectionResult[] = |
| 355 | "Network.Shill.WiFi.UserInitiatedConnectionResult"; |
| 356 | |
Peter Qiu | b9256f3 | 2014-05-09 15:27:29 -0700 | [diff] [blame] | 357 | // static |
Peter Qiu | d87179e | 2014-07-10 18:29:22 -0700 | [diff] [blame] | 358 | const char Metrics::kMetricWifiUserInitiatedConnectionFailureReason[] = |
| 359 | "Network.Shill.WiFi.UserInitiatedConnectionFailureReason"; |
| 360 | |
| 361 | // static |
Peter Qiu | f18e771 | 2014-05-20 09:59:46 -0700 | [diff] [blame] | 362 | const char Metrics::kMetricFallbackDNSTestResultSuffix[] = |
| 363 | "FallbackDNSTestResult"; |
Peter Qiu | b9256f3 | 2014-05-09 15:27:29 -0700 | [diff] [blame] | 364 | |
Peter Qiu | dc335f8 | 2014-05-15 10:33:17 -0700 | [diff] [blame] | 365 | // static |
| 366 | const char Metrics::kMetricNetworkProblemDetectedSuffix[] = |
| 367 | "NetworkProblemDetected"; |
| 368 | |
Peter Qiu | 700de64 | 2014-07-14 16:31:30 -0700 | [diff] [blame] | 369 | // static |
| 370 | const char Metrics::kMetricDeviceConnectionStatus[] = |
| 371 | "Network.Shill.DeviceConnectionStatus"; |
| 372 | |
Paul Stewart | 3bdf1ab | 2014-07-17 19:22:26 -0700 | [diff] [blame] | 373 | // static |
| 374 | const char Metrics::kMetricDhcpClientStatus[] = |
Paul Stewart | a72a79c | 2014-07-21 13:52:03 -0700 | [diff] [blame] | 375 | "Network.Shill.DHCPClientStatus"; |
Paul Stewart | 3bdf1ab | 2014-07-17 19:22:26 -0700 | [diff] [blame] | 376 | |
Peter Qiu | 300769e | 2014-08-27 11:48:45 -0700 | [diff] [blame] | 377 | // static |
| 378 | const char Metrics::kMetricNetworkConnectionIPTypeSuffix[] = |
| 379 | "NetworkConnectionIPType"; |
| 380 | |
| 381 | // static |
| 382 | const char Metrics::kMetricIPv6ConnectivityStatusSuffix[] = |
| 383 | "IPv6ConnectivityStatus"; |
| 384 | |
Peter Qiu | 94d18af | 2014-09-11 15:54:15 -0700 | [diff] [blame] | 385 | // static |
| 386 | const char Metrics::kMetricDevicePresenceStatusSuffix[] = |
| 387 | "DevicePresenceStatus"; |
| 388 | |
Peter Qiu | 9f5159e | 2014-09-12 16:50:14 -0700 | [diff] [blame] | 389 | // static |
| 390 | const char Metrics::kMetricDeviceRemovedEvent[] = |
| 391 | "Network.Shill.DeviceRemovedEvent"; |
| 392 | |
Samuel Tan | a493343 | 2015-02-06 18:20:41 -0800 | [diff] [blame] | 393 | // static |
| 394 | const char Metrics::kMetricUnreliableLinkSignalStrengthSuffix[] = |
| 395 | "UnreliableLinkSignalStrength"; |
Peter Qiu | a057203 | 2014-09-26 10:07:37 -0700 | [diff] [blame] | 396 | const int Metrics::kMetricSerivceSignalStrengthMin = 0; |
| 397 | const int Metrics::kMetricServiceSignalStrengthMax = 100; |
| 398 | const int Metrics::kMetricServiceSignalStrengthNumBuckets = 40; |
| 399 | |
Paul Stewart | 8ae1874 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 400 | Metrics::Metrics(EventDispatcher* dispatcher) |
Thieu Le | 6c1e3bb | 2013-02-06 15:20:35 -0800 | [diff] [blame] | 401 | : dispatcher_(dispatcher), |
| 402 | library_(&metrics_library_), |
Thieu Le | a20cbc2 | 2012-01-09 22:01:43 +0000 | [diff] [blame] | 403 | last_default_technology_(Technology::kUnknown), |
| 404 | was_online_(false), |
| 405 | time_online_timer_(new chromeos_metrics::Timer), |
Thieu Le | b84ba34 | 2012-03-02 15:15:19 -0800 | [diff] [blame] | 406 | time_to_drop_timer_(new chromeos_metrics::Timer), |
Darin Petkov | 58f0b6d | 2012-06-12 12:52:30 +0200 | [diff] [blame] | 407 | time_resume_to_ready_timer_(new chromeos_metrics::Timer), |
Arman Uguray | ab22c16 | 2012-10-08 19:08:38 -0700 | [diff] [blame] | 408 | time_termination_actions_timer(new chromeos_metrics::Timer), |
Samuel Tan | fbe8d2b | 2014-09-15 20:23:59 -0700 | [diff] [blame] | 409 | time_suspend_actions_timer(new chromeos_metrics::Timer), |
Samuel Tan | 68b73d2 | 2014-10-28 17:00:56 -0700 | [diff] [blame] | 410 | time_dark_resume_actions_timer(new chromeos_metrics::Timer), |
Samuel Tan | 0e0ac0d | 2014-12-29 16:03:42 -0800 | [diff] [blame] | 411 | collect_bootstats_(true), |
Samuel Tan | c36b410 | 2015-01-26 19:34:35 -0800 | [diff] [blame] | 412 | num_scan_results_expected_in_dark_resume_(0), |
Samuel Tan | a493343 | 2015-02-06 18:20:41 -0800 | [diff] [blame] | 413 | wake_on_wifi_throttled_(false), |
Samuel Tan | 029feac | 2015-03-27 16:53:01 -0700 | [diff] [blame] | 414 | wake_reason_received_(false), |
| 415 | dark_resume_scan_retries_(0) { |
Thieu Le | 48e6d6d | 2011-12-06 00:40:27 +0000 | [diff] [blame] | 416 | metrics_library_.Init(); |
| 417 | chromeos_metrics::TimerReporter::set_metrics_lib(library_); |
| 418 | } |
| 419 | |
| 420 | Metrics::~Metrics() {} |
| 421 | |
| 422 | // static |
Ben Chan | 7fab897 | 2014-08-10 17:14:46 -0700 | [diff] [blame] | 423 | Metrics::WiFiChannel Metrics::WiFiFrequencyToChannel(uint16_t frequency) { |
Thieu Le | 48e6d6d | 2011-12-06 00:40:27 +0000 | [diff] [blame] | 424 | WiFiChannel channel = kWiFiChannelUndef; |
| 425 | if (kWiFiFrequency2412 <= frequency && frequency <= kWiFiFrequency2472) { |
| 426 | if (((frequency - kWiFiFrequency2412) % kWiFiBandwidth5MHz) == 0) |
| 427 | channel = static_cast<WiFiChannel>( |
| 428 | kWiFiChannel2412 + |
| 429 | (frequency - kWiFiFrequency2412) / kWiFiBandwidth5MHz); |
| 430 | } else if (frequency == kWiFiFrequency2484) { |
| 431 | channel = kWiFiChannel2484; |
| 432 | } else if (kWiFiFrequency5170 <= frequency && |
| 433 | frequency <= kWiFiFrequency5230) { |
| 434 | if ((frequency % kWiFiBandwidth20MHz) == 0) |
| 435 | channel = static_cast<WiFiChannel>( |
| 436 | kWiFiChannel5180 + |
| 437 | (frequency - kWiFiFrequency5180) / kWiFiBandwidth20MHz); |
| 438 | if ((frequency % kWiFiBandwidth20MHz) == 10) |
| 439 | channel = static_cast<WiFiChannel>( |
| 440 | kWiFiChannel5170 + |
| 441 | (frequency - kWiFiFrequency5170) / kWiFiBandwidth20MHz); |
| 442 | } else if (kWiFiFrequency5240 <= frequency && |
| 443 | frequency <= kWiFiFrequency5320) { |
| 444 | if (((frequency - kWiFiFrequency5180) % kWiFiBandwidth20MHz) == 0) |
| 445 | channel = static_cast<WiFiChannel>( |
| 446 | kWiFiChannel5180 + |
| 447 | (frequency - kWiFiFrequency5180) / kWiFiBandwidth20MHz); |
| 448 | } else if (kWiFiFrequency5500 <= frequency && |
| 449 | frequency <= kWiFiFrequency5700) { |
| 450 | if (((frequency - kWiFiFrequency5500) % kWiFiBandwidth20MHz) == 0) |
| 451 | channel = static_cast<WiFiChannel>( |
| 452 | kWiFiChannel5500 + |
| 453 | (frequency - kWiFiFrequency5500) / kWiFiBandwidth20MHz); |
| 454 | } else if (kWiFiFrequency5745 <= frequency && |
| 455 | frequency <= kWiFiFrequency5825) { |
| 456 | if (((frequency - kWiFiFrequency5745) % kWiFiBandwidth20MHz) == 0) |
| 457 | channel = static_cast<WiFiChannel>( |
| 458 | kWiFiChannel5745 + |
| 459 | (frequency - kWiFiFrequency5745) / kWiFiBandwidth20MHz); |
| 460 | } |
| 461 | CHECK(kWiFiChannelUndef <= channel && channel < kWiFiChannelMax); |
| 462 | |
| 463 | if (channel == kWiFiChannelUndef) |
| 464 | LOG(WARNING) << "no mapping for frequency " << frequency; |
| 465 | else |
Rebecca Silberstein | c9c31d8 | 2014-10-21 15:01:00 -0700 | [diff] [blame] | 466 | SLOG(nullptr, 3) << "mapped frequency " << frequency |
| 467 | << " to enum bucket " << channel; |
Thieu Le | 48e6d6d | 2011-12-06 00:40:27 +0000 | [diff] [blame] | 468 | |
| 469 | return channel; |
| 470 | } |
| 471 | |
Thieu Le | ad1ec2c | 2012-01-05 23:39:48 +0000 | [diff] [blame] | 472 | // static |
| 473 | Metrics::WiFiSecurity Metrics::WiFiSecurityStringToEnum( |
Paul Stewart | 8ae1874 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 474 | const string& security) { |
Ben Chan | 923a502 | 2013-09-20 11:23:23 -0700 | [diff] [blame] | 475 | if (security == kSecurityNone) { |
Thieu Le | ad1ec2c | 2012-01-05 23:39:48 +0000 | [diff] [blame] | 476 | return kWiFiSecurityNone; |
Ben Chan | 923a502 | 2013-09-20 11:23:23 -0700 | [diff] [blame] | 477 | } else if (security == kSecurityWep) { |
Thieu Le | ad1ec2c | 2012-01-05 23:39:48 +0000 | [diff] [blame] | 478 | return kWiFiSecurityWep; |
Ben Chan | 923a502 | 2013-09-20 11:23:23 -0700 | [diff] [blame] | 479 | } else if (security == kSecurityWpa) { |
Thieu Le | ad1ec2c | 2012-01-05 23:39:48 +0000 | [diff] [blame] | 480 | return kWiFiSecurityWpa; |
Ben Chan | 923a502 | 2013-09-20 11:23:23 -0700 | [diff] [blame] | 481 | } else if (security == kSecurityRsn) { |
Thieu Le | ad1ec2c | 2012-01-05 23:39:48 +0000 | [diff] [blame] | 482 | return kWiFiSecurityRsn; |
Ben Chan | 923a502 | 2013-09-20 11:23:23 -0700 | [diff] [blame] | 483 | } else if (security == kSecurity8021x) { |
Thieu Le | ad1ec2c | 2012-01-05 23:39:48 +0000 | [diff] [blame] | 484 | return kWiFiSecurity8021x; |
Ben Chan | 923a502 | 2013-09-20 11:23:23 -0700 | [diff] [blame] | 485 | } else if (security == kSecurityPsk) { |
Thieu Le | ad1ec2c | 2012-01-05 23:39:48 +0000 | [diff] [blame] | 486 | return kWiFiSecurityPsk; |
| 487 | } else { |
| 488 | return kWiFiSecurityUnknown; |
| 489 | } |
| 490 | } |
| 491 | |
Thieu Le | 85e050b | 2012-03-13 15:04:38 -0700 | [diff] [blame] | 492 | // static |
Paul Stewart | 8ae1874 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 493 | Metrics::WiFiApMode Metrics::WiFiApModeStringToEnum(const string& ap_mode) { |
Ben Chan | 923a502 | 2013-09-20 11:23:23 -0700 | [diff] [blame] | 494 | if (ap_mode == kModeManaged) { |
Paul Stewart | e4cedde | 2013-07-17 08:56:44 -0700 | [diff] [blame] | 495 | return kWiFiApModeManaged; |
Ben Chan | 923a502 | 2013-09-20 11:23:23 -0700 | [diff] [blame] | 496 | } else if (ap_mode == kModeAdhoc) { |
Paul Stewart | e4cedde | 2013-07-17 08:56:44 -0700 | [diff] [blame] | 497 | return kWiFiApModeAdHoc; |
| 498 | } else { |
| 499 | return kWiFiApModeUnknown; |
| 500 | } |
| 501 | } |
| 502 | |
| 503 | // static |
Paul Stewart | 21f4096 | 2013-03-01 14:27:28 -0800 | [diff] [blame] | 504 | Metrics::EapOuterProtocol Metrics::EapOuterProtocolStringToEnum( |
Paul Stewart | 8ae1874 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 505 | const string& outer) { |
Ben Chan | 923a502 | 2013-09-20 11:23:23 -0700 | [diff] [blame] | 506 | if (outer == kEapMethodPEAP) { |
Paul Stewart | 21f4096 | 2013-03-01 14:27:28 -0800 | [diff] [blame] | 507 | return kEapOuterProtocolPeap; |
Ben Chan | 923a502 | 2013-09-20 11:23:23 -0700 | [diff] [blame] | 508 | } else if (outer == kEapMethodTLS) { |
Paul Stewart | 21f4096 | 2013-03-01 14:27:28 -0800 | [diff] [blame] | 509 | return kEapOuterProtocolTls; |
Ben Chan | 923a502 | 2013-09-20 11:23:23 -0700 | [diff] [blame] | 510 | } else if (outer == kEapMethodTTLS) { |
Paul Stewart | 21f4096 | 2013-03-01 14:27:28 -0800 | [diff] [blame] | 511 | return kEapOuterProtocolTtls; |
Ben Chan | 923a502 | 2013-09-20 11:23:23 -0700 | [diff] [blame] | 512 | } else if (outer == kEapMethodLEAP) { |
Paul Stewart | 21f4096 | 2013-03-01 14:27:28 -0800 | [diff] [blame] | 513 | return kEapOuterProtocolLeap; |
| 514 | } else { |
| 515 | return kEapOuterProtocolUnknown; |
| 516 | } |
| 517 | } |
| 518 | |
| 519 | // static |
| 520 | Metrics::EapInnerProtocol Metrics::EapInnerProtocolStringToEnum( |
Paul Stewart | 8ae1874 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 521 | const string& inner) { |
Paul Stewart | 21f4096 | 2013-03-01 14:27:28 -0800 | [diff] [blame] | 522 | if (inner.empty()) { |
| 523 | return kEapInnerProtocolNone; |
Ben Chan | 923a502 | 2013-09-20 11:23:23 -0700 | [diff] [blame] | 524 | } else if (inner == kEapPhase2AuthPEAPMD5) { |
Paul Stewart | 21f4096 | 2013-03-01 14:27:28 -0800 | [diff] [blame] | 525 | return kEapInnerProtocolPeapMd5; |
Ben Chan | 923a502 | 2013-09-20 11:23:23 -0700 | [diff] [blame] | 526 | } else if (inner == kEapPhase2AuthPEAPMSCHAPV2) { |
Paul Stewart | 21f4096 | 2013-03-01 14:27:28 -0800 | [diff] [blame] | 527 | return kEapInnerProtocolPeapMschapv2; |
Ben Chan | 923a502 | 2013-09-20 11:23:23 -0700 | [diff] [blame] | 528 | } else if (inner == kEapPhase2AuthTTLSEAPMD5) { |
Paul Stewart | 21f4096 | 2013-03-01 14:27:28 -0800 | [diff] [blame] | 529 | return kEapInnerProtocolTtlsEapMd5; |
Ben Chan | 923a502 | 2013-09-20 11:23:23 -0700 | [diff] [blame] | 530 | } else if (inner == kEapPhase2AuthTTLSEAPMSCHAPV2) { |
Paul Stewart | 21f4096 | 2013-03-01 14:27:28 -0800 | [diff] [blame] | 531 | return kEapInnerProtocolTtlsEapMschapv2; |
Ben Chan | 923a502 | 2013-09-20 11:23:23 -0700 | [diff] [blame] | 532 | } else if (inner == kEapPhase2AuthTTLSMSCHAPV2) { |
Paul Stewart | 21f4096 | 2013-03-01 14:27:28 -0800 | [diff] [blame] | 533 | return kEapInnerProtocolTtlsMschapv2; |
Ben Chan | 923a502 | 2013-09-20 11:23:23 -0700 | [diff] [blame] | 534 | } else if (inner == kEapPhase2AuthTTLSMSCHAP) { |
Paul Stewart | 21f4096 | 2013-03-01 14:27:28 -0800 | [diff] [blame] | 535 | return kEapInnerProtocolTtlsMschap; |
Ben Chan | 923a502 | 2013-09-20 11:23:23 -0700 | [diff] [blame] | 536 | } else if (inner == kEapPhase2AuthTTLSPAP) { |
Paul Stewart | 21f4096 | 2013-03-01 14:27:28 -0800 | [diff] [blame] | 537 | return kEapInnerProtocolTtlsPap; |
Ben Chan | 923a502 | 2013-09-20 11:23:23 -0700 | [diff] [blame] | 538 | } else if (inner == kEapPhase2AuthTTLSCHAP) { |
Paul Stewart | 21f4096 | 2013-03-01 14:27:28 -0800 | [diff] [blame] | 539 | return kEapInnerProtocolTtlsChap; |
| 540 | } else { |
| 541 | return kEapInnerProtocolUnknown; |
| 542 | } |
| 543 | } |
| 544 | |
| 545 | // static |
Thieu Le | 85e050b | 2012-03-13 15:04:38 -0700 | [diff] [blame] | 546 | Metrics::PortalResult Metrics::PortalDetectionResultToEnum( |
Paul Stewart | 8ae1874 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 547 | const PortalDetector::Result& portal_result) { |
Rebecca Silberstein | 3d49ea4 | 2014-08-21 11:20:50 -0700 | [diff] [blame] | 548 | DCHECK(portal_result.final); |
Thieu Le | 85e050b | 2012-03-13 15:04:38 -0700 | [diff] [blame] | 549 | PortalResult retval = kPortalResultUnknown; |
Rebecca Silberstein | 3d49ea4 | 2014-08-21 11:20:50 -0700 | [diff] [blame] | 550 | ConnectivityTrial::Result result = portal_result.trial_result; |
Thieu Le | 85e050b | 2012-03-13 15:04:38 -0700 | [diff] [blame] | 551 | // The only time we should end a successful portal detection is when we're |
| 552 | // in the Content phase. If we end with kStatusSuccess in any other phase, |
| 553 | // then this indicates that something bad has happened. |
| 554 | switch (result.phase) { |
Rebecca Silberstein | 3d49ea4 | 2014-08-21 11:20:50 -0700 | [diff] [blame] | 555 | case ConnectivityTrial::kPhaseDNS: |
| 556 | if (result.status == ConnectivityTrial::kStatusFailure) |
Thieu Le | 85e050b | 2012-03-13 15:04:38 -0700 | [diff] [blame] | 557 | retval = kPortalResultDNSFailure; |
Rebecca Silberstein | 3d49ea4 | 2014-08-21 11:20:50 -0700 | [diff] [blame] | 558 | else if (result.status == ConnectivityTrial::kStatusTimeout) |
Thieu Le | 85e050b | 2012-03-13 15:04:38 -0700 | [diff] [blame] | 559 | retval = kPortalResultDNSTimeout; |
| 560 | else |
| 561 | LOG(DFATAL) << __func__ << ": Final result status " << result.status |
| 562 | << " is not allowed in the DNS phase"; |
| 563 | break; |
| 564 | |
Rebecca Silberstein | 3d49ea4 | 2014-08-21 11:20:50 -0700 | [diff] [blame] | 565 | case ConnectivityTrial::kPhaseConnection: |
| 566 | if (result.status == ConnectivityTrial::kStatusFailure) |
Thieu Le | 85e050b | 2012-03-13 15:04:38 -0700 | [diff] [blame] | 567 | retval = kPortalResultConnectionFailure; |
Rebecca Silberstein | 3d49ea4 | 2014-08-21 11:20:50 -0700 | [diff] [blame] | 568 | else if (result.status == ConnectivityTrial::kStatusTimeout) |
Thieu Le | 85e050b | 2012-03-13 15:04:38 -0700 | [diff] [blame] | 569 | retval = kPortalResultConnectionTimeout; |
| 570 | else |
| 571 | LOG(DFATAL) << __func__ << ": Final result status " << result.status |
| 572 | << " is not allowed in the Connection phase"; |
| 573 | break; |
| 574 | |
Rebecca Silberstein | 3d49ea4 | 2014-08-21 11:20:50 -0700 | [diff] [blame] | 575 | case ConnectivityTrial::kPhaseHTTP: |
| 576 | if (result.status == ConnectivityTrial::kStatusFailure) |
Thieu Le | 85e050b | 2012-03-13 15:04:38 -0700 | [diff] [blame] | 577 | retval = kPortalResultHTTPFailure; |
Rebecca Silberstein | 3d49ea4 | 2014-08-21 11:20:50 -0700 | [diff] [blame] | 578 | else if (result.status == ConnectivityTrial::kStatusTimeout) |
Thieu Le | 85e050b | 2012-03-13 15:04:38 -0700 | [diff] [blame] | 579 | retval = kPortalResultHTTPTimeout; |
| 580 | else |
| 581 | LOG(DFATAL) << __func__ << ": Final result status " << result.status |
| 582 | << " is not allowed in the HTTP phase"; |
| 583 | break; |
| 584 | |
Rebecca Silberstein | 3d49ea4 | 2014-08-21 11:20:50 -0700 | [diff] [blame] | 585 | case ConnectivityTrial::kPhaseContent: |
| 586 | if (result.status == ConnectivityTrial::kStatusSuccess) |
Thieu Le | 85e050b | 2012-03-13 15:04:38 -0700 | [diff] [blame] | 587 | retval = kPortalResultSuccess; |
Rebecca Silberstein | 3d49ea4 | 2014-08-21 11:20:50 -0700 | [diff] [blame] | 588 | else if (result.status == ConnectivityTrial::kStatusFailure) |
Thieu Le | 85e050b | 2012-03-13 15:04:38 -0700 | [diff] [blame] | 589 | retval = kPortalResultContentFailure; |
Rebecca Silberstein | 3d49ea4 | 2014-08-21 11:20:50 -0700 | [diff] [blame] | 590 | else if (result.status == ConnectivityTrial::kStatusTimeout) |
Thieu Le | 85e050b | 2012-03-13 15:04:38 -0700 | [diff] [blame] | 591 | retval = kPortalResultContentTimeout; |
| 592 | else |
| 593 | LOG(DFATAL) << __func__ << ": Final result status " << result.status |
| 594 | << " is not allowed in the Content phase"; |
| 595 | break; |
| 596 | |
Rebecca Silberstein | 3d49ea4 | 2014-08-21 11:20:50 -0700 | [diff] [blame] | 597 | case ConnectivityTrial::kPhaseUnknown: |
Thieu Le | 85e050b | 2012-03-13 15:04:38 -0700 | [diff] [blame] | 598 | retval = kPortalResultUnknown; |
| 599 | break; |
| 600 | |
| 601 | default: |
| 602 | LOG(DFATAL) << __func__ << ": Invalid phase " << result.phase; |
| 603 | break; |
| 604 | } |
| 605 | |
| 606 | return retval; |
| 607 | } |
| 608 | |
Thieu Le | 6c1e3bb | 2013-02-06 15:20:35 -0800 | [diff] [blame] | 609 | void Metrics::Start() { |
Rebecca Silberstein | c9c31d8 | 2014-10-21 15:01:00 -0700 | [diff] [blame] | 610 | SLOG(this, 2) << __func__; |
Thieu Le | 6c1e3bb | 2013-02-06 15:20:35 -0800 | [diff] [blame] | 611 | } |
| 612 | |
| 613 | void Metrics::Stop() { |
Rebecca Silberstein | c9c31d8 | 2014-10-21 15:01:00 -0700 | [diff] [blame] | 614 | SLOG(this, 2) << __func__; |
Thieu Le | 6c1e3bb | 2013-02-06 15:20:35 -0800 | [diff] [blame] | 615 | } |
| 616 | |
Paul Stewart | 8ae1874 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 617 | void Metrics::RegisterService(const Service& service) { |
Rebecca Silberstein | c9c31d8 | 2014-10-21 15:01:00 -0700 | [diff] [blame] | 618 | SLOG(this, 2) << __func__; |
Wade Guthrie | 7ac610b | 2013-10-01 17:48:14 -0700 | [diff] [blame] | 619 | LOG_IF(WARNING, ContainsKey(services_metrics_, &service)) |
| 620 | << "Repeatedly registering " << service.unique_name(); |
mukesh agrawal | 6cfe53f | 2013-08-13 13:39:01 -0700 | [diff] [blame] | 621 | shared_ptr<ServiceMetrics> service_metrics(new ServiceMetrics()); |
Wade Guthrie | 7ac610b | 2013-10-01 17:48:14 -0700 | [diff] [blame] | 622 | services_metrics_[&service] = service_metrics; |
Thieu Le | 48e6d6d | 2011-12-06 00:40:27 +0000 | [diff] [blame] | 623 | InitializeCommonServiceMetrics(service); |
Thieu Le | 48e6d6d | 2011-12-06 00:40:27 +0000 | [diff] [blame] | 624 | } |
| 625 | |
Paul Stewart | 8ae1874 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 626 | void Metrics::DeregisterService(const Service& service) { |
Wade Guthrie | 7ac610b | 2013-10-01 17:48:14 -0700 | [diff] [blame] | 627 | services_metrics_.erase(&service); |
Thieu Le | 48e6d6d | 2011-12-06 00:40:27 +0000 | [diff] [blame] | 628 | } |
| 629 | |
| 630 | void Metrics::AddServiceStateTransitionTimer( |
Paul Stewart | 8ae1874 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 631 | const Service& service, |
| 632 | const string& histogram_name, |
Thieu Le | 48e6d6d | 2011-12-06 00:40:27 +0000 | [diff] [blame] | 633 | Service::ConnectState start_state, |
| 634 | Service::ConnectState stop_state) { |
Rebecca Silberstein | c9c31d8 | 2014-10-21 15:01:00 -0700 | [diff] [blame] | 635 | SLOG(this, 2) << __func__ << ": adding " << histogram_name << " for " |
| 636 | << Service::ConnectStateToString(start_state) << " -> " |
| 637 | << Service::ConnectStateToString(stop_state); |
Wade Guthrie | 7ac610b | 2013-10-01 17:48:14 -0700 | [diff] [blame] | 638 | ServiceMetricsLookupMap::iterator it = services_metrics_.find(&service); |
Thieu Le | 48e6d6d | 2011-12-06 00:40:27 +0000 | [diff] [blame] | 639 | if (it == services_metrics_.end()) { |
Rebecca Silberstein | c9c31d8 | 2014-10-21 15:01:00 -0700 | [diff] [blame] | 640 | SLOG(this, 1) << "service not found"; |
Thieu Le | 48e6d6d | 2011-12-06 00:40:27 +0000 | [diff] [blame] | 641 | DCHECK(false); |
| 642 | return; |
| 643 | } |
Paul Stewart | 8ae1874 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 644 | ServiceMetrics* service_metrics = it->second.get(); |
Thieu Le | 48e6d6d | 2011-12-06 00:40:27 +0000 | [diff] [blame] | 645 | CHECK(start_state < stop_state); |
Paul Stewart | 8ae1874 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 646 | chromeos_metrics::TimerReporter* timer = |
Thieu Le | 48e6d6d | 2011-12-06 00:40:27 +0000 | [diff] [blame] | 647 | new chromeos_metrics::TimerReporter(histogram_name, |
Thieu Le | a20cbc2 | 2012-01-09 22:01:43 +0000 | [diff] [blame] | 648 | kTimerHistogramMillisecondsMin, |
| 649 | kTimerHistogramMillisecondsMax, |
Thieu Le | 48e6d6d | 2011-12-06 00:40:27 +0000 | [diff] [blame] | 650 | kTimerHistogramNumBuckets); |
| 651 | service_metrics->timers.push_back(timer); // passes ownership. |
| 652 | service_metrics->start_on_state[start_state].push_back(timer); |
| 653 | service_metrics->stop_on_state[stop_state].push_back(timer); |
| 654 | } |
| 655 | |
Paul Stewart | 8ae1874 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 656 | void Metrics::NotifyDefaultServiceChanged(const Service* service) { |
Thieu Le | a20cbc2 | 2012-01-09 22:01:43 +0000 | [diff] [blame] | 657 | base::TimeDelta elapsed_seconds; |
| 658 | |
| 659 | Technology::Identifier technology = (service) ? service->technology() : |
| 660 | Technology::kUnknown; |
| 661 | if (technology != last_default_technology_) { |
| 662 | if (last_default_technology_ != Technology::kUnknown) { |
mukesh agrawal | 132e96f | 2014-04-24 11:49:42 -0700 | [diff] [blame] | 663 | string histogram = GetFullMetricName(kMetricTimeOnlineSecondsSuffix, |
Thieu Le | a20cbc2 | 2012-01-09 22:01:43 +0000 | [diff] [blame] | 664 | last_default_technology_); |
| 665 | time_online_timer_->GetElapsedTime(&elapsed_seconds); |
| 666 | SendToUMA(histogram, |
| 667 | elapsed_seconds.InSeconds(), |
| 668 | kMetricTimeOnlineSecondsMin, |
| 669 | kMetricTimeOnlineSecondsMax, |
| 670 | kTimerHistogramNumBuckets); |
| 671 | } |
| 672 | last_default_technology_ = technology; |
| 673 | time_online_timer_->Start(); |
| 674 | } |
| 675 | |
Thieu Le | a20cbc2 | 2012-01-09 22:01:43 +0000 | [diff] [blame] | 676 | // Ignore changes that are not online/offline transitions; e.g. |
| 677 | // switching between wired and wireless. TimeToDrop measures |
| 678 | // time online regardless of how we are connected. |
Ben Chan | cc225ef | 2014-09-30 13:26:51 -0700 | [diff] [blame] | 679 | if ((service == nullptr && !was_online_) || |
| 680 | (service != nullptr && was_online_)) |
Thieu Le | a20cbc2 | 2012-01-09 22:01:43 +0000 | [diff] [blame] | 681 | return; |
| 682 | |
Ben Chan | cc225ef | 2014-09-30 13:26:51 -0700 | [diff] [blame] | 683 | if (service == nullptr) { |
Thieu Le | a20cbc2 | 2012-01-09 22:01:43 +0000 | [diff] [blame] | 684 | time_to_drop_timer_->GetElapsedTime(&elapsed_seconds); |
| 685 | SendToUMA(kMetricTimeToDropSeconds, |
| 686 | elapsed_seconds.InSeconds(), |
| 687 | kMetricTimeToDropSecondsMin, |
| 688 | kMetricTimeToDropSecondsMax, |
| 689 | kTimerHistogramNumBuckets); |
| 690 | } else { |
| 691 | time_to_drop_timer_->Start(); |
| 692 | } |
| 693 | |
Ben Chan | cc225ef | 2014-09-30 13:26:51 -0700 | [diff] [blame] | 694 | was_online_ = (service != nullptr); |
Thieu Le | 48e6d6d | 2011-12-06 00:40:27 +0000 | [diff] [blame] | 695 | } |
| 696 | |
Paul Stewart | 8ae1874 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 697 | void Metrics::NotifyServiceStateChanged(const Service& service, |
Thieu Le | 48e6d6d | 2011-12-06 00:40:27 +0000 | [diff] [blame] | 698 | Service::ConnectState new_state) { |
Wade Guthrie | 7ac610b | 2013-10-01 17:48:14 -0700 | [diff] [blame] | 699 | ServiceMetricsLookupMap::iterator it = services_metrics_.find(&service); |
Thieu Le | 48e6d6d | 2011-12-06 00:40:27 +0000 | [diff] [blame] | 700 | if (it == services_metrics_.end()) { |
Rebecca Silberstein | c9c31d8 | 2014-10-21 15:01:00 -0700 | [diff] [blame] | 701 | SLOG(this, 1) << "service not found"; |
Thieu Le | 48e6d6d | 2011-12-06 00:40:27 +0000 | [diff] [blame] | 702 | DCHECK(false); |
| 703 | return; |
| 704 | } |
Paul Stewart | 8ae1874 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 705 | ServiceMetrics* service_metrics = it->second.get(); |
Thieu Le | 48e6d6d | 2011-12-06 00:40:27 +0000 | [diff] [blame] | 706 | UpdateServiceStateTransitionMetrics(service_metrics, new_state); |
| 707 | |
| 708 | if (new_state == Service::kStateFailure) |
| 709 | SendServiceFailure(service); |
| 710 | |
Darin Petkov | 58f0b6d | 2012-06-12 12:52:30 +0200 | [diff] [blame] | 711 | if (collect_bootstats_) { |
Ben Chan | a0ddf46 | 2014-02-06 11:32:42 -0800 | [diff] [blame] | 712 | bootstat_log(base::StringPrintf("network-%s-%s", |
| 713 | Technology::NameFromIdentifier( |
| 714 | service.technology()).c_str(), |
| 715 | service.GetStateString().c_str()).c_str()); |
Darin Petkov | 58f0b6d | 2012-06-12 12:52:30 +0200 | [diff] [blame] | 716 | } |
| 717 | |
Paul Stewart | 20088d8 | 2012-02-16 06:58:55 -0800 | [diff] [blame] | 718 | if (new_state != Service::kStateConnected) |
Thieu Le | 48e6d6d | 2011-12-06 00:40:27 +0000 | [diff] [blame] | 719 | return; |
| 720 | |
Thieu Le | b84ba34 | 2012-03-02 15:15:19 -0800 | [diff] [blame] | 721 | base::TimeDelta time_resume_to_ready; |
| 722 | time_resume_to_ready_timer_->GetElapsedTime(&time_resume_to_ready); |
| 723 | time_resume_to_ready_timer_->Reset(); |
Wade Guthrie | 7ac610b | 2013-10-01 17:48:14 -0700 | [diff] [blame] | 724 | service.SendPostReadyStateMetrics(time_resume_to_ready.InMilliseconds()); |
Thieu Le | 48e6d6d | 2011-12-06 00:40:27 +0000 | [diff] [blame] | 725 | } |
| 726 | |
Paul Stewart | 8ae1874 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 727 | string Metrics::GetFullMetricName(const char* metric_suffix, |
Thieu Le | 48e6d6d | 2011-12-06 00:40:27 +0000 | [diff] [blame] | 728 | Technology::Identifier technology_id) { |
| 729 | string technology = Technology::NameFromIdentifier(technology_id); |
| 730 | technology[0] = base::ToUpperASCII(technology[0]); |
mukesh agrawal | 132e96f | 2014-04-24 11:49:42 -0700 | [diff] [blame] | 731 | return base::StringPrintf("%s.%s.%s", kMetricPrefix, technology.c_str(), |
| 732 | metric_suffix); |
Thieu Le | 48e6d6d | 2011-12-06 00:40:27 +0000 | [diff] [blame] | 733 | } |
| 734 | |
Paul Stewart | 8ae1874 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 735 | void Metrics::NotifyServiceDisconnect(const Service& service) { |
Wade Guthrie | 7ac610b | 2013-10-01 17:48:14 -0700 | [diff] [blame] | 736 | Technology::Identifier technology = service.technology(); |
mukesh agrawal | 132e96f | 2014-04-24 11:49:42 -0700 | [diff] [blame] | 737 | string histogram = GetFullMetricName(kMetricDisconnectSuffix, technology); |
Thieu Le | 67370f6 | 2012-02-14 23:01:42 +0000 | [diff] [blame] | 738 | SendToUMA(histogram, |
Wade Guthrie | 7ac610b | 2013-10-01 17:48:14 -0700 | [diff] [blame] | 739 | service.explicitly_disconnected(), |
Thieu Le | 67370f6 | 2012-02-14 23:01:42 +0000 | [diff] [blame] | 740 | kMetricDisconnectMin, |
| 741 | kMetricDisconnectMax, |
| 742 | kMetricDisconnectNumBuckets); |
Thieu Le | 48e6d6d | 2011-12-06 00:40:27 +0000 | [diff] [blame] | 743 | } |
| 744 | |
Paul Stewart | 8ae1874 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 745 | void Metrics::NotifySignalAtDisconnect(const Service& service, |
Wade Guthrie | 9ec0806 | 2013-09-25 15:22:24 -0700 | [diff] [blame] | 746 | int16_t signal_strength) { |
| 747 | // Negate signal_strength (goes from dBm to -dBm) because the metrics don't |
| 748 | // seem to handle negative values well. Now everything's positive. |
| 749 | Technology::Identifier technology = service.technology(); |
mukesh agrawal | 132e96f | 2014-04-24 11:49:42 -0700 | [diff] [blame] | 750 | string histogram = GetFullMetricName(kMetricSignalAtDisconnectSuffix, |
| 751 | technology); |
Wade Guthrie | 9ec0806 | 2013-09-25 15:22:24 -0700 | [diff] [blame] | 752 | SendToUMA(histogram, |
| 753 | -signal_strength, |
| 754 | kMetricSignalAtDisconnectMin, |
| 755 | kMetricSignalAtDisconnectMax, |
| 756 | kMetricSignalAtDisconnectNumBuckets); |
| 757 | } |
| 758 | |
Daniel Erat | fac0953 | 2014-04-17 20:25:59 -0700 | [diff] [blame] | 759 | void Metrics::NotifySuspendDone() { |
| 760 | time_resume_to_ready_timer_->Start(); |
Thieu Le | 48e6d6d | 2011-12-06 00:40:27 +0000 | [diff] [blame] | 761 | } |
| 762 | |
Samuel Tan | 66bddc6 | 2014-11-13 20:01:04 -0800 | [diff] [blame] | 763 | void Metrics::NotifyWakeOnWiFiFeaturesEnabledState( |
| 764 | WakeOnWiFiFeaturesEnabledState state) { |
| 765 | SendEnumToUMA(kMetricWakeOnWiFiFeaturesEnabledState, state, |
| 766 | kWakeOnWiFiFeaturesEnabledStateMax); |
| 767 | } |
| 768 | |
Samuel Tan | f144d5d | 2014-11-25 18:18:01 -0800 | [diff] [blame] | 769 | void Metrics::NotifyVerifyWakeOnWiFiSettingsResult( |
| 770 | VerifyWakeOnWiFiSettingsResult result) { |
| 771 | SendEnumToUMA(kMetricVerifyWakeOnWiFiSettingsResult, result, |
| 772 | kVerifyWakeOnWiFiSettingsResultMax); |
| 773 | } |
| 774 | |
Samuel Tan | 1964b5d | 2014-12-02 10:11:21 -0800 | [diff] [blame] | 775 | void Metrics::NotifyConnectedToServiceAfterWake( |
| 776 | WiFiConnectionStatusAfterWake status) { |
| 777 | SendEnumToUMA(kMetricWiFiConnectionStatusAfterWake, status, |
| 778 | kWiFiConnetionStatusAfterWakeMax); |
| 779 | } |
| 780 | |
Samuel Tan | fbe8d2b | 2014-09-15 20:23:59 -0700 | [diff] [blame] | 781 | void Metrics::NotifyTerminationActionsStarted() { |
Arman Uguray | ab22c16 | 2012-10-08 19:08:38 -0700 | [diff] [blame] | 782 | if (time_termination_actions_timer->HasStarted()) |
| 783 | return; |
| 784 | time_termination_actions_timer->Start(); |
| 785 | } |
| 786 | |
Samuel Tan | fbe8d2b | 2014-09-15 20:23:59 -0700 | [diff] [blame] | 787 | void Metrics::NotifyTerminationActionsCompleted(bool success) { |
Arman Uguray | ab22c16 | 2012-10-08 19:08:38 -0700 | [diff] [blame] | 788 | if (!time_termination_actions_timer->HasStarted()) |
| 789 | return; |
| 790 | |
Samuel Tan | 0e0ac0d | 2014-12-29 16:03:42 -0800 | [diff] [blame] | 791 | TerminationActionResult result = success ? kTerminationActionResultSuccess |
| 792 | : kTerminationActionResultFailure; |
Arman Uguray | ab22c16 | 2012-10-08 19:08:38 -0700 | [diff] [blame] | 793 | |
| 794 | base::TimeDelta elapsed_time; |
| 795 | time_termination_actions_timer->GetElapsedTime(&elapsed_time); |
| 796 | time_termination_actions_timer->Reset(); |
| 797 | string time_metric, result_metric; |
Samuel Tan | ea7dcda | 2015-01-05 14:32:50 -0800 | [diff] [blame] | 798 | time_metric = kMetricTerminationActionTimeTaken; |
Samuel Tan | fbe8d2b | 2014-09-15 20:23:59 -0700 | [diff] [blame] | 799 | result_metric = kMetricTerminationActionResult; |
Arman Uguray | ab22c16 | 2012-10-08 19:08:38 -0700 | [diff] [blame] | 800 | |
| 801 | SendToUMA(time_metric, |
| 802 | elapsed_time.InMilliseconds(), |
Samuel Tan | ea7dcda | 2015-01-05 14:32:50 -0800 | [diff] [blame] | 803 | kMetricTerminationActionTimeTakenMillisecondsMin, |
| 804 | kMetricTerminationActionTimeTakenMillisecondsMax, |
Arman Uguray | ab22c16 | 2012-10-08 19:08:38 -0700 | [diff] [blame] | 805 | kTimerHistogramNumBuckets); |
| 806 | |
| 807 | SendEnumToUMA(result_metric, |
| 808 | result, |
| 809 | kTerminationActionResultMax); |
| 810 | } |
| 811 | |
Samuel Tan | fbe8d2b | 2014-09-15 20:23:59 -0700 | [diff] [blame] | 812 | void Metrics::NotifySuspendActionsStarted() { |
| 813 | if (time_suspend_actions_timer->HasStarted()) |
| 814 | return; |
| 815 | time_suspend_actions_timer->Start(); |
Samuel Tan | c36b410 | 2015-01-26 19:34:35 -0800 | [diff] [blame] | 816 | wake_on_wifi_throttled_ = false; |
Samuel Tan | fbe8d2b | 2014-09-15 20:23:59 -0700 | [diff] [blame] | 817 | } |
| 818 | |
| 819 | void Metrics::NotifySuspendActionsCompleted(bool success) { |
| 820 | if (!time_suspend_actions_timer->HasStarted()) |
| 821 | return; |
| 822 | |
Samuel Tan | a493343 | 2015-02-06 18:20:41 -0800 | [diff] [blame] | 823 | // Reset for next dark resume. |
| 824 | wake_reason_received_ = false; |
| 825 | |
Samuel Tan | 0e0ac0d | 2014-12-29 16:03:42 -0800 | [diff] [blame] | 826 | SuspendActionResult result = |
| 827 | success ? kSuspendActionResultSuccess : kSuspendActionResultFailure; |
Samuel Tan | fbe8d2b | 2014-09-15 20:23:59 -0700 | [diff] [blame] | 828 | |
| 829 | base::TimeDelta elapsed_time; |
| 830 | time_suspend_actions_timer->GetElapsedTime(&elapsed_time); |
| 831 | time_suspend_actions_timer->Reset(); |
| 832 | string time_metric, result_metric; |
Samuel Tan | ea7dcda | 2015-01-05 14:32:50 -0800 | [diff] [blame] | 833 | time_metric = kMetricSuspendActionTimeTaken; |
Samuel Tan | fbe8d2b | 2014-09-15 20:23:59 -0700 | [diff] [blame] | 834 | result_metric = kMetricSuspendActionResult; |
| 835 | |
| 836 | SendToUMA(time_metric, |
| 837 | elapsed_time.InMilliseconds(), |
Samuel Tan | ea7dcda | 2015-01-05 14:32:50 -0800 | [diff] [blame] | 838 | kMetricSuspendActionTimeTakenMillisecondsMin, |
| 839 | kMetricSuspendActionTimeTakenMillisecondsMax, |
Samuel Tan | fbe8d2b | 2014-09-15 20:23:59 -0700 | [diff] [blame] | 840 | kTimerHistogramNumBuckets); |
| 841 | |
| 842 | SendEnumToUMA(result_metric, |
| 843 | result, |
| 844 | kSuspendActionResultMax); |
| 845 | } |
| 846 | |
Samuel Tan | 68b73d2 | 2014-10-28 17:00:56 -0700 | [diff] [blame] | 847 | void Metrics::NotifyDarkResumeActionsStarted() { |
| 848 | if (time_dark_resume_actions_timer->HasStarted()) |
| 849 | return; |
| 850 | time_dark_resume_actions_timer->Start(); |
Samuel Tan | 0e0ac0d | 2014-12-29 16:03:42 -0800 | [diff] [blame] | 851 | num_scan_results_expected_in_dark_resume_ = 0; |
Samuel Tan | 029feac | 2015-03-27 16:53:01 -0700 | [diff] [blame] | 852 | dark_resume_scan_retries_ = 0; |
Samuel Tan | 68b73d2 | 2014-10-28 17:00:56 -0700 | [diff] [blame] | 853 | } |
| 854 | |
| 855 | void Metrics::NotifyDarkResumeActionsCompleted(bool success) { |
| 856 | if (!time_dark_resume_actions_timer->HasStarted()) |
| 857 | return; |
| 858 | |
Samuel Tan | a493343 | 2015-02-06 18:20:41 -0800 | [diff] [blame] | 859 | // Reset for next dark resume. |
| 860 | wake_reason_received_ = false; |
| 861 | |
Samuel Tan | 0e0ac0d | 2014-12-29 16:03:42 -0800 | [diff] [blame] | 862 | DarkResumeActionResult result = |
| 863 | success ? kDarkResumeActionResultSuccess : kDarkResumeActionResultFailure; |
Samuel Tan | 68b73d2 | 2014-10-28 17:00:56 -0700 | [diff] [blame] | 864 | |
| 865 | base::TimeDelta elapsed_time; |
| 866 | time_dark_resume_actions_timer->GetElapsedTime(&elapsed_time); |
| 867 | time_dark_resume_actions_timer->Reset(); |
Samuel Tan | 68b73d2 | 2014-10-28 17:00:56 -0700 | [diff] [blame] | 868 | |
Samuel Tan | 029feac | 2015-03-27 16:53:01 -0700 | [diff] [blame] | 869 | SendToUMA(kMetricDarkResumeActionTimeTaken, |
Samuel Tan | 68b73d2 | 2014-10-28 17:00:56 -0700 | [diff] [blame] | 870 | elapsed_time.InMilliseconds(), |
Samuel Tan | ea7dcda | 2015-01-05 14:32:50 -0800 | [diff] [blame] | 871 | kMetricDarkResumeActionTimeTakenMillisecondsMin, |
| 872 | kMetricDarkResumeActionTimeTakenMillisecondsMax, |
Samuel Tan | 68b73d2 | 2014-10-28 17:00:56 -0700 | [diff] [blame] | 873 | kTimerHistogramNumBuckets); |
| 874 | |
Samuel Tan | 029feac | 2015-03-27 16:53:01 -0700 | [diff] [blame] | 875 | SendEnumToUMA(kMetricDarkResumeActionResult, |
Samuel Tan | 68b73d2 | 2014-10-28 17:00:56 -0700 | [diff] [blame] | 876 | result, |
| 877 | kDarkResumeActionResultMax); |
Samuel Tan | 0e0ac0d | 2014-12-29 16:03:42 -0800 | [diff] [blame] | 878 | |
| 879 | DarkResumeUnmatchedScanResultReceived unmatched_scan_results_received = |
| 880 | (num_scan_results_expected_in_dark_resume_ < 0) |
| 881 | ? kDarkResumeUnmatchedScanResultsReceivedTrue |
| 882 | : kDarkResumeUnmatchedScanResultsReceivedFalse; |
| 883 | SendEnumToUMA(kMetricDarkResumeUnmatchedScanResultReceived, |
| 884 | unmatched_scan_results_received, |
| 885 | kDarkResumeUnmatchedScanResultsReceivedMax); |
Samuel Tan | 029feac | 2015-03-27 16:53:01 -0700 | [diff] [blame] | 886 | |
| 887 | SendToUMA(kMetricDarkResumeScanNumRetries, dark_resume_scan_retries_, |
| 888 | kMetricDarkResumeScanNumRetriesMin, |
| 889 | kMetricDarkResumeScanNumRetriesMax, kTimerHistogramNumBuckets); |
Samuel Tan | 0e0ac0d | 2014-12-29 16:03:42 -0800 | [diff] [blame] | 890 | } |
| 891 | |
| 892 | void Metrics::NotifyDarkResumeInitiateScan() { |
| 893 | ++num_scan_results_expected_in_dark_resume_; |
| 894 | } |
| 895 | |
| 896 | void Metrics::NotifyDarkResumeScanResultsReceived() { |
| 897 | --num_scan_results_expected_in_dark_resume_; |
Samuel Tan | 68b73d2 | 2014-10-28 17:00:56 -0700 | [diff] [blame] | 898 | } |
| 899 | |
Paul Stewart | ff845fc | 2012-08-07 07:28:44 -0700 | [diff] [blame] | 900 | void Metrics::NotifyLinkMonitorFailure( |
Paul Stewart | 0443aa5 | 2012-08-09 10:43:50 -0700 | [diff] [blame] | 901 | Technology::Identifier technology, |
| 902 | LinkMonitorFailure failure, |
Paul Stewart | f1961f8 | 2012-09-11 20:45:39 -0700 | [diff] [blame] | 903 | int seconds_to_failure, |
| 904 | int broadcast_error_count, |
| 905 | int unicast_error_count) { |
mukesh agrawal | 132e96f | 2014-04-24 11:49:42 -0700 | [diff] [blame] | 906 | string histogram = GetFullMetricName(kMetricLinkMonitorFailureSuffix, |
Paul Stewart | ff845fc | 2012-08-07 07:28:44 -0700 | [diff] [blame] | 907 | technology); |
| 908 | SendEnumToUMA(histogram, failure, kLinkMonitorFailureMax); |
Paul Stewart | 0443aa5 | 2012-08-09 10:43:50 -0700 | [diff] [blame] | 909 | |
| 910 | if (failure == kLinkMonitorFailureThresholdReached) { |
| 911 | if (seconds_to_failure > kMetricLinkMonitorSecondsToFailureMax) { |
| 912 | seconds_to_failure = kMetricLinkMonitorSecondsToFailureMax; |
| 913 | } |
mukesh agrawal | 132e96f | 2014-04-24 11:49:42 -0700 | [diff] [blame] | 914 | histogram = GetFullMetricName(kMetricLinkMonitorSecondsToFailureSuffix, |
Paul Stewart | 0443aa5 | 2012-08-09 10:43:50 -0700 | [diff] [blame] | 915 | technology); |
| 916 | SendToUMA(histogram, |
| 917 | seconds_to_failure, |
| 918 | kMetricLinkMonitorSecondsToFailureMin, |
| 919 | kMetricLinkMonitorSecondsToFailureMax, |
| 920 | kMetricLinkMonitorSecondsToFailureNumBuckets); |
mukesh agrawal | 132e96f | 2014-04-24 11:49:42 -0700 | [diff] [blame] | 921 | histogram = GetFullMetricName( |
| 922 | kMetricLinkMonitorBroadcastErrorsAtFailureSuffix, technology); |
Paul Stewart | 0443aa5 | 2012-08-09 10:43:50 -0700 | [diff] [blame] | 923 | SendToUMA(histogram, |
| 924 | broadcast_error_count, |
| 925 | kMetricLinkMonitorErrorCountMin, |
| 926 | kMetricLinkMonitorErrorCountMax, |
| 927 | kMetricLinkMonitorErrorCountNumBuckets); |
mukesh agrawal | 132e96f | 2014-04-24 11:49:42 -0700 | [diff] [blame] | 928 | histogram = GetFullMetricName( |
| 929 | kMetricLinkMonitorUnicastErrorsAtFailureSuffix, technology); |
Paul Stewart | 0443aa5 | 2012-08-09 10:43:50 -0700 | [diff] [blame] | 930 | SendToUMA(histogram, |
| 931 | unicast_error_count, |
| 932 | kMetricLinkMonitorErrorCountMin, |
| 933 | kMetricLinkMonitorErrorCountMax, |
| 934 | kMetricLinkMonitorErrorCountNumBuckets); |
| 935 | } |
Paul Stewart | ff845fc | 2012-08-07 07:28:44 -0700 | [diff] [blame] | 936 | } |
| 937 | |
| 938 | void Metrics::NotifyLinkMonitorResponseTimeSampleAdded( |
| 939 | Technology::Identifier technology, |
Paul Stewart | f1961f8 | 2012-09-11 20:45:39 -0700 | [diff] [blame] | 940 | int response_time_milliseconds) { |
mukesh agrawal | 132e96f | 2014-04-24 11:49:42 -0700 | [diff] [blame] | 941 | string histogram = GetFullMetricName( |
| 942 | kMetricLinkMonitorResponseTimeSampleSuffix, technology); |
Paul Stewart | ff845fc | 2012-08-07 07:28:44 -0700 | [diff] [blame] | 943 | SendToUMA(histogram, |
| 944 | response_time_milliseconds, |
| 945 | kMetricLinkMonitorResponseTimeSampleMin, |
| 946 | kMetricLinkMonitorResponseTimeSampleMax, |
| 947 | kMetricLinkMonitorResponseTimeSampleNumBuckets); |
| 948 | } |
| 949 | |
Peter Qiu | 1a72f54 | 2015-04-14 16:31:36 -0700 | [diff] [blame] | 950 | #if !defined(DISABLE_WIFI) |
| 951 | // TODO(zqiu): Change argument type from IEEE_80211::WiFiReasonCode to |
| 952 | // Metrics::WiFiStatusType, to remove dependency for IEEE_80211. |
Wade Guthrie | d4977f2 | 2012-08-22 12:37:54 -0700 | [diff] [blame] | 953 | void Metrics::Notify80211Disconnect(WiFiDisconnectByWhom by_whom, |
| 954 | IEEE_80211::WiFiReasonCode reason) { |
| 955 | string metric_disconnect_reason; |
| 956 | string metric_disconnect_type; |
| 957 | WiFiStatusType type; |
| 958 | |
| 959 | if (by_whom == kDisconnectedByAp) { |
| 960 | metric_disconnect_reason = kMetricLinkApDisconnectReason; |
| 961 | metric_disconnect_type = kMetricLinkApDisconnectType; |
| 962 | type = kStatusCodeTypeByAp; |
| 963 | } else { |
| 964 | metric_disconnect_reason = kMetricLinkClientDisconnectReason; |
| 965 | metric_disconnect_type = kMetricLinkClientDisconnectType; |
Wade Guthrie | 60a3706 | 2013-04-02 11:39:09 -0700 | [diff] [blame] | 966 | switch (reason) { |
Wade Guthrie | d4977f2 | 2012-08-22 12:37:54 -0700 | [diff] [blame] | 967 | case IEEE_80211::kReasonCodeSenderHasLeft: |
| 968 | case IEEE_80211::kReasonCodeDisassociatedHasLeft: |
| 969 | type = kStatusCodeTypeByUser; |
| 970 | break; |
| 971 | |
| 972 | case IEEE_80211::kReasonCodeInactivity: |
| 973 | type = kStatusCodeTypeConsideredDead; |
| 974 | break; |
| 975 | |
| 976 | default: |
| 977 | type = kStatusCodeTypeByClient; |
| 978 | break; |
| 979 | } |
| 980 | } |
| 981 | SendEnumToUMA(metric_disconnect_reason, reason, |
| 982 | IEEE_80211::kStatusCodeMax); |
| 983 | SendEnumToUMA(metric_disconnect_type, type, kStatusCodeTypeMax); |
| 984 | } |
Peter Qiu | 1a72f54 | 2015-04-14 16:31:36 -0700 | [diff] [blame] | 985 | #endif // DISABLE_WIFI |
Wade Guthrie | d4977f2 | 2012-08-22 12:37:54 -0700 | [diff] [blame] | 986 | |
Thieu Le | c8078a6 | 2013-01-22 18:01:12 -0800 | [diff] [blame] | 987 | void Metrics::RegisterDevice(int interface_index, |
| 988 | Technology::Identifier technology) { |
Rebecca Silberstein | c9c31d8 | 2014-10-21 15:01:00 -0700 | [diff] [blame] | 989 | SLOG(this, 2) << __func__ << ": " << interface_index; |
Thieu Le | c8078a6 | 2013-01-22 18:01:12 -0800 | [diff] [blame] | 990 | shared_ptr<DeviceMetrics> device_metrics(new DeviceMetrics); |
| 991 | devices_metrics_[interface_index] = device_metrics; |
Thieu Le | 9abd674 | 2013-01-23 23:35:37 -0800 | [diff] [blame] | 992 | device_metrics->technology = technology; |
mukesh agrawal | 132e96f | 2014-04-24 11:49:42 -0700 | [diff] [blame] | 993 | string histogram = GetFullMetricName( |
| 994 | kMetricTimeToInitializeMillisecondsSuffix, technology); |
Thieu Le | c8078a6 | 2013-01-22 18:01:12 -0800 | [diff] [blame] | 995 | device_metrics->initialization_timer.reset( |
| 996 | new chromeos_metrics::TimerReporter( |
| 997 | histogram, |
| 998 | kMetricTimeToInitializeMillisecondsMin, |
| 999 | kMetricTimeToInitializeMillisecondsMax, |
| 1000 | kMetricTimeToInitializeMillisecondsNumBuckets)); |
| 1001 | device_metrics->initialization_timer->Start(); |
mukesh agrawal | 132e96f | 2014-04-24 11:49:42 -0700 | [diff] [blame] | 1002 | histogram = GetFullMetricName(kMetricTimeToEnableMillisecondsSuffix, |
Thieu Le | ce4483e | 2013-01-23 15:12:03 -0800 | [diff] [blame] | 1003 | technology); |
| 1004 | device_metrics->enable_timer.reset( |
| 1005 | new chromeos_metrics::TimerReporter( |
| 1006 | histogram, |
| 1007 | kMetricTimeToEnableMillisecondsMin, |
| 1008 | kMetricTimeToEnableMillisecondsMax, |
| 1009 | kMetricTimeToEnableMillisecondsNumBuckets)); |
mukesh agrawal | 132e96f | 2014-04-24 11:49:42 -0700 | [diff] [blame] | 1010 | histogram = GetFullMetricName(kMetricTimeToDisableMillisecondsSuffix, |
Thieu Le | a2519bf | 2013-01-23 16:51:54 -0800 | [diff] [blame] | 1011 | technology); |
| 1012 | device_metrics->disable_timer.reset( |
| 1013 | new chromeos_metrics::TimerReporter( |
| 1014 | histogram, |
| 1015 | kMetricTimeToDisableMillisecondsMin, |
| 1016 | kMetricTimeToDisableMillisecondsMax, |
| 1017 | kMetricTimeToDisableMillisecondsNumBuckets)); |
mukesh agrawal | 132e96f | 2014-04-24 11:49:42 -0700 | [diff] [blame] | 1018 | histogram = GetFullMetricName(kMetricTimeToScanMillisecondsSuffix, |
Thieu Le | 18c1107 | 2013-01-28 17:21:37 -0800 | [diff] [blame] | 1019 | technology); |
| 1020 | device_metrics->scan_timer.reset( |
| 1021 | new chromeos_metrics::TimerReporter( |
| 1022 | histogram, |
| 1023 | kMetricTimeToScanMillisecondsMin, |
| 1024 | kMetricTimeToScanMillisecondsMax, |
| 1025 | kMetricTimeToScanMillisecondsNumBuckets)); |
mukesh agrawal | 132e96f | 2014-04-24 11:49:42 -0700 | [diff] [blame] | 1026 | histogram = GetFullMetricName(kMetricTimeToConnectMillisecondsSuffix, |
Thieu Le | cdb5a21 | 2013-01-25 11:17:18 -0800 | [diff] [blame] | 1027 | technology); |
| 1028 | device_metrics->connect_timer.reset( |
| 1029 | new chromeos_metrics::TimerReporter( |
| 1030 | histogram, |
| 1031 | kMetricTimeToConnectMillisecondsMin, |
| 1032 | kMetricTimeToConnectMillisecondsMax, |
| 1033 | kMetricTimeToConnectMillisecondsNumBuckets)); |
mukesh agrawal | 132e96f | 2014-04-24 11:49:42 -0700 | [diff] [blame] | 1034 | histogram = GetFullMetricName(kMetricTimeToScanAndConnectMillisecondsSuffix, |
Wade Guthrie | 44f290d | 2013-05-28 10:16:25 -0700 | [diff] [blame] | 1035 | technology); |
| 1036 | device_metrics->scan_connect_timer.reset( |
| 1037 | new chromeos_metrics::TimerReporter( |
| 1038 | histogram, |
| 1039 | kMetricTimeToScanMillisecondsMin, |
| 1040 | kMetricTimeToScanMillisecondsMax + |
| 1041 | kMetricTimeToConnectMillisecondsMax, |
| 1042 | kMetricTimeToScanMillisecondsNumBuckets + |
| 1043 | kMetricTimeToConnectMillisecondsNumBuckets)); |
Thieu Le | 7cf36b0 | 2013-01-30 17:15:56 -0800 | [diff] [blame] | 1044 | device_metrics->auto_connect_timer.reset( |
| 1045 | new chromeos_metrics::TimerReporter( |
| 1046 | kMetricCellularAutoConnectTotalTime, |
| 1047 | kMetricCellularAutoConnectTotalTimeMin, |
| 1048 | kMetricCellularAutoConnectTotalTimeMax, |
| 1049 | kMetricCellularAutoConnectTotalTimeNumBuckets)); |
Thieu Le | c8078a6 | 2013-01-22 18:01:12 -0800 | [diff] [blame] | 1050 | } |
| 1051 | |
Thieu Le | 9abd674 | 2013-01-23 23:35:37 -0800 | [diff] [blame] | 1052 | bool Metrics::IsDeviceRegistered(int interface_index, |
| 1053 | Technology::Identifier technology) { |
Rebecca Silberstein | c9c31d8 | 2014-10-21 15:01:00 -0700 | [diff] [blame] | 1054 | SLOG(this, 2) << __func__ << ": interface index: " << interface_index |
| 1055 | << ", technology: " << technology; |
Paul Stewart | 8ae1874 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 1056 | DeviceMetrics* device_metrics = GetDeviceMetrics(interface_index); |
Ben Chan | cc225ef | 2014-09-30 13:26:51 -0700 | [diff] [blame] | 1057 | if (device_metrics == nullptr) |
Thieu Le | 9abd674 | 2013-01-23 23:35:37 -0800 | [diff] [blame] | 1058 | return false; |
| 1059 | // Make sure the device technologies match. |
| 1060 | return (technology == device_metrics->technology); |
| 1061 | } |
| 1062 | |
Thieu Le | c8078a6 | 2013-01-22 18:01:12 -0800 | [diff] [blame] | 1063 | void Metrics::DeregisterDevice(int interface_index) { |
Rebecca Silberstein | c9c31d8 | 2014-10-21 15:01:00 -0700 | [diff] [blame] | 1064 | SLOG(this, 2) << __func__ << ": interface index: " << interface_index; |
Peter Qiu | 9f5159e | 2014-09-12 16:50:14 -0700 | [diff] [blame] | 1065 | |
Paul Stewart | 8ae1874 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 1066 | DeviceMetrics* device_metrics = GetDeviceMetrics(interface_index); |
Ben Chan | cc225ef | 2014-09-30 13:26:51 -0700 | [diff] [blame] | 1067 | if (device_metrics != nullptr) { |
Peter Qiu | 9f5159e | 2014-09-12 16:50:14 -0700 | [diff] [blame] | 1068 | NotifyDeviceRemovedEvent(device_metrics->technology); |
| 1069 | } |
| 1070 | |
Thieu Le | c8078a6 | 2013-01-22 18:01:12 -0800 | [diff] [blame] | 1071 | devices_metrics_.erase(interface_index); |
| 1072 | } |
| 1073 | |
| 1074 | void Metrics::NotifyDeviceInitialized(int interface_index) { |
Paul Stewart | 8ae1874 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 1075 | DeviceMetrics* device_metrics = GetDeviceMetrics(interface_index); |
Ben Chan | cc225ef | 2014-09-30 13:26:51 -0700 | [diff] [blame] | 1076 | if (device_metrics == nullptr) |
Thieu Le | c8078a6 | 2013-01-22 18:01:12 -0800 | [diff] [blame] | 1077 | return; |
Wade Guthrie | 091c41c | 2013-03-22 15:48:53 -0700 | [diff] [blame] | 1078 | if (!device_metrics->initialization_timer->Stop()) |
| 1079 | return; |
Thieu Le | c8078a6 | 2013-01-22 18:01:12 -0800 | [diff] [blame] | 1080 | device_metrics->initialization_timer->ReportMilliseconds(); |
| 1081 | } |
| 1082 | |
Thieu Le | ce4483e | 2013-01-23 15:12:03 -0800 | [diff] [blame] | 1083 | void Metrics::NotifyDeviceEnableStarted(int interface_index) { |
Paul Stewart | 8ae1874 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 1084 | DeviceMetrics* device_metrics = GetDeviceMetrics(interface_index); |
Ben Chan | cc225ef | 2014-09-30 13:26:51 -0700 | [diff] [blame] | 1085 | if (device_metrics == nullptr) |
Thieu Le | ce4483e | 2013-01-23 15:12:03 -0800 | [diff] [blame] | 1086 | return; |
| 1087 | device_metrics->enable_timer->Start(); |
| 1088 | } |
| 1089 | |
| 1090 | void Metrics::NotifyDeviceEnableFinished(int interface_index) { |
Paul Stewart | 8ae1874 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 1091 | DeviceMetrics* device_metrics = GetDeviceMetrics(interface_index); |
Ben Chan | cc225ef | 2014-09-30 13:26:51 -0700 | [diff] [blame] | 1092 | if (device_metrics == nullptr) |
Thieu Le | ce4483e | 2013-01-23 15:12:03 -0800 | [diff] [blame] | 1093 | return; |
Wade Guthrie | 091c41c | 2013-03-22 15:48:53 -0700 | [diff] [blame] | 1094 | if (!device_metrics->enable_timer->Stop()) |
| 1095 | return; |
Thieu Le | ce4483e | 2013-01-23 15:12:03 -0800 | [diff] [blame] | 1096 | device_metrics->enable_timer->ReportMilliseconds(); |
| 1097 | } |
| 1098 | |
Thieu Le | a2519bf | 2013-01-23 16:51:54 -0800 | [diff] [blame] | 1099 | void Metrics::NotifyDeviceDisableStarted(int interface_index) { |
Paul Stewart | 8ae1874 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 1100 | DeviceMetrics* device_metrics = GetDeviceMetrics(interface_index); |
Ben Chan | cc225ef | 2014-09-30 13:26:51 -0700 | [diff] [blame] | 1101 | if (device_metrics == nullptr) |
Thieu Le | a2519bf | 2013-01-23 16:51:54 -0800 | [diff] [blame] | 1102 | return; |
| 1103 | device_metrics->disable_timer->Start(); |
| 1104 | } |
| 1105 | |
| 1106 | void Metrics::NotifyDeviceDisableFinished(int interface_index) { |
Paul Stewart | 8ae1874 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 1107 | DeviceMetrics* device_metrics = GetDeviceMetrics(interface_index); |
Ben Chan | cc225ef | 2014-09-30 13:26:51 -0700 | [diff] [blame] | 1108 | if (device_metrics == nullptr) |
Thieu Le | a2519bf | 2013-01-23 16:51:54 -0800 | [diff] [blame] | 1109 | return; |
Wade Guthrie | 091c41c | 2013-03-22 15:48:53 -0700 | [diff] [blame] | 1110 | if (!device_metrics->disable_timer->Stop()) |
| 1111 | return; |
Thieu Le | a2519bf | 2013-01-23 16:51:54 -0800 | [diff] [blame] | 1112 | device_metrics->disable_timer->ReportMilliseconds(); |
| 1113 | } |
| 1114 | |
Thieu Le | 18c1107 | 2013-01-28 17:21:37 -0800 | [diff] [blame] | 1115 | void Metrics::NotifyDeviceScanStarted(int interface_index) { |
Paul Stewart | 8ae1874 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 1116 | DeviceMetrics* device_metrics = GetDeviceMetrics(interface_index); |
Ben Chan | cc225ef | 2014-09-30 13:26:51 -0700 | [diff] [blame] | 1117 | if (device_metrics == nullptr) |
Thieu Le | 18c1107 | 2013-01-28 17:21:37 -0800 | [diff] [blame] | 1118 | return; |
Thieu Le | 18c1107 | 2013-01-28 17:21:37 -0800 | [diff] [blame] | 1119 | device_metrics->scan_timer->Start(); |
Wade Guthrie | 44f290d | 2013-05-28 10:16:25 -0700 | [diff] [blame] | 1120 | device_metrics->scan_connect_timer->Start(); |
Thieu Le | 18c1107 | 2013-01-28 17:21:37 -0800 | [diff] [blame] | 1121 | } |
| 1122 | |
| 1123 | void Metrics::NotifyDeviceScanFinished(int interface_index) { |
Paul Stewart | 8ae1874 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 1124 | DeviceMetrics* device_metrics = GetDeviceMetrics(interface_index); |
Ben Chan | cc225ef | 2014-09-30 13:26:51 -0700 | [diff] [blame] | 1125 | if (device_metrics == nullptr) |
Thieu Le | 18c1107 | 2013-01-28 17:21:37 -0800 | [diff] [blame] | 1126 | return; |
Wade Guthrie | 091c41c | 2013-03-22 15:48:53 -0700 | [diff] [blame] | 1127 | if (!device_metrics->scan_timer->Stop()) |
| 1128 | return; |
Wade Guthrie | 68d4109 | 2013-04-02 12:56:02 -0700 | [diff] [blame] | 1129 | // Don't send TimeToScan metrics if the elapsed time exceeds the max metrics |
| 1130 | // value. Huge scan times usually mean something's gone awry; for cellular, |
| 1131 | // for instance, this usually means that the modem is in an area without |
| 1132 | // service and we're not interested in this scenario. |
Thieu Le | 18c1107 | 2013-01-28 17:21:37 -0800 | [diff] [blame] | 1133 | base::TimeDelta elapsed_time; |
| 1134 | device_metrics->scan_timer->GetElapsedTime(&elapsed_time); |
| 1135 | if (elapsed_time.InMilliseconds() <= kMetricTimeToScanMillisecondsMax) |
| 1136 | device_metrics->scan_timer->ReportMilliseconds(); |
| 1137 | } |
| 1138 | |
Wade Guthrie | 44f290d | 2013-05-28 10:16:25 -0700 | [diff] [blame] | 1139 | void Metrics::ResetScanTimer(int interface_index) { |
Paul Stewart | 8ae1874 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 1140 | DeviceMetrics* device_metrics = GetDeviceMetrics(interface_index); |
Ben Chan | cc225ef | 2014-09-30 13:26:51 -0700 | [diff] [blame] | 1141 | if (device_metrics == nullptr) |
Wade Guthrie | 44f290d | 2013-05-28 10:16:25 -0700 | [diff] [blame] | 1142 | return; |
| 1143 | device_metrics->scan_timer->Reset(); |
| 1144 | } |
| 1145 | |
Thieu Le | 7cf36b0 | 2013-01-30 17:15:56 -0800 | [diff] [blame] | 1146 | void Metrics::NotifyDeviceConnectStarted(int interface_index, |
| 1147 | bool is_auto_connecting) { |
Paul Stewart | 8ae1874 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 1148 | DeviceMetrics* device_metrics = GetDeviceMetrics(interface_index); |
Ben Chan | cc225ef | 2014-09-30 13:26:51 -0700 | [diff] [blame] | 1149 | if (device_metrics == nullptr) |
Thieu Le | cdb5a21 | 2013-01-25 11:17:18 -0800 | [diff] [blame] | 1150 | return; |
| 1151 | device_metrics->connect_timer->Start(); |
Thieu Le | 7cf36b0 | 2013-01-30 17:15:56 -0800 | [diff] [blame] | 1152 | |
| 1153 | if (is_auto_connecting) { |
| 1154 | device_metrics->auto_connect_tries++; |
| 1155 | if (device_metrics->auto_connect_tries == 1) |
| 1156 | device_metrics->auto_connect_timer->Start(); |
| 1157 | } else { |
| 1158 | AutoConnectMetricsReset(device_metrics); |
| 1159 | } |
Thieu Le | cdb5a21 | 2013-01-25 11:17:18 -0800 | [diff] [blame] | 1160 | } |
| 1161 | |
| 1162 | void Metrics::NotifyDeviceConnectFinished(int interface_index) { |
Paul Stewart | 8ae1874 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 1163 | DeviceMetrics* device_metrics = GetDeviceMetrics(interface_index); |
Ben Chan | cc225ef | 2014-09-30 13:26:51 -0700 | [diff] [blame] | 1164 | if (device_metrics == nullptr) |
Thieu Le | cdb5a21 | 2013-01-25 11:17:18 -0800 | [diff] [blame] | 1165 | return; |
Wade Guthrie | 091c41c | 2013-03-22 15:48:53 -0700 | [diff] [blame] | 1166 | if (!device_metrics->connect_timer->Stop()) |
| 1167 | return; |
Thieu Le | cdb5a21 | 2013-01-25 11:17:18 -0800 | [diff] [blame] | 1168 | device_metrics->connect_timer->ReportMilliseconds(); |
Thieu Le | 7cf36b0 | 2013-01-30 17:15:56 -0800 | [diff] [blame] | 1169 | |
| 1170 | if (device_metrics->auto_connect_tries > 0) { |
Wade Guthrie | 091c41c | 2013-03-22 15:48:53 -0700 | [diff] [blame] | 1171 | if (!device_metrics->auto_connect_timer->Stop()) |
| 1172 | return; |
Thieu Le | 7cf36b0 | 2013-01-30 17:15:56 -0800 | [diff] [blame] | 1173 | base::TimeDelta elapsed_time; |
| 1174 | device_metrics->auto_connect_timer->GetElapsedTime(&elapsed_time); |
| 1175 | if (elapsed_time.InMilliseconds() > kMetricCellularAutoConnectTotalTimeMax) |
| 1176 | return; |
| 1177 | device_metrics->auto_connect_timer->ReportMilliseconds(); |
| 1178 | SendToUMA(kMetricCellularAutoConnectTries, |
| 1179 | device_metrics->auto_connect_tries, |
| 1180 | kMetricCellularAutoConnectTriesMin, |
| 1181 | kMetricCellularAutoConnectTriesMax, |
| 1182 | kMetricCellularAutoConnectTriesNumBuckets); |
| 1183 | AutoConnectMetricsReset(device_metrics); |
| 1184 | } |
Wade Guthrie | 44f290d | 2013-05-28 10:16:25 -0700 | [diff] [blame] | 1185 | |
| 1186 | if (!device_metrics->scan_connect_timer->Stop()) |
| 1187 | return; |
Wade Guthrie | 44f290d | 2013-05-28 10:16:25 -0700 | [diff] [blame] | 1188 | device_metrics->scan_connect_timer->ReportMilliseconds(); |
| 1189 | } |
| 1190 | |
| 1191 | void Metrics::ResetConnectTimer(int interface_index) { |
Paul Stewart | 8ae1874 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 1192 | DeviceMetrics* device_metrics = GetDeviceMetrics(interface_index); |
Ben Chan | cc225ef | 2014-09-30 13:26:51 -0700 | [diff] [blame] | 1193 | if (device_metrics == nullptr) |
Wade Guthrie | 44f290d | 2013-05-28 10:16:25 -0700 | [diff] [blame] | 1194 | return; |
| 1195 | device_metrics->connect_timer->Reset(); |
| 1196 | device_metrics->scan_connect_timer->Reset(); |
Thieu Le | cdb5a21 | 2013-01-25 11:17:18 -0800 | [diff] [blame] | 1197 | } |
| 1198 | |
Prathmesh Prabhu | 08757aa | 2013-05-15 17:17:33 -0700 | [diff] [blame] | 1199 | void Metrics::Notify3GPPRegistrationDelayedDropPosted() { |
| 1200 | SendEnumToUMA(kMetricCellular3GPPRegistrationDelayedDrop, |
| 1201 | kCellular3GPPRegistrationDelayedDropPosted, |
| 1202 | kCellular3GPPRegistrationDelayedDropMax); |
| 1203 | } |
| 1204 | |
| 1205 | void Metrics::Notify3GPPRegistrationDelayedDropCanceled() { |
| 1206 | SendEnumToUMA(kMetricCellular3GPPRegistrationDelayedDrop, |
| 1207 | kCellular3GPPRegistrationDelayedDropCanceled, |
| 1208 | kCellular3GPPRegistrationDelayedDropMax); |
| 1209 | } |
| 1210 | |
Paul Stewart | 8ae1874 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 1211 | void Metrics::NotifyCellularDeviceDrop(const string& network_technology, |
Ben Chan | 7fab897 | 2014-08-10 17:14:46 -0700 | [diff] [blame] | 1212 | uint16_t signal_strength) { |
Rebecca Silberstein | c9c31d8 | 2014-10-21 15:01:00 -0700 | [diff] [blame] | 1213 | SLOG(this, 2) << __func__ << ": " << network_technology |
| 1214 | << ", " << signal_strength; |
Thieu Le | 26fc01b | 2013-01-28 12:08:48 -0800 | [diff] [blame] | 1215 | CellularDropTechnology drop_technology = kCellularDropTechnologyUnknown; |
Ben Chan | 923a502 | 2013-09-20 11:23:23 -0700 | [diff] [blame] | 1216 | if (network_technology == kNetworkTechnology1Xrtt) { |
Thieu Le | 26fc01b | 2013-01-28 12:08:48 -0800 | [diff] [blame] | 1217 | drop_technology = kCellularDropTechnology1Xrtt; |
Ben Chan | 923a502 | 2013-09-20 11:23:23 -0700 | [diff] [blame] | 1218 | } else if (network_technology == kNetworkTechnologyEdge) { |
Thieu Le | 26fc01b | 2013-01-28 12:08:48 -0800 | [diff] [blame] | 1219 | drop_technology = kCellularDropTechnologyEdge; |
Ben Chan | 923a502 | 2013-09-20 11:23:23 -0700 | [diff] [blame] | 1220 | } else if (network_technology == kNetworkTechnologyEvdo) { |
Thieu Le | 26fc01b | 2013-01-28 12:08:48 -0800 | [diff] [blame] | 1221 | drop_technology = kCellularDropTechnologyEvdo; |
Ben Chan | 923a502 | 2013-09-20 11:23:23 -0700 | [diff] [blame] | 1222 | } else if (network_technology == kNetworkTechnologyGprs) { |
Thieu Le | 26fc01b | 2013-01-28 12:08:48 -0800 | [diff] [blame] | 1223 | drop_technology = kCellularDropTechnologyGprs; |
Ben Chan | 923a502 | 2013-09-20 11:23:23 -0700 | [diff] [blame] | 1224 | } else if (network_technology == kNetworkTechnologyGsm) { |
Thieu Le | 26fc01b | 2013-01-28 12:08:48 -0800 | [diff] [blame] | 1225 | drop_technology = kCellularDropTechnologyGsm; |
Ben Chan | 923a502 | 2013-09-20 11:23:23 -0700 | [diff] [blame] | 1226 | } else if (network_technology == kNetworkTechnologyHspa) { |
Thieu Le | 26fc01b | 2013-01-28 12:08:48 -0800 | [diff] [blame] | 1227 | drop_technology = kCellularDropTechnologyHspa; |
Ben Chan | 923a502 | 2013-09-20 11:23:23 -0700 | [diff] [blame] | 1228 | } else if (network_technology == kNetworkTechnologyHspaPlus) { |
Thieu Le | 26fc01b | 2013-01-28 12:08:48 -0800 | [diff] [blame] | 1229 | drop_technology = kCellularDropTechnologyHspaPlus; |
Ben Chan | 923a502 | 2013-09-20 11:23:23 -0700 | [diff] [blame] | 1230 | } else if (network_technology == kNetworkTechnologyLte) { |
Thieu Le | 26fc01b | 2013-01-28 12:08:48 -0800 | [diff] [blame] | 1231 | drop_technology = kCellularDropTechnologyLte; |
Ben Chan | 923a502 | 2013-09-20 11:23:23 -0700 | [diff] [blame] | 1232 | } else if (network_technology == kNetworkTechnologyUmts) { |
Thieu Le | 26fc01b | 2013-01-28 12:08:48 -0800 | [diff] [blame] | 1233 | drop_technology = kCellularDropTechnologyUmts; |
| 1234 | } |
| 1235 | SendEnumToUMA(kMetricCellularDrop, |
| 1236 | drop_technology, |
| 1237 | kCellularDropTechnologyMax); |
| 1238 | SendToUMA(kMetricCellularSignalStrengthBeforeDrop, |
| 1239 | signal_strength, |
| 1240 | kMetricCellularSignalStrengthBeforeDropMin, |
| 1241 | kMetricCellularSignalStrengthBeforeDropMax, |
| 1242 | kMetricCellularSignalStrengthBeforeDropNumBuckets); |
| 1243 | } |
| 1244 | |
Paul Stewart | 8ae1874 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 1245 | void Metrics::NotifyCellularDeviceFailure(const Error& error) { |
Thieu Le | b7aa5f7 | 2013-01-31 15:57:48 -0800 | [diff] [blame] | 1246 | library_->SendUserActionToUMA( |
| 1247 | kMetricCellularFailureReason + error.message()); |
| 1248 | } |
| 1249 | |
Thieu Le | 91fccf6 | 2013-04-22 15:23:16 -0700 | [diff] [blame] | 1250 | void Metrics::NotifyCellularOutOfCredits( |
| 1251 | Metrics::CellularOutOfCreditsReason reason) { |
| 1252 | SendEnumToUMA(kMetricCellularOutOfCreditsReason, |
| 1253 | reason, |
| 1254 | kCellularOutOfCreditsReasonMax); |
| 1255 | } |
| 1256 | |
Thieu Le | 5133b71 | 2013-02-19 14:47:21 -0800 | [diff] [blame] | 1257 | void Metrics::NotifyCorruptedProfile() { |
| 1258 | SendEnumToUMA(kMetricCorruptedProfile, |
| 1259 | kCorruptedProfile, |
| 1260 | kCorruptedProfileMax); |
| 1261 | } |
| 1262 | |
Peter Qiu | 574996a | 2014-04-04 10:55:47 -0700 | [diff] [blame] | 1263 | void Metrics::NotifyWifiAutoConnectableServices(int num_services) { |
| 1264 | SendToUMA(kMetricWifiAutoConnectableServices, |
| 1265 | num_services, |
| 1266 | kMetricWifiAutoConnectableServicesMin, |
| 1267 | kMetricWifiAutoConnectableServicesMax, |
| 1268 | kMetricWifiAutoConnectableServicesNumBuckets); |
| 1269 | } |
| 1270 | |
| 1271 | void Metrics::NotifyWifiAvailableBSSes(int num_bss) { |
| 1272 | SendToUMA(kMetricWifiAvailableBSSes, |
| 1273 | num_bss, |
| 1274 | kMetricWifiAvailableBSSesMin, |
| 1275 | kMetricWifiAvailableBSSesMax, |
| 1276 | kMetricWifiAvailableBSSesNumBuckets); |
| 1277 | } |
| 1278 | |
Peter Qiu | 39d4af0 | 2014-04-14 12:24:01 -0700 | [diff] [blame] | 1279 | void Metrics::NotifyServicesOnSameNetwork(int num_services) { |
| 1280 | SendToUMA(kMetricServicesOnSameNetwork, |
| 1281 | num_services, |
| 1282 | kMetricServicesOnSameNetworkMin, |
| 1283 | kMetricServicesOnSameNetworkMax, |
| 1284 | kMetricServicesOnSameNetworkNumBuckets); |
| 1285 | } |
| 1286 | |
Peter Qiu | e783f1c | 2014-05-02 11:42:33 -0700 | [diff] [blame] | 1287 | void Metrics::NotifyUserInitiatedEvent(int event) { |
| 1288 | SendEnumToUMA(kMetricUserInitiatedEvents, |
| 1289 | event, |
| 1290 | kUserInitiatedEventMax); |
| 1291 | } |
| 1292 | |
Peter Qiu | 8e43058 | 2014-04-30 14:12:37 -0700 | [diff] [blame] | 1293 | void Metrics::NotifyWifiTxBitrate(int bitrate) { |
| 1294 | SendToUMA(kMetricWifiTxBitrate, |
| 1295 | bitrate, |
| 1296 | kMetricWifiTxBitrateMin, |
| 1297 | kMetricWifiTxBitrateMax, |
| 1298 | kMetricWifiTxBitrateNumBuckets); |
| 1299 | } |
| 1300 | |
Paul Stewart | 8ae1874 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 1301 | void Metrics::NotifyUserInitiatedConnectionResult(const string& name, |
Peter Qiu | dc4e099 | 2014-05-01 10:02:52 -0700 | [diff] [blame] | 1302 | int result) { |
| 1303 | SendEnumToUMA(name, |
| 1304 | result, |
| 1305 | kUserInitiatedConnectionResultMax); |
| 1306 | } |
| 1307 | |
Peter Qiu | d87179e | 2014-07-10 18:29:22 -0700 | [diff] [blame] | 1308 | void Metrics::NotifyUserInitiatedConnectionFailureReason( |
Paul Stewart | 8ae1874 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 1309 | const string& name, const Service::ConnectFailure failure) { |
Peter Qiu | d87179e | 2014-07-10 18:29:22 -0700 | [diff] [blame] | 1310 | UserInitiatedConnectionFailureReason reason; |
| 1311 | switch (failure) { |
| 1312 | case Service::kFailureBadPassphrase: |
| 1313 | reason = kUserInitiatedConnectionFailureReasonBadPassphrase; |
| 1314 | break; |
| 1315 | case Service::kFailureBadWEPKey: |
| 1316 | reason = kUserInitiatedConnectionFailureReasonBadWEPKey; |
| 1317 | break; |
| 1318 | case Service::kFailureConnect: |
| 1319 | reason = kUserInitiatedConnectionFailureReasonConnect; |
| 1320 | break; |
| 1321 | case Service::kFailureDHCP: |
| 1322 | reason = kUserInitiatedConnectionFailureReasonDHCP; |
| 1323 | break; |
| 1324 | case Service::kFailureDNSLookup: |
| 1325 | reason = kUserInitiatedConnectionFailureReasonDNSLookup; |
| 1326 | break; |
| 1327 | case Service::kFailureEAPAuthentication: |
| 1328 | reason = kUserInitiatedConnectionFailureReasonEAPAuthentication; |
| 1329 | break; |
| 1330 | case Service::kFailureEAPLocalTLS: |
| 1331 | reason = kUserInitiatedConnectionFailureReasonEAPLocalTLS; |
| 1332 | break; |
| 1333 | case Service::kFailureEAPRemoteTLS: |
| 1334 | reason = kUserInitiatedConnectionFailureReasonEAPRemoteTLS; |
| 1335 | break; |
| 1336 | case Service::kFailureOutOfRange: |
| 1337 | reason = kUserInitiatedConnectionFailureReasonOutOfRange; |
| 1338 | break; |
| 1339 | case Service::kFailurePinMissing: |
| 1340 | reason = kUserInitiatedConnectionFailureReasonPinMissing; |
| 1341 | break; |
| 1342 | default: |
| 1343 | reason = kUserInitiatedConnectionFailureReasonUnknown; |
| 1344 | break; |
| 1345 | } |
| 1346 | SendEnumToUMA(name, |
| 1347 | reason, |
| 1348 | kUserInitiatedConnectionFailureReasonMax); |
| 1349 | } |
| 1350 | |
Peter Qiu | f18e771 | 2014-05-20 09:59:46 -0700 | [diff] [blame] | 1351 | void Metrics::NotifyFallbackDNSTestResult(Technology::Identifier technology_id, |
| 1352 | int result) { |
| 1353 | string histogram = GetFullMetricName(kMetricFallbackDNSTestResultSuffix, |
| 1354 | technology_id); |
| 1355 | SendEnumToUMA(histogram, |
Peter Qiu | b9256f3 | 2014-05-09 15:27:29 -0700 | [diff] [blame] | 1356 | result, |
Peter Qiu | f18e771 | 2014-05-20 09:59:46 -0700 | [diff] [blame] | 1357 | kFallbackDNSTestResultMax); |
Peter Qiu | b9256f3 | 2014-05-09 15:27:29 -0700 | [diff] [blame] | 1358 | } |
| 1359 | |
Peter Qiu | dc335f8 | 2014-05-15 10:33:17 -0700 | [diff] [blame] | 1360 | void Metrics::NotifyNetworkProblemDetected(Technology::Identifier technology_id, |
| 1361 | int reason) { |
| 1362 | string histogram = GetFullMetricName(kMetricNetworkProblemDetectedSuffix, |
| 1363 | technology_id); |
| 1364 | SendEnumToUMA(histogram, |
| 1365 | reason, |
| 1366 | kNetworkProblemMax); |
| 1367 | } |
| 1368 | |
Peter Qiu | 700de64 | 2014-07-14 16:31:30 -0700 | [diff] [blame] | 1369 | void Metrics::NotifyDeviceConnectionStatus(ConnectionStatus status) { |
| 1370 | SendEnumToUMA(kMetricDeviceConnectionStatus, status, kConnectionStatusMax); |
| 1371 | } |
| 1372 | |
Paul Stewart | 3bdf1ab | 2014-07-17 19:22:26 -0700 | [diff] [blame] | 1373 | void Metrics::NotifyDhcpClientStatus(DhcpClientStatus status) { |
| 1374 | SendEnumToUMA(kMetricDhcpClientStatus, status, kDhcpClientStatusMax); |
| 1375 | } |
| 1376 | |
Peter Qiu | 300769e | 2014-08-27 11:48:45 -0700 | [diff] [blame] | 1377 | void Metrics::NotifyNetworkConnectionIPType( |
| 1378 | Technology::Identifier technology_id, NetworkConnectionIPType type) { |
| 1379 | string histogram = GetFullMetricName(kMetricNetworkConnectionIPTypeSuffix, |
| 1380 | technology_id); |
| 1381 | SendEnumToUMA(histogram, type, kNetworkConnectionIPTypeMax); |
| 1382 | } |
| 1383 | |
| 1384 | void Metrics::NotifyIPv6ConnectivityStatus(Technology::Identifier technology_id, |
| 1385 | bool status) { |
| 1386 | string histogram = GetFullMetricName(kMetricIPv6ConnectivityStatusSuffix, |
| 1387 | technology_id); |
| 1388 | IPv6ConnectivityStatus ipv6_status = status ? kIPv6ConnectivityStatusYes |
| 1389 | : kIPv6ConnectivityStatusNo; |
| 1390 | SendEnumToUMA(histogram, ipv6_status, kIPv6ConnectivityStatusMax); |
| 1391 | } |
| 1392 | |
Peter Qiu | 94d18af | 2014-09-11 15:54:15 -0700 | [diff] [blame] | 1393 | void Metrics::NotifyDevicePresenceStatus(Technology::Identifier technology_id, |
| 1394 | bool status) { |
| 1395 | string histogram = GetFullMetricName(kMetricDevicePresenceStatusSuffix, |
| 1396 | technology_id); |
| 1397 | DevicePresenceStatus presence = status ? kDevicePresenceStatusYes |
| 1398 | : kDevicePresenceStatusNo; |
| 1399 | SendEnumToUMA(histogram, presence, kDevicePresenceStatusMax); |
| 1400 | } |
| 1401 | |
Peter Qiu | 9f5159e | 2014-09-12 16:50:14 -0700 | [diff] [blame] | 1402 | void Metrics::NotifyDeviceRemovedEvent(Technology::Identifier technology_id) { |
| 1403 | DeviceTechnologyType type; |
| 1404 | switch (technology_id) { |
| 1405 | case Technology::kEthernet: |
| 1406 | type = kDeviceTechnologyTypeEthernet; |
| 1407 | break; |
| 1408 | case Technology::kWifi: |
| 1409 | type = kDeviceTechnologyTypeWifi; |
| 1410 | break; |
| 1411 | case Technology::kWiMax: |
| 1412 | type = kDeviceTechnologyTypeWimax; |
| 1413 | break; |
| 1414 | case Technology::kCellular: |
| 1415 | type = kDeviceTechnologyTypeCellular; |
| 1416 | break; |
| 1417 | default: |
| 1418 | type = kDeviceTechnologyTypeUnknown; |
| 1419 | break; |
| 1420 | } |
| 1421 | SendEnumToUMA(kMetricDeviceRemovedEvent, type, kDeviceTechnologyTypeMax); |
| 1422 | } |
| 1423 | |
Peter Qiu | a057203 | 2014-09-26 10:07:37 -0700 | [diff] [blame] | 1424 | void Metrics::NotifyUnreliableLinkSignalStrength( |
| 1425 | Technology::Identifier technology_id, int signal_strength) { |
| 1426 | string histogram = GetFullMetricName( |
| 1427 | kMetricUnreliableLinkSignalStrengthSuffix, technology_id); |
| 1428 | SendToUMA(histogram, |
| 1429 | signal_strength, |
| 1430 | kMetricSerivceSignalStrengthMin, |
| 1431 | kMetricServiceSignalStrengthMax, |
| 1432 | kMetricServiceSignalStrengthNumBuckets); |
| 1433 | } |
| 1434 | |
Paul Stewart | 8ae1874 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 1435 | bool Metrics::SendEnumToUMA(const string& name, int sample, int max) { |
Rebecca Silberstein | c9c31d8 | 2014-10-21 15:01:00 -0700 | [diff] [blame] | 1436 | SLOG(this, 5) |
mukesh agrawal | 94cde58 | 2013-08-12 17:55:33 -0700 | [diff] [blame] | 1437 | << "Sending enum " << name << " with value " << sample << "."; |
Thieu Le | 48e6d6d | 2011-12-06 00:40:27 +0000 | [diff] [blame] | 1438 | return library_->SendEnumToUMA(name, sample, max); |
| 1439 | } |
| 1440 | |
Paul Stewart | 8ae1874 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 1441 | bool Metrics::SendToUMA(const string& name, int sample, int min, int max, |
Thieu Le | a20cbc2 | 2012-01-09 22:01:43 +0000 | [diff] [blame] | 1442 | int num_buckets) { |
Rebecca Silberstein | c9c31d8 | 2014-10-21 15:01:00 -0700 | [diff] [blame] | 1443 | SLOG(this, 5) |
mukesh agrawal | 94cde58 | 2013-08-12 17:55:33 -0700 | [diff] [blame] | 1444 | << "Sending metric " << name << " with value " << sample << "."; |
Thieu Le | a20cbc2 | 2012-01-09 22:01:43 +0000 | [diff] [blame] | 1445 | return library_->SendToUMA(name, sample, min, max, num_buckets); |
| 1446 | } |
| 1447 | |
Samuel Tan | c36b410 | 2015-01-26 19:34:35 -0800 | [diff] [blame] | 1448 | void Metrics::NotifyWakeOnWiFiThrottled() { |
| 1449 | wake_on_wifi_throttled_ = true; |
| 1450 | } |
| 1451 | |
| 1452 | void Metrics::NotifySuspendWithWakeOnWiFiEnabledDone() { |
| 1453 | WakeOnWiFiThrottled throttled_result = wake_on_wifi_throttled_ |
| 1454 | ? kWakeOnWiFiThrottledTrue |
| 1455 | : kWakeOnWiFiThrottledFalse; |
| 1456 | SendEnumToUMA(kMetricWakeOnWiFiThrottled, throttled_result, |
| 1457 | kWakeOnWiFiThrottledMax); |
| 1458 | } |
| 1459 | |
Samuel Tan | a493343 | 2015-02-06 18:20:41 -0800 | [diff] [blame] | 1460 | void Metrics::NotifyWakeupReasonReceived() { wake_reason_received_ = true; } |
| 1461 | |
Peter Qiu | 1a72f54 | 2015-04-14 16:31:36 -0700 | [diff] [blame] | 1462 | #if !defined(DISABLE_WIFI) |
| 1463 | // TODO(zqiu): Change argument type from WakeOnWiFi::WakeOnWiFiTrigger to |
| 1464 | // Metrics::DarkResumeWakeReason, to remove the dependency for WakeOnWiFi. |
| 1465 | // to remove the dependency for WakeOnWiFi. |
Samuel Tan | a493343 | 2015-02-06 18:20:41 -0800 | [diff] [blame] | 1466 | void Metrics::NotifyWakeOnWiFiOnDarkResume( |
| 1467 | WakeOnWiFi::WakeOnWiFiTrigger reason) { |
| 1468 | WakeReasonReceivedBeforeOnDarkResume result = |
| 1469 | wake_reason_received_ ? kWakeReasonReceivedBeforeOnDarkResumeTrue |
| 1470 | : kWakeReasonReceivedBeforeOnDarkResumeFalse; |
| 1471 | |
| 1472 | SendEnumToUMA(kMetricWakeReasonReceivedBeforeOnDarkResume, result, |
| 1473 | kWakeReasonReceivedBeforeOnDarkResumeMax); |
| 1474 | |
| 1475 | DarkResumeWakeReason wake_reason; |
| 1476 | switch (reason) { |
| 1477 | case WakeOnWiFi::kWakeTriggerPattern: |
| 1478 | wake_reason = kDarkResumeWakeReasonPattern; |
| 1479 | break; |
| 1480 | case WakeOnWiFi::kWakeTriggerDisconnect: |
| 1481 | wake_reason = kDarkResumeWakeReasonDisconnect; |
| 1482 | break; |
| 1483 | case WakeOnWiFi::kWakeTriggerSSID: |
| 1484 | wake_reason = kDarkResumeWakeReasonSSID; |
| 1485 | break; |
| 1486 | case WakeOnWiFi::kWakeTriggerUnsupported: |
| 1487 | default: |
| 1488 | wake_reason = kDarkResumeWakeReasonUnsupported; |
| 1489 | break; |
| 1490 | } |
| 1491 | SendEnumToUMA(kMetricDarkResumeWakeReason, wake_reason, |
| 1492 | kDarkResumeWakeReasonMax); |
| 1493 | } |
Peter Qiu | 1a72f54 | 2015-04-14 16:31:36 -0700 | [diff] [blame] | 1494 | #endif // DISABLE_WIFI |
Samuel Tan | a493343 | 2015-02-06 18:20:41 -0800 | [diff] [blame] | 1495 | |
Samuel Tan | d1bec5d | 2015-03-06 12:49:02 -0800 | [diff] [blame] | 1496 | void Metrics::NotifyScanStartedInDarkResume(bool is_active_scan) { |
| 1497 | DarkResumeScanType scan_type = |
| 1498 | is_active_scan ? kDarkResumeScanTypeActive : kDarkResumeScanTypePassive; |
| 1499 | SendEnumToUMA(kMetricDarkResumeScanType, scan_type, kDarkResumeScanTypeMax); |
| 1500 | } |
| 1501 | |
Samuel Tan | 029feac | 2015-03-27 16:53:01 -0700 | [diff] [blame] | 1502 | void Metrics::NotifyDarkResumeScanRetry() { |
| 1503 | ++dark_resume_scan_retries_; |
| 1504 | } |
| 1505 | |
| 1506 | void Metrics::NotifyBeforeSuspendActions(bool is_connected, |
| 1507 | bool in_dark_resume) { |
| 1508 | if (in_dark_resume && dark_resume_scan_retries_) { |
| 1509 | DarkResumeScanRetryResult connect_result = |
| 1510 | is_connected ? kDarkResumeScanRetryResultConnected |
| 1511 | : kDarkResumeScanRetryResultNotConnected; |
| 1512 | SendEnumToUMA(kMetricDarkResumeScanRetryResult, connect_result, |
| 1513 | kDarkResumeScanRetryResultMax); |
| 1514 | } |
| 1515 | } |
| 1516 | |
Paul Stewart | 8ae1874 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 1517 | void Metrics::InitializeCommonServiceMetrics(const Service& service) { |
Wade Guthrie | 7ac610b | 2013-10-01 17:48:14 -0700 | [diff] [blame] | 1518 | Technology::Identifier technology = service.technology(); |
mukesh agrawal | 132e96f | 2014-04-24 11:49:42 -0700 | [diff] [blame] | 1519 | string histogram = GetFullMetricName(kMetricTimeToConfigMillisecondsSuffix, |
Thieu Le | 48e6d6d | 2011-12-06 00:40:27 +0000 | [diff] [blame] | 1520 | technology); |
| 1521 | AddServiceStateTransitionTimer( |
| 1522 | service, |
| 1523 | histogram, |
| 1524 | Service::kStateConfiguring, |
Paul Stewart | 20088d8 | 2012-02-16 06:58:55 -0800 | [diff] [blame] | 1525 | Service::kStateConnected); |
mukesh agrawal | 132e96f | 2014-04-24 11:49:42 -0700 | [diff] [blame] | 1526 | histogram = GetFullMetricName(kMetricTimeToPortalMillisecondsSuffix, |
| 1527 | technology); |
Thieu Le | 48e6d6d | 2011-12-06 00:40:27 +0000 | [diff] [blame] | 1528 | AddServiceStateTransitionTimer( |
| 1529 | service, |
| 1530 | histogram, |
Paul Stewart | 20088d8 | 2012-02-16 06:58:55 -0800 | [diff] [blame] | 1531 | Service::kStateConnected, |
Thieu Le | 48e6d6d | 2011-12-06 00:40:27 +0000 | [diff] [blame] | 1532 | Service::kStatePortal); |
mukesh agrawal | 132e96f | 2014-04-24 11:49:42 -0700 | [diff] [blame] | 1533 | histogram = GetFullMetricName(kMetricTimeToOnlineMillisecondsSuffix, |
| 1534 | technology); |
Thieu Le | 48e6d6d | 2011-12-06 00:40:27 +0000 | [diff] [blame] | 1535 | AddServiceStateTransitionTimer( |
| 1536 | service, |
| 1537 | histogram, |
Paul Stewart | 20088d8 | 2012-02-16 06:58:55 -0800 | [diff] [blame] | 1538 | Service::kStateConnected, |
Thieu Le | 48e6d6d | 2011-12-06 00:40:27 +0000 | [diff] [blame] | 1539 | Service::kStateOnline); |
| 1540 | } |
| 1541 | |
| 1542 | void Metrics::UpdateServiceStateTransitionMetrics( |
Paul Stewart | 8ae1874 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 1543 | ServiceMetrics* service_metrics, |
Thieu Le | 48e6d6d | 2011-12-06 00:40:27 +0000 | [diff] [blame] | 1544 | Service::ConnectState new_state) { |
Paul Stewart | 8ae1874 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 1545 | const char* state_string = Service::ConnectStateToString(new_state); |
Rebecca Silberstein | c9c31d8 | 2014-10-21 15:01:00 -0700 | [diff] [blame] | 1546 | SLOG(this, 5) << __func__ << ": new_state=" << state_string; |
Paul Stewart | 8ae1874 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 1547 | TimerReportersList& start_timers = service_metrics->start_on_state[new_state]; |
| 1548 | for (auto& start_timer : start_timers) { |
Rebecca Silberstein | c9c31d8 | 2014-10-21 15:01:00 -0700 | [diff] [blame] | 1549 | SLOG(this, 5) << "Starting timer for " << start_timer->histogram_name() |
| 1550 | << " due to new state " << state_string << "."; |
mukesh agrawal | 6f4ab42 | 2013-08-13 12:51:55 -0700 | [diff] [blame] | 1551 | start_timer->Start(); |
| 1552 | } |
Thieu Le | 48e6d6d | 2011-12-06 00:40:27 +0000 | [diff] [blame] | 1553 | |
Paul Stewart | 8ae1874 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 1554 | TimerReportersList& stop_timers = service_metrics->stop_on_state[new_state]; |
| 1555 | for (auto& stop_timer : stop_timers) { |
Rebecca Silberstein | c9c31d8 | 2014-10-21 15:01:00 -0700 | [diff] [blame] | 1556 | SLOG(this, 5) << "Stopping timer for " << stop_timer->histogram_name() |
| 1557 | << " due to new state " << state_string << "."; |
mukesh agrawal | 6f4ab42 | 2013-08-13 12:51:55 -0700 | [diff] [blame] | 1558 | if (stop_timer->Stop()) |
| 1559 | stop_timer->ReportMilliseconds(); |
Thieu Le | 48e6d6d | 2011-12-06 00:40:27 +0000 | [diff] [blame] | 1560 | } |
| 1561 | } |
| 1562 | |
Paul Stewart | 8ae1874 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 1563 | void Metrics::SendServiceFailure(const Service& service) { |
Peter Qiu | 27df364 | 2014-09-19 09:50:54 -0700 | [diff] [blame] | 1564 | NetworkServiceError error = kNetworkServiceErrorUnknown; |
| 1565 | // Explicitly map all possible failures. So when new failures are added, |
| 1566 | // they will need to be mapped as well. Otherwise, the compiler will |
| 1567 | // complain. |
| 1568 | switch (service.failure()) { |
| 1569 | case Service::kFailureUnknown: |
| 1570 | case Service::kFailureMax: |
| 1571 | error = kNetworkServiceErrorUnknown; |
| 1572 | break; |
| 1573 | case Service::kFailureAAA: |
| 1574 | error = kNetworkServiceErrorAAA; |
| 1575 | break; |
| 1576 | case Service::kFailureActivation: |
| 1577 | error = kNetworkServiceErrorActivation; |
| 1578 | break; |
| 1579 | case Service::kFailureBadPassphrase: |
| 1580 | error = kNetworkServiceErrorBadPassphrase; |
| 1581 | break; |
| 1582 | case Service::kFailureBadWEPKey: |
| 1583 | error = kNetworkServiceErrorBadWEPKey; |
| 1584 | break; |
| 1585 | case Service::kFailureConnect: |
| 1586 | error = kNetworkServiceErrorConnect; |
| 1587 | break; |
| 1588 | case Service::kFailureDHCP: |
| 1589 | error = kNetworkServiceErrorDHCP; |
| 1590 | break; |
| 1591 | case Service::kFailureDNSLookup: |
| 1592 | error = kNetworkServiceErrorDNSLookup; |
| 1593 | break; |
| 1594 | case Service::kFailureEAPAuthentication: |
| 1595 | error = kNetworkServiceErrorEAPAuthentication; |
| 1596 | break; |
| 1597 | case Service::kFailureEAPLocalTLS: |
| 1598 | error = kNetworkServiceErrorEAPLocalTLS; |
| 1599 | break; |
| 1600 | case Service::kFailureEAPRemoteTLS: |
| 1601 | error = kNetworkServiceErrorEAPRemoteTLS; |
| 1602 | break; |
| 1603 | case Service::kFailureHTTPGet: |
| 1604 | error = kNetworkServiceErrorHTTPGet; |
| 1605 | break; |
| 1606 | case Service::kFailureIPSecCertAuth: |
| 1607 | error = kNetworkServiceErrorIPSecCertAuth; |
| 1608 | break; |
| 1609 | case Service::kFailureIPSecPSKAuth: |
| 1610 | error = kNetworkServiceErrorIPSecPSKAuth; |
| 1611 | break; |
| 1612 | case Service::kFailureInternal: |
| 1613 | error = kNetworkServiceErrorInternal; |
| 1614 | break; |
| 1615 | case Service::kFailureNeedEVDO: |
| 1616 | error = kNetworkServiceErrorNeedEVDO; |
| 1617 | break; |
| 1618 | case Service::kFailureNeedHomeNetwork: |
| 1619 | error = kNetworkServiceErrorNeedHomeNetwork; |
| 1620 | break; |
| 1621 | case Service::kFailureOTASP: |
| 1622 | error = kNetworkServiceErrorOTASP; |
| 1623 | break; |
| 1624 | case Service::kFailureOutOfRange: |
| 1625 | error = kNetworkServiceErrorOutOfRange; |
| 1626 | break; |
| 1627 | case Service::kFailurePPPAuth: |
| 1628 | error = kNetworkServiceErrorPPPAuth; |
| 1629 | break; |
| 1630 | case Service::kFailurePinMissing: |
| 1631 | error = kNetworkServiceErrorPinMissing; |
| 1632 | break; |
| 1633 | } |
| 1634 | |
Thieu Le | 48e6d6d | 2011-12-06 00:40:27 +0000 | [diff] [blame] | 1635 | library_->SendEnumToUMA(kMetricNetworkServiceErrors, |
Peter Qiu | 27df364 | 2014-09-19 09:50:54 -0700 | [diff] [blame] | 1636 | error, |
| 1637 | kNetworkServiceErrorMax); |
Thieu Le | 48e6d6d | 2011-12-06 00:40:27 +0000 | [diff] [blame] | 1638 | } |
| 1639 | |
Paul Stewart | 8ae1874 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 1640 | Metrics::DeviceMetrics* Metrics::GetDeviceMetrics(int interface_index) const { |
Thieu Le | 9abd674 | 2013-01-23 23:35:37 -0800 | [diff] [blame] | 1641 | DeviceMetricsLookupMap::const_iterator it = |
| 1642 | devices_metrics_.find(interface_index); |
Thieu Le | ce4483e | 2013-01-23 15:12:03 -0800 | [diff] [blame] | 1643 | if (it == devices_metrics_.end()) { |
Rebecca Silberstein | c9c31d8 | 2014-10-21 15:01:00 -0700 | [diff] [blame] | 1644 | SLOG(this, 2) << __func__ << ": device " << interface_index |
| 1645 | << " not found"; |
Ben Chan | cc225ef | 2014-09-30 13:26:51 -0700 | [diff] [blame] | 1646 | return nullptr; |
Thieu Le | ce4483e | 2013-01-23 15:12:03 -0800 | [diff] [blame] | 1647 | } |
| 1648 | return it->second.get(); |
| 1649 | } |
| 1650 | |
Paul Stewart | 8ae1874 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 1651 | void Metrics::AutoConnectMetricsReset(DeviceMetrics* device_metrics) { |
Thieu Le | 7cf36b0 | 2013-01-30 17:15:56 -0800 | [diff] [blame] | 1652 | device_metrics->auto_connect_tries = 0; |
| 1653 | device_metrics->auto_connect_timer->Reset(); |
| 1654 | } |
| 1655 | |
Paul Stewart | 8ae1874 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 1656 | void Metrics::set_library(MetricsLibraryInterface* library) { |
Thieu Le | 48e6d6d | 2011-12-06 00:40:27 +0000 | [diff] [blame] | 1657 | chromeos_metrics::TimerReporter::set_metrics_lib(library); |
| 1658 | library_ = library; |
| 1659 | } |
| 1660 | |
| 1661 | } // namespace shill |