Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(251)

Side by Side Diff: content/browser/bluetooth/bluetooth_metrics.cc

Issue 2506813003: Use new wrapper types for web_bluetooth.mojom (Closed)
Patch Set: merge master and resolve conflicts Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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;
72 }
70 UMA_HISTOGRAM_COUNTS_100("Bluetooth.Web.RequestDevice.FilterSize", 73 UMA_HISTOGRAM_COUNTS_100("Bluetooth.Web.RequestDevice.FilterSize",
71 filter->services.size()); 74 filter->services->size());
72 for (const base::Optional<BluetoothUUID>& service : filter->services) { 75 for (const BluetoothUUID& service : filter->services.value()) {
73 // TODO(ortuno): Use a macro to histogram strings. 76 // TODO(ortuno): Use a macro to histogram strings.
74 // http://crbug.com/520284 77 // http://crbug.com/520284
75 UMA_HISTOGRAM_SPARSE_SLOWLY( 78 UMA_HISTOGRAM_SPARSE_SLOWLY(
76 "Bluetooth.Web.RequestDevice.Filters.Services", HashUUID(service)); 79 "Bluetooth.Web.RequestDevice.Filters.Services", HashUUID(service));
77 } 80 }
78 } 81 }
79 } 82 }
80 83
81 static void RecordRequestDeviceOptionalServices( 84 static void RecordRequestDeviceOptionalServices(
82 const mojo::Array<base::Optional<BluetoothUUID>>& optional_services) { 85 const std::vector<BluetoothUUID>& optional_services) {
83 UMA_HISTOGRAM_COUNTS_100("Bluetooth.Web.RequestDevice.OptionalServices.Count", 86 UMA_HISTOGRAM_COUNTS_100("Bluetooth.Web.RequestDevice.OptionalServices.Count",
84 optional_services.size()); 87 optional_services.size());
85 for (const base::Optional<BluetoothUUID>& service : optional_services) { 88 for (const BluetoothUUID& service : optional_services) {
86 // TODO(ortuno): Use a macro to histogram strings. 89 // TODO(ortuno): Use a macro to histogram strings.
87 // http://crbug.com/520284 90 // http://crbug.com/520284
88 UMA_HISTOGRAM_SPARSE_SLOWLY( 91 UMA_HISTOGRAM_SPARSE_SLOWLY(
89 "Bluetooth.Web.RequestDevice.OptionalServices.Services", 92 "Bluetooth.Web.RequestDevice.OptionalServices.Services",
90 HashUUID(service)); 93 HashUUID(service));
91 } 94 }
92 } 95 }
93 96
94 static void RecordUnionOfServices( 97 static void RecordUnionOfServices(
95 const blink::mojom::WebBluetoothRequestDeviceOptionsPtr& options) { 98 const blink::mojom::WebBluetoothRequestDeviceOptionsPtr& options) {
96 std::unordered_set<std::string> union_of_services; 99 std::unordered_set<std::string> union_of_services;
97 for (const base::Optional<BluetoothUUID>& service : 100 for (const BluetoothUUID& service : options->optional_services) {
98 options->optional_services) { 101 union_of_services.insert(service.canonical_value());
99 union_of_services.insert(service->canonical_value());
100 } 102 }
101 103
102 for (const auto& filter : options->filters) { 104 for (const auto& filter : options->filters) {
103 for (const base::Optional<BluetoothUUID>& service : filter->services) { 105 if (!filter->services) {
104 union_of_services.insert(service->canonical_value()); 106 continue;
107 }
108 for (const BluetoothUUID& service : filter->services.value()) {
109 union_of_services.insert(service.canonical_value());
105 } 110 }
106 } 111 }
107 112
108 UMA_HISTOGRAM_COUNTS_100("Bluetooth.Web.RequestDevice.UnionOfServices.Count", 113 UMA_HISTOGRAM_COUNTS_100("Bluetooth.Web.RequestDevice.UnionOfServices.Count",
109 union_of_services.size()); 114 union_of_services.size());
110 115
111 for (const std::string& service : union_of_services) { 116 for (const std::string& service : union_of_services) {
112 // TODO(ortuno): Use a macro to histogram strings. 117 // TODO(ortuno): Use a macro to histogram strings.
113 // http://crbug.com/520284 118 // http://crbug.com/520284
114 UMA_HISTOGRAM_SPARSE_SLOWLY( 119 UMA_HISTOGRAM_SPARSE_SLOWLY(
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 } 339 }
335 340
336 void RecordRSSISignalStrengthLevel(UMARSSISignalStrengthLevel level) { 341 void RecordRSSISignalStrengthLevel(UMARSSISignalStrengthLevel level) {
337 UMA_HISTOGRAM_ENUMERATION( 342 UMA_HISTOGRAM_ENUMERATION(
338 "Bluetooth.Web.RequestDevice.RSSISignalStrengthLevel", 343 "Bluetooth.Web.RequestDevice.RSSISignalStrengthLevel",
339 static_cast<int>(level), 344 static_cast<int>(level),
340 static_cast<int>(UMARSSISignalStrengthLevel::COUNT)); 345 static_cast<int>(UMARSSISignalStrengthLevel::COUNT));
341 } 346 }
342 347
343 } // namespace content 348 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698