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 <algorithm> |
9 #include <map> | 10 #include <map> |
10 #include <set> | 11 #include <set> |
11 #include <unordered_set> | 12 #include <unordered_set> |
12 | 13 |
13 #include "base/hash.h" | 14 #include "base/hash.h" |
14 #include "base/metrics/histogram_macros.h" | 15 #include "base/metrics/histogram_macros.h" |
15 #include "base/metrics/sparse_histogram.h" | 16 #include "base/metrics/sparse_histogram.h" |
16 #include "device/bluetooth/bluetooth_uuid.h" | 17 #include "device/bluetooth/bluetooth_uuid.h" |
17 | 18 |
18 using device::BluetoothUUID; | 19 using device::BluetoothUUID; |
(...skipping 16 matching lines...) Expand all Loading... |
35 | 36 |
36 // Strip off the sign bit because UMA doesn't support negative values, | 37 // Strip off the sign bit because UMA doesn't support negative values, |
37 // but takes a signed int as input. | 38 // but takes a signed int as input. |
38 return static_cast<int>(data & 0x7fffffff); | 39 return static_cast<int>(data & 0x7fffffff); |
39 } | 40 } |
40 | 41 |
41 int HashUUID(const base::Optional<BluetoothUUID>& uuid) { | 42 int HashUUID(const base::Optional<BluetoothUUID>& uuid) { |
42 return uuid ? HashUUID(uuid->canonical_value()) : 0; | 43 return uuid ? HashUUID(uuid->canonical_value()) : 0; |
43 } | 44 } |
44 | 45 |
| 46 // The maximum number of devices that needs to be recorded. |
| 47 const size_t kMaxNumOfDevices = 100; |
| 48 |
45 } // namespace | 49 } // namespace |
46 | 50 |
47 namespace content { | 51 namespace content { |
48 | 52 |
49 // General | 53 // General |
50 | 54 |
51 void RecordWebBluetoothFunctionCall(UMAWebBluetoothFunction function) { | 55 void RecordWebBluetoothFunctionCall(UMAWebBluetoothFunction function) { |
52 UMA_HISTOGRAM_ENUMERATION("Bluetooth.Web.FunctionCall.Count", | 56 UMA_HISTOGRAM_ENUMERATION("Bluetooth.Web.FunctionCall.Count", |
53 static_cast<int>(function), | 57 static_cast<int>(function), |
54 static_cast<int>(UMAWebBluetoothFunction::COUNT)); | 58 static_cast<int>(UMAWebBluetoothFunction::COUNT)); |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 rssi); | 350 rssi); |
347 } | 351 } |
348 | 352 |
349 void RecordRSSISignalStrengthLevel(UMARSSISignalStrengthLevel level) { | 353 void RecordRSSISignalStrengthLevel(UMARSSISignalStrengthLevel level) { |
350 UMA_HISTOGRAM_ENUMERATION( | 354 UMA_HISTOGRAM_ENUMERATION( |
351 "Bluetooth.Web.RequestDevice.RSSISignalStrengthLevel", | 355 "Bluetooth.Web.RequestDevice.RSSISignalStrengthLevel", |
352 static_cast<int>(level), | 356 static_cast<int>(level), |
353 static_cast<int>(UMARSSISignalStrengthLevel::COUNT)); | 357 static_cast<int>(UMARSSISignalStrengthLevel::COUNT)); |
354 } | 358 } |
355 | 359 |
| 360 void RecordNumOfDevices(bool accept_all_devices, size_t num_of_devices) { |
| 361 if (accept_all_devices) { |
| 362 UMA_HISTOGRAM_SPARSE_SLOWLY( |
| 363 "Bluetooth.Web.RequestDevice." |
| 364 "NumOfDevicesInChooserWhenNotAcceptingAllDevices", |
| 365 std::min(num_of_devices, kMaxNumOfDevices)); |
| 366 } |
| 367 } |
| 368 |
356 } // namespace content | 369 } // namespace content |
OLD | NEW |