| OLD | NEW | 
|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 #include "content/browser/bluetooth/bluetooth_metrics.h" | 5 #include "content/browser/bluetooth/bluetooth_metrics.h" | 
| 6 | 6 | 
| 7 #include <map> | 7 #include <map> | 
| 8 #include <set> | 8 #include <set> | 
| 9 #include "base/hash.h" | 9 #include "base/hash.h" | 
| 10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" | 
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 96 } | 96 } | 
| 97 | 97 | 
| 98 // connectGATT | 98 // connectGATT | 
| 99 | 99 | 
| 100 void RecordConnectGATTOutcome(UMAConnectGATTOutcome outcome) { | 100 void RecordConnectGATTOutcome(UMAConnectGATTOutcome outcome) { | 
| 101   UMA_HISTOGRAM_ENUMERATION("Bluetooth.Web.ConnectGATT.Outcome", | 101   UMA_HISTOGRAM_ENUMERATION("Bluetooth.Web.ConnectGATT.Outcome", | 
| 102                             static_cast<int>(outcome), | 102                             static_cast<int>(outcome), | 
| 103                             static_cast<int>(UMAConnectGATTOutcome::COUNT)); | 103                             static_cast<int>(UMAConnectGATTOutcome::COUNT)); | 
| 104 } | 104 } | 
| 105 | 105 | 
|  | 106 void RecordConnectGATTOutcome(CacheQueryOutcome outcome) { | 
|  | 107   DCHECK(outcome == CacheQueryOutcome::NO_DEVICE); | 
|  | 108   RecordConnectGATTOutcome(UMAConnectGATTOutcome::NO_DEVICE); | 
|  | 109 } | 
|  | 110 | 
| 106 void RecordConnectGATTTimeSuccess(const base::TimeDelta& duration) { | 111 void RecordConnectGATTTimeSuccess(const base::TimeDelta& duration) { | 
| 107   UMA_HISTOGRAM_MEDIUM_TIMES("Bluetooth.Web.ConnectGATT.TimeSuccess", duration); | 112   UMA_HISTOGRAM_MEDIUM_TIMES("Bluetooth.Web.ConnectGATT.TimeSuccess", duration); | 
| 108 } | 113 } | 
| 109 | 114 | 
| 110 void RecordConnectGATTTimeFailed(const base::TimeDelta& duration) { | 115 void RecordConnectGATTTimeFailed(const base::TimeDelta& duration) { | 
| 111   UMA_HISTOGRAM_MEDIUM_TIMES("Bluetooth.Web.ConnectGATT.TimeFailed", duration); | 116   UMA_HISTOGRAM_MEDIUM_TIMES("Bluetooth.Web.ConnectGATT.TimeFailed", duration); | 
| 112 } | 117 } | 
| 113 | 118 | 
| 114 // getPrimaryService | 119 // getPrimaryService | 
| 115 | 120 | 
| 116 void RecordGetPrimaryServiceService(const BluetoothUUID& service) { | 121 void RecordGetPrimaryServiceService(const BluetoothUUID& service) { | 
| 117   // TODO(ortuno): Use a macro to histogram strings. | 122   // TODO(ortuno): Use a macro to histogram strings. | 
| 118   // http://crbug.com/520284 | 123   // http://crbug.com/520284 | 
| 119   UMA_HISTOGRAM_SPARSE_SLOWLY("Bluetooth.Web.GetPrimaryService.Services", | 124   UMA_HISTOGRAM_SPARSE_SLOWLY("Bluetooth.Web.GetPrimaryService.Services", | 
| 120                               HashUUID(service.canonical_value())); | 125                               HashUUID(service.canonical_value())); | 
| 121 } | 126 } | 
| 122 | 127 | 
| 123 void RecordGetPrimaryServiceOutcome(UMAGetPrimaryServiceOutcome outcome) { | 128 void RecordGetPrimaryServiceOutcome(UMAGetPrimaryServiceOutcome outcome) { | 
| 124   UMA_HISTOGRAM_ENUMERATION( | 129   UMA_HISTOGRAM_ENUMERATION( | 
| 125       "Bluetooth.Web.GetPrimaryService.Outcome", static_cast<int>(outcome), | 130       "Bluetooth.Web.GetPrimaryService.Outcome", static_cast<int>(outcome), | 
| 126       static_cast<int>(UMAGetPrimaryServiceOutcome::COUNT)); | 131       static_cast<int>(UMAGetPrimaryServiceOutcome::COUNT)); | 
| 127 } | 132 } | 
| 128 | 133 | 
|  | 134 void RecordGetPrimaryServiceOutcome(CacheQueryOutcome outcome) { | 
|  | 135   DCHECK(outcome == CacheQueryOutcome::NO_DEVICE); | 
|  | 136   RecordGetPrimaryServiceOutcome(UMAGetPrimaryServiceOutcome::NO_DEVICE); | 
|  | 137 } | 
|  | 138 | 
| 129 // getCharacteristic | 139 // getCharacteristic | 
| 130 | 140 | 
| 131 void RecordGetCharacteristicOutcome(UMAGetCharacteristicOutcome outcome) { | 141 void RecordGetCharacteristicOutcome(UMAGetCharacteristicOutcome outcome) { | 
| 132   UMA_HISTOGRAM_ENUMERATION( | 142   UMA_HISTOGRAM_ENUMERATION( | 
| 133       "Bluetooth.Web.GetCharacteristic.Outcome", static_cast<int>(outcome), | 143       "Bluetooth.Web.GetCharacteristic.Outcome", static_cast<int>(outcome), | 
| 134       static_cast<int>(UMAGetCharacteristicOutcome::COUNT)); | 144       static_cast<int>(UMAGetCharacteristicOutcome::COUNT)); | 
| 135 } | 145 } | 
| 136 | 146 | 
|  | 147 void RecordGetCharacteristicOutcome(CacheQueryOutcome outcome) { | 
|  | 148   switch (outcome) { | 
|  | 149     case CacheQueryOutcome::SUCCESS: | 
|  | 150     case CacheQueryOutcome::BAD_RENDERER: | 
|  | 151       NOTIMPLEMENTED() << "No need to record a success or renderer crash"; | 
|  | 152       return; | 
|  | 153     case CacheQueryOutcome::NO_DEVICE: | 
|  | 154       RecordGetCharacteristicOutcome(UMAGetCharacteristicOutcome::NO_DEVICE); | 
|  | 155       return; | 
|  | 156     case CacheQueryOutcome::NO_SERVICE: | 
|  | 157       RecordGetCharacteristicOutcome(UMAGetCharacteristicOutcome::NO_SERVICE); | 
|  | 158       return; | 
|  | 159     case CacheQueryOutcome::NO_CHARACTERISTIC: | 
|  | 160       NOTIMPLEMENTED(); | 
|  | 161       return; | 
|  | 162   } | 
|  | 163 } | 
|  | 164 | 
| 137 void RecordGetCharacteristicCharacteristic(const std::string& characteristic) { | 165 void RecordGetCharacteristicCharacteristic(const std::string& characteristic) { | 
| 138   UMA_HISTOGRAM_SPARSE_SLOWLY("Bluetooth.Web.GetCharacteristic.Characteristic", | 166   UMA_HISTOGRAM_SPARSE_SLOWLY("Bluetooth.Web.GetCharacteristic.Characteristic", | 
| 139                               HashUUID(characteristic)); | 167                               HashUUID(characteristic)); | 
| 140 } | 168 } | 
| 141 | 169 | 
| 142 // GATT Operations | 170 // GATT Operations | 
| 143 | 171 | 
| 144 void RecordGATTOperationOutcome(UMAGATTOperation operation, | 172 void RecordGATTOperationOutcome(UMAGATTOperation operation, | 
| 145                                 UMAGATTOperationOutcome outcome) { | 173                                 UMAGATTOperationOutcome outcome) { | 
| 146   switch (operation) { | 174   switch (operation) { | 
| 147     case UMAGATTOperation::CHARACTERISTIC_READ: | 175     case UMAGATTOperation::CHARACTERISTIC_READ: | 
| 148       RecordCharacteristicReadValueOutcome(outcome); | 176       RecordCharacteristicReadValueOutcome(outcome); | 
| 149       return; | 177       return; | 
| 150     case UMAGATTOperation::CHARACTERISTIC_WRITE: | 178     case UMAGATTOperation::CHARACTERISTIC_WRITE: | 
| 151       RecordCharacteristicWriteValueOutcome(outcome); | 179       RecordCharacteristicWriteValueOutcome(outcome); | 
| 152       return; | 180       return; | 
| 153     case UMAGATTOperation::START_NOTIFICATIONS: | 181     case UMAGATTOperation::START_NOTIFICATIONS: | 
| 154       RecordStartNotificationsOutcome(outcome); | 182       RecordStartNotificationsOutcome(outcome); | 
| 155       return; | 183       return; | 
| 156     case UMAGATTOperation::COUNT: | 184     case UMAGATTOperation::COUNT: | 
| 157       NOTREACHED(); | 185       NOTREACHED(); | 
| 158       return; | 186       return; | 
| 159   } | 187   } | 
| 160   NOTREACHED(); | 188   NOTREACHED(); | 
| 161 } | 189 } | 
| 162 | 190 | 
|  | 191 static UMAGATTOperationOutcome TranslateCacheQueryOutcomeToGATTOperationOutcome( | 
|  | 192     CacheQueryOutcome outcome) { | 
|  | 193   switch (outcome) { | 
|  | 194     case CacheQueryOutcome::SUCCESS: | 
|  | 195     case CacheQueryOutcome::BAD_RENDERER: | 
|  | 196       NOTIMPLEMENTED() << "No need to record success or renderer crash"; | 
|  | 197       return UMAGATTOperationOutcome::NOT_SUPPORTED; | 
|  | 198     case CacheQueryOutcome::NO_DEVICE: | 
|  | 199       return UMAGATTOperationOutcome::NO_DEVICE; | 
|  | 200     case CacheQueryOutcome::NO_SERVICE: | 
|  | 201       return UMAGATTOperationOutcome::NO_SERVICE; | 
|  | 202     case CacheQueryOutcome::NO_CHARACTERISTIC: | 
|  | 203       return UMAGATTOperationOutcome::NO_CHARACTERISTIC; | 
|  | 204   } | 
|  | 205 } | 
|  | 206 | 
| 163 // Characteristic.readValue | 207 // Characteristic.readValue | 
| 164 | 208 | 
| 165 // static | 209 // static | 
| 166 void RecordCharacteristicReadValueOutcome(UMAGATTOperationOutcome outcome) { | 210 void RecordCharacteristicReadValueOutcome(UMAGATTOperationOutcome outcome) { | 
| 167   UMA_HISTOGRAM_ENUMERATION("Bluetooth.Web.Characteristic.ReadValue.Outcome", | 211   UMA_HISTOGRAM_ENUMERATION("Bluetooth.Web.Characteristic.ReadValue.Outcome", | 
| 168                             static_cast<int>(outcome), | 212                             static_cast<int>(outcome), | 
| 169                             static_cast<int>(UMAGATTOperationOutcome::COUNT)); | 213                             static_cast<int>(UMAGATTOperationOutcome::COUNT)); | 
| 170 } | 214 } | 
| 171 | 215 | 
|  | 216 void RecordCharacteristicReadValueOutcome(CacheQueryOutcome outcome) { | 
|  | 217   RecordCharacteristicReadValueOutcome( | 
|  | 218       TranslateCacheQueryOutcomeToGATTOperationOutcome(outcome)); | 
|  | 219 } | 
|  | 220 | 
| 172 // Characteristic.writeValue | 221 // Characteristic.writeValue | 
| 173 | 222 | 
| 174 void RecordCharacteristicWriteValueOutcome(UMAGATTOperationOutcome outcome) { | 223 void RecordCharacteristicWriteValueOutcome(UMAGATTOperationOutcome outcome) { | 
| 175   UMA_HISTOGRAM_ENUMERATION("Bluetooth.Web.Characteristic.WriteValue.Outcome", | 224   UMA_HISTOGRAM_ENUMERATION("Bluetooth.Web.Characteristic.WriteValue.Outcome", | 
| 176                             static_cast<int>(outcome), | 225                             static_cast<int>(outcome), | 
| 177                             static_cast<int>(UMAGATTOperationOutcome::COUNT)); | 226                             static_cast<int>(UMAGATTOperationOutcome::COUNT)); | 
| 178 } | 227 } | 
| 179 | 228 | 
|  | 229 void RecordCharacteristicWriteValueOutcome(CacheQueryOutcome outcome) { | 
|  | 230   RecordCharacteristicWriteValueOutcome( | 
|  | 231       TranslateCacheQueryOutcomeToGATTOperationOutcome(outcome)); | 
|  | 232 } | 
|  | 233 | 
| 180 // Characteristic.startNotifications | 234 // Characteristic.startNotifications | 
| 181 void RecordStartNotificationsOutcome(UMAGATTOperationOutcome outcome) { | 235 void RecordStartNotificationsOutcome(UMAGATTOperationOutcome outcome) { | 
| 182   UMA_HISTOGRAM_ENUMERATION( | 236   UMA_HISTOGRAM_ENUMERATION( | 
| 183       "Bluetooth.Web.Characteristic.StartNotifications.Outcome", | 237       "Bluetooth.Web.Characteristic.StartNotifications.Outcome", | 
| 184       static_cast<int>(outcome), | 238       static_cast<int>(outcome), | 
| 185       static_cast<int>(UMAGATTOperationOutcome::COUNT)); | 239       static_cast<int>(UMAGATTOperationOutcome::COUNT)); | 
| 186 } | 240 } | 
| 187 | 241 | 
|  | 242 void RecordStartNotificationsOutcome(CacheQueryOutcome outcome) { | 
|  | 243   RecordStartNotificationsOutcome( | 
|  | 244       TranslateCacheQueryOutcomeToGATTOperationOutcome(outcome)); | 
|  | 245 } | 
|  | 246 | 
| 188 }  // namespace content | 247 }  // namespace content | 
| OLD | NEW | 
|---|