| Index: content/browser/bluetooth/bluetooth_metrics.cc
|
| diff --git a/content/browser/bluetooth/bluetooth_metrics.cc b/content/browser/bluetooth/bluetooth_metrics.cc
|
| index ad3205bd63cc77c8b51b9b677977dab5298d9130..1340c1aa37321b5d63b2d66d7a7c5437c26ea5f1 100644
|
| --- a/content/browser/bluetooth/bluetooth_metrics.cc
|
| +++ b/content/browser/bluetooth/bluetooth_metrics.cc
|
| @@ -8,6 +8,8 @@
|
|
|
| #include <map>
|
| #include <set>
|
| +#include <unordered_set>
|
| +
|
| #include "base/hash.h"
|
| #include "base/metrics/histogram_macros.h"
|
| #include "base/metrics/sparse_histogram.h"
|
| @@ -21,11 +23,14 @@ namespace {
|
| // UMA_HISTOGRAM_SPARSE_SLOWLY (positive int).
|
| //
|
| // Hash values can be produced manually using tool: bluetooth_metrics_hash.
|
| -int HashUUID(const std::string& canonical_uuid) {
|
| - DCHECK(canonical_uuid == BluetoothUUID(canonical_uuid).canonical_value());
|
| +int HashUUID(const base::Optional<BluetoothUUID>& uuid) {
|
| + if (!uuid) {
|
| + return 0;
|
| + }
|
|
|
| - // TODO(520284): Other than verifying that uuid is canonical, this logic
|
| + // TODO(520284): Other than verifying that |uuid| contains a value, this logic
|
| // should be migrated to a dedicated histogram macro for hashed strings.
|
| + const std::string& canonical_uuid = uuid->canonical_value();
|
| uint32_t data =
|
| base::SuperFastHash(canonical_uuid.data(), canonical_uuid.size());
|
|
|
| @@ -60,7 +65,7 @@ static void RecordRequestDeviceFilters(
|
| for (const auto& filter : filters) {
|
| UMA_HISTOGRAM_COUNTS_100("Bluetooth.Web.RequestDevice.FilterSize",
|
| filter->services.size());
|
| - for (const std::string& service : filter->services) {
|
| + for (const base::Optional<BluetoothUUID>& service : filter->services) {
|
| // TODO(ortuno): Use a macro to histogram strings.
|
| // http://crbug.com/520284
|
| UMA_HISTOGRAM_SPARSE_SLOWLY(
|
| @@ -70,10 +75,10 @@ static void RecordRequestDeviceFilters(
|
| }
|
|
|
| static void RecordRequestDeviceOptionalServices(
|
| - const mojo::Array<mojo::String>& optional_services) {
|
| + const mojo::Array<base::Optional<BluetoothUUID>>& optional_services) {
|
| UMA_HISTOGRAM_COUNTS_100("Bluetooth.Web.RequestDevice.OptionalServices.Count",
|
| optional_services.size());
|
| - for (const std::string& service : optional_services) {
|
| + for (const base::Optional<BluetoothUUID>& service : optional_services) {
|
| // TODO(ortuno): Use a macro to histogram strings.
|
| // http://crbug.com/520284
|
| UMA_HISTOGRAM_SPARSE_SLOWLY(
|
| @@ -84,11 +89,17 @@ static void RecordRequestDeviceOptionalServices(
|
|
|
| static void RecordUnionOfServices(
|
| const blink::mojom::WebBluetoothRequestDeviceOptionsPtr& options) {
|
| - std::set<mojo::String> union_of_services(options->optional_services.begin(),
|
| - options->optional_services.end());
|
| + std::unordered_set<std::string> union_of_services;
|
| + for (const base::Optional<BluetoothUUID>& service :
|
| + options->optional_services) {
|
| + union_of_services.insert(service->canonical_value());
|
| + }
|
|
|
| - for (const auto& filter : options->filters)
|
| - union_of_services.insert(filter->services.begin(), filter->services.end());
|
| + for (const auto& filter : options->filters) {
|
| + for (const base::Optional<BluetoothUUID>& service : filter->services) {
|
| + union_of_services.insert(service->canonical_value());
|
| + }
|
| + }
|
|
|
| UMA_HISTOGRAM_COUNTS_100("Bluetooth.Web.RequestDevice.UnionOfServices.Count",
|
| union_of_services.size());
|
| @@ -124,11 +135,12 @@ void RecordConnectGATTTimeFailed(const base::TimeDelta& duration) {
|
|
|
| // getPrimaryService
|
|
|
| -void RecordGetPrimaryServiceService(const BluetoothUUID& service) {
|
| +void RecordGetPrimaryServiceService(
|
| + const base::Optional<BluetoothUUID>& service) {
|
| // TODO(ortuno): Use a macro to histogram strings.
|
| // http://crbug.com/520284
|
| UMA_HISTOGRAM_SPARSE_SLOWLY("Bluetooth.Web.GetPrimaryService.Services",
|
| - HashUUID(service.canonical_value()));
|
| + HashUUID(service));
|
| }
|
|
|
| void RecordGetPrimaryServiceOutcome(UMAGetPrimaryServiceOutcome outcome) {
|
| @@ -186,7 +198,7 @@ void RecordGetCharacteristicsOutcome(
|
|
|
| void RecordGetCharacteristicsCharacteristic(
|
| blink::mojom::WebBluetoothGATTQueryQuantity quantity,
|
| - const std::string& characteristic) {
|
| + const base::Optional<BluetoothUUID>& characteristic) {
|
| switch (quantity) {
|
| case blink::mojom::WebBluetoothGATTQueryQuantity::SINGLE:
|
| UMA_HISTOGRAM_SPARSE_SLOWLY(
|
|
|