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> |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 | 56 |
57 // requestDevice() | 57 // requestDevice() |
58 | 58 |
59 void RecordRequestDeviceOutcome(UMARequestDeviceOutcome outcome) { | 59 void RecordRequestDeviceOutcome(UMARequestDeviceOutcome outcome) { |
60 UMA_HISTOGRAM_ENUMERATION("Bluetooth.Web.RequestDevice.Outcome", | 60 UMA_HISTOGRAM_ENUMERATION("Bluetooth.Web.RequestDevice.Outcome", |
61 static_cast<int>(outcome), | 61 static_cast<int>(outcome), |
62 static_cast<int>(UMARequestDeviceOutcome::COUNT)); | 62 static_cast<int>(UMARequestDeviceOutcome::COUNT)); |
63 } | 63 } |
64 | 64 |
65 static void RecordRequestDeviceFilters( | 65 static void RecordRequestDeviceFilters( |
66 const mojo::Array<blink::mojom::WebBluetoothScanFilterPtr>& filters) { | 66 const std::vector<blink::mojom::WebBluetoothScanFilterPtr>& filters) { |
67 UMA_HISTOGRAM_COUNTS_100("Bluetooth.Web.RequestDevice.Filters.Count", | 67 UMA_HISTOGRAM_COUNTS_100("Bluetooth.Web.RequestDevice.Filters.Count", |
68 filters.size()); | 68 filters.size()); |
69 for (const auto& filter : filters) { | 69 for (const auto& filter : filters) { |
| 70 if (!filter->services) |
| 71 continue; |
70 UMA_HISTOGRAM_COUNTS_100("Bluetooth.Web.RequestDevice.FilterSize", | 72 UMA_HISTOGRAM_COUNTS_100("Bluetooth.Web.RequestDevice.FilterSize", |
71 filter->services.size()); | 73 filter->services->size()); |
72 for (const base::Optional<BluetoothUUID>& service : filter->services) { | 74 for (const BluetoothUUID& service : filter->services.value()) { |
73 // TODO(ortuno): Use a macro to histogram strings. | 75 // TODO(ortuno): Use a macro to histogram strings. |
74 // http://crbug.com/520284 | 76 // http://crbug.com/520284 |
75 UMA_HISTOGRAM_SPARSE_SLOWLY( | 77 UMA_HISTOGRAM_SPARSE_SLOWLY( |
76 "Bluetooth.Web.RequestDevice.Filters.Services", HashUUID(service)); | 78 "Bluetooth.Web.RequestDevice.Filters.Services", HashUUID(service)); |
77 } | 79 } |
78 } | 80 } |
79 } | 81 } |
80 | 82 |
81 static void RecordRequestDeviceOptionalServices( | 83 static void RecordRequestDeviceOptionalServices( |
82 const mojo::Array<base::Optional<BluetoothUUID>>& optional_services) { | 84 const std::vector<BluetoothUUID>& optional_services) { |
83 UMA_HISTOGRAM_COUNTS_100("Bluetooth.Web.RequestDevice.OptionalServices.Count", | 85 UMA_HISTOGRAM_COUNTS_100("Bluetooth.Web.RequestDevice.OptionalServices.Count", |
84 optional_services.size()); | 86 optional_services.size()); |
85 for (const base::Optional<BluetoothUUID>& service : optional_services) { | 87 for (const BluetoothUUID& service : optional_services) { |
86 // TODO(ortuno): Use a macro to histogram strings. | 88 // TODO(ortuno): Use a macro to histogram strings. |
87 // http://crbug.com/520284 | 89 // http://crbug.com/520284 |
88 UMA_HISTOGRAM_SPARSE_SLOWLY( | 90 UMA_HISTOGRAM_SPARSE_SLOWLY( |
89 "Bluetooth.Web.RequestDevice.OptionalServices.Services", | 91 "Bluetooth.Web.RequestDevice.OptionalServices.Services", |
90 HashUUID(service)); | 92 HashUUID(service)); |
91 } | 93 } |
92 } | 94 } |
93 | 95 |
94 static void RecordUnionOfServices( | 96 static void RecordUnionOfServices( |
95 const blink::mojom::WebBluetoothRequestDeviceOptionsPtr& options) { | 97 const blink::mojom::WebBluetoothRequestDeviceOptionsPtr& options) { |
96 std::unordered_set<std::string> union_of_services; | 98 std::unordered_set<std::string> union_of_services; |
97 for (const base::Optional<BluetoothUUID>& service : | 99 for (const BluetoothUUID& service : options->optional_services) |
98 options->optional_services) { | 100 union_of_services.insert(service.canonical_value()); |
99 union_of_services.insert(service->canonical_value()); | |
100 } | |
101 | 101 |
102 for (const auto& filter : options->filters) { | 102 for (const auto& filter : options->filters) { |
103 for (const base::Optional<BluetoothUUID>& service : filter->services) { | 103 if (!filter->services) |
104 union_of_services.insert(service->canonical_value()); | 104 continue; |
105 } | 105 for (const BluetoothUUID& service : filter->services.value()) |
| 106 union_of_services.insert(service.canonical_value()); |
106 } | 107 } |
107 | 108 |
108 UMA_HISTOGRAM_COUNTS_100("Bluetooth.Web.RequestDevice.UnionOfServices.Count", | 109 UMA_HISTOGRAM_COUNTS_100("Bluetooth.Web.RequestDevice.UnionOfServices.Count", |
109 union_of_services.size()); | 110 union_of_services.size()); |
110 | 111 |
111 for (const std::string& service : union_of_services) { | 112 for (const std::string& service : union_of_services) { |
112 // TODO(ortuno): Use a macro to histogram strings. | 113 // TODO(ortuno): Use a macro to histogram strings. |
113 // http://crbug.com/520284 | 114 // http://crbug.com/520284 |
114 UMA_HISTOGRAM_SPARSE_SLOWLY( | 115 UMA_HISTOGRAM_SPARSE_SLOWLY( |
115 "Bluetooth.Web.RequestDevice.UnionOfServices.Services", | 116 "Bluetooth.Web.RequestDevice.UnionOfServices.Services", |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 } | 335 } |
335 | 336 |
336 void RecordRSSISignalStrengthLevel(UMARSSISignalStrengthLevel level) { | 337 void RecordRSSISignalStrengthLevel(UMARSSISignalStrengthLevel level) { |
337 UMA_HISTOGRAM_ENUMERATION( | 338 UMA_HISTOGRAM_ENUMERATION( |
338 "Bluetooth.Web.RequestDevice.RSSISignalStrengthLevel", | 339 "Bluetooth.Web.RequestDevice.RSSISignalStrengthLevel", |
339 static_cast<int>(level), | 340 static_cast<int>(level), |
340 static_cast<int>(UMARSSISignalStrengthLevel::COUNT)); | 341 static_cast<int>(UMARSSISignalStrengthLevel::COUNT)); |
341 } | 342 } |
342 | 343 |
343 } // namespace content | 344 } // namespace content |
OLD | NEW |