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 UMA_HISTOGRAM_COUNTS_100("Bluetooth.Web.RequestDevice.FilterSize", | 70 if (filter->services) { |
ortuno
2016/11/21 04:42:31
if (!filter->services) {
continue;
}
...
juncai
2016/11/21 21:27:05
Done.
| |
71 filter->services.size()); | 71 UMA_HISTOGRAM_COUNTS_100("Bluetooth.Web.RequestDevice.FilterSize", |
72 for (const base::Optional<BluetoothUUID>& service : filter->services) { | 72 filter->services->size()); |
73 // TODO(ortuno): Use a macro to histogram strings. | 73 for (const BluetoothUUID& service : filter->services.value()) { |
74 // http://crbug.com/520284 | 74 // TODO(ortuno): Use a macro to histogram strings. |
75 UMA_HISTOGRAM_SPARSE_SLOWLY( | 75 // http://crbug.com/520284 |
76 "Bluetooth.Web.RequestDevice.Filters.Services", HashUUID(service)); | 76 UMA_HISTOGRAM_SPARSE_SLOWLY( |
77 "Bluetooth.Web.RequestDevice.Filters.Services", HashUUID(service)); | |
78 } | |
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 |
102 for (const auto& filter : options->filters) { | 103 for (const auto& filter : options->filters) { |
103 for (const base::Optional<BluetoothUUID>& service : filter->services) { | 104 if (filter->services) { |
ortuno
2016/11/21 04:42:31
if (!filter->services) {
continue;
}
...
juncai
2016/11/21 21:27:05
Done.
| |
104 union_of_services.insert(service->canonical_value()); | 105 for (const BluetoothUUID& service : filter->services.value()) { |
106 union_of_services.insert(service.canonical_value()); | |
107 } | |
105 } | 108 } |
106 } | 109 } |
107 | 110 |
108 UMA_HISTOGRAM_COUNTS_100("Bluetooth.Web.RequestDevice.UnionOfServices.Count", | 111 UMA_HISTOGRAM_COUNTS_100("Bluetooth.Web.RequestDevice.UnionOfServices.Count", |
109 union_of_services.size()); | 112 union_of_services.size()); |
110 | 113 |
111 for (const std::string& service : union_of_services) { | 114 for (const std::string& service : union_of_services) { |
112 // TODO(ortuno): Use a macro to histogram strings. | 115 // TODO(ortuno): Use a macro to histogram strings. |
113 // http://crbug.com/520284 | 116 // http://crbug.com/520284 |
114 UMA_HISTOGRAM_SPARSE_SLOWLY( | 117 UMA_HISTOGRAM_SPARSE_SLOWLY( |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
334 } | 337 } |
335 | 338 |
336 void RecordRSSISignalStrengthLevel(UMARSSISignalStrengthLevel level) { | 339 void RecordRSSISignalStrengthLevel(UMARSSISignalStrengthLevel level) { |
337 UMA_HISTOGRAM_ENUMERATION( | 340 UMA_HISTOGRAM_ENUMERATION( |
338 "Bluetooth.Web.RequestDevice.RSSISignalStrengthLevel", | 341 "Bluetooth.Web.RequestDevice.RSSISignalStrengthLevel", |
339 static_cast<int>(level), | 342 static_cast<int>(level), |
340 static_cast<int>(UMARSSISignalStrengthLevel::COUNT)); | 343 static_cast<int>(UMARSSISignalStrengthLevel::COUNT)); |
341 } | 344 } |
342 | 345 |
343 } // namespace content | 346 } // namespace content |
OLD | NEW |