| 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 <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <set> | 10 #include <set> |
| 11 #include "base/hash.h" | 11 #include "base/hash.h" |
| 12 #include "base/metrics/histogram_macros.h" | 12 #include "base/metrics/histogram_macros.h" |
| 13 #include "base/metrics/sparse_histogram.h" | 13 #include "base/metrics/sparse_histogram.h" |
| 14 #include "content/common/bluetooth/bluetooth_scan_filter.h" | 14 #include "content/common/bluetooth/bluetooth_scan_filter.h" |
| 15 #include "device/bluetooth/bluetooth_uuid.h" | 15 #include "device/bluetooth/bluetooth_uuid.h" |
| 16 | 16 |
| 17 using device::BluetoothUUID; | 17 using device::BluetoothUUID; |
| 18 | 18 |
| 19 namespace { | 19 namespace { |
| 20 // TODO(ortuno): Remove once we have a macro to histogram strings. | |
| 21 // http://crbug.com/520284 | |
| 22 int HashUUID(const std::string& uuid) { | |
| 23 uint32_t data = base::SuperFastHash(uuid.data(), uuid.size()); | |
| 24 | 20 |
| 25 // Strip off the signed bit because UMA doesn't support negative values, | 21 // Generates a hash from a canonical UUID string suitable for |
| 22 // UMA_HISTOGRAM_SPARSE_SLOWLY (positive int). |
| 23 // |
| 24 // Hash values can be produced manually using tool: bluetooth_metrics_hash. |
| 25 int HashUUID(const std::string& canonical_uuid) { |
| 26 DCHECK(canonical_uuid == BluetoothUUID(canonical_uuid).canonical_value()); |
| 27 |
| 28 // TODO(520284): Other than verifying that uuid is canonical, this logic |
| 29 // should be migrated to a dedicated histogram macro for hashed strings. |
| 30 uint32_t data = |
| 31 base::SuperFastHash(canonical_uuid.data(), canonical_uuid.size()); |
| 32 |
| 33 // Strip off the sign bit because UMA doesn't support negative values, |
| 26 // but takes a signed int as input. | 34 // but takes a signed int as input. |
| 27 return static_cast<int>(data & 0x7fffffff); | 35 return static_cast<int>(data & 0x7fffffff); |
| 28 } | 36 } |
| 29 } // namespace | 37 } // namespace |
| 30 | 38 |
| 31 namespace content { | 39 namespace content { |
| 32 | 40 |
| 33 // General | 41 // General |
| 34 | 42 |
| 35 void RecordWebBluetoothFunctionCall(UMAWebBluetoothFunction function) { | 43 void RecordWebBluetoothFunctionCall(UMAWebBluetoothFunction function) { |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 static_cast<int>(outcome), | 284 static_cast<int>(outcome), |
| 277 static_cast<int>(UMAGATTOperationOutcome::COUNT)); | 285 static_cast<int>(UMAGATTOperationOutcome::COUNT)); |
| 278 } | 286 } |
| 279 | 287 |
| 280 void RecordStartNotificationsOutcome(CacheQueryOutcome outcome) { | 288 void RecordStartNotificationsOutcome(CacheQueryOutcome outcome) { |
| 281 RecordStartNotificationsOutcome( | 289 RecordStartNotificationsOutcome( |
| 282 TranslateCacheQueryOutcomeToGATTOperationOutcome(outcome)); | 290 TranslateCacheQueryOutcomeToGATTOperationOutcome(outcome)); |
| 283 } | 291 } |
| 284 | 292 |
| 285 } // namespace content | 293 } // namespace content |
| OLD | NEW |