diff options
author | ortuno <ortuno@chromium.org> | 2015-08-14 10:45:19 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-08-14 17:45:56 +0000 |
commit | 400d345c0459b97f17f827316494924591f5eae9 (patch) | |
tree | 46ad10ebe5fd6c96d5c6a010ffaadc813e537e6d | |
parent | 14d14dea488ed3f351ee396ffe3c8fc3bf5593b9 (diff) | |
download | chromium_src-400d345c0459b97f17f827316494924591f5eae9.zip chromium_src-400d345c0459b97f17f827316494924591f5eae9.tar.gz chromium_src-400d345c0459b97f17f827316494924591f5eae9.tar.bz2 |
bluetooth: Move histogram related code to its own file
Histograms' code was starting to become a significant portion of
bluetooth_dispatcher_host. This change moves it to its own class.
BUG=499636
Review URL: https://codereview.chromium.org/1265323004
Cr-Commit-Position: refs/heads/master@{#343423}
-rw-r--r-- | content/browser/bluetooth/bluetooth_dispatcher_host.cc | 185 | ||||
-rw-r--r-- | content/browser/bluetooth/bluetooth_metrics.cc | 136 | ||||
-rw-r--r-- | content/browser/bluetooth/bluetooth_metrics.h | 135 | ||||
-rw-r--r-- | content/content_browser.gypi | 2 |
4 files changed, 281 insertions, 177 deletions
diff --git a/content/browser/bluetooth/bluetooth_dispatcher_host.cc b/content/browser/bluetooth/bluetooth_dispatcher_host.cc index 02e8944d..f10195b 100644 --- a/content/browser/bluetooth/bluetooth_dispatcher_host.cc +++ b/content/browser/bluetooth/bluetooth_dispatcher_host.cc @@ -10,11 +10,9 @@ #include "content/browser/bluetooth/bluetooth_dispatcher_host.h" -#include "base/hash.h" -#include "base/metrics/histogram_macros.h" -#include "base/metrics/sparse_histogram.h" #include "base/strings/utf_string_conversions.h" #include "content/browser/bad_message.h" +#include "content/browser/bluetooth/bluetooth_metrics.h" #include "content/browser/frame_host/render_frame_host_impl.h" #include "content/common/bluetooth/bluetooth_messages.h" #include "device/bluetooth/bluetooth_adapter.h" @@ -31,161 +29,9 @@ using device::BluetoothGattCharacteristic; using device::BluetoothGattService; using device::BluetoothUUID; -namespace { - -// These types of errors aren't as common. We log them to understand -// how common they are and if we need to investigate more. -enum class BluetoothGATTError { - UNKNOWN, - FAILED, - IN_PROGRESS, - NOT_PAIRED, - // Add errors above this line and update corresponding histograms.xml enum. - MAX_ERROR, -}; - -enum class UMARequestDeviceOutcome { - SUCCESS = 0, - NO_BLUETOOTH_ADAPTER = 1, - NO_RENDER_FRAME = 2, - DISCOVERY_START_FAILED = 3, - DISCOVERY_STOP_FAILED = 4, - NO_MATCHING_DEVICES_FOUND = 5, - BLUETOOTH_ADAPTER_NOT_PRESENT = 6, - BLUETOOTH_ADAPTER_OFF = 7, - // NOTE: Add new requestDevice() outcomes immediately above this line. Make - // sure to update the enum list in - // tools/metrics/histogram/histograms.xml accordingly. - COUNT -}; - -void RecordRequestDeviceOutcome(UMARequestDeviceOutcome outcome) { - UMA_HISTOGRAM_ENUMERATION("Bluetooth.Web.RequestDevice.Outcome", - static_cast<int>(outcome), - static_cast<int>(UMARequestDeviceOutcome::COUNT)); -} -// TODO(ortuno): Remove once we have a macro to histogram strings. -// http://crbug.com/520284 -int HashUUID(const std::string& uuid) { - uint32 data = base::SuperFastHash(uuid.data(), uuid.size()); - - // Strip off the signed bit because UMA doesn't support negative values, - // but takes a signed int as input. - return static_cast<int>(data & 0x7fffffff); -} - -void RecordRequestDeviceFilters( - const std::vector<content::BluetoothScanFilter>& filters) { - UMA_HISTOGRAM_COUNTS_100("Bluetooth.Web.RequestDevice.Filters.Count", - filters.size()); - for (const content::BluetoothScanFilter& filter : filters) { - UMA_HISTOGRAM_COUNTS_100("Bluetooth.Web.RequestDevice.FilterSize", - filter.services.size()); - for (const BluetoothUUID& service : filter.services) { - // TODO(ortuno): Use a macro to histogram strings. - // http://crbug.com/520284 - UMA_HISTOGRAM_SPARSE_SLOWLY( - "Bluetooth.Web.RequestDevice.Filters.Services", - HashUUID(service.canonical_value())); - } - } -} - -void RecordRequestDeviceOptionalServices( - const std::vector<BluetoothUUID>& optional_services) { - UMA_HISTOGRAM_COUNTS_100("Bluetooth.Web.RequestDevice.OptionalServices.Count", - optional_services.size()); - for (const BluetoothUUID& service : optional_services) { - // TODO(ortuno): Use a macro to histogram strings. - // http://crbug.com/520284 - UMA_HISTOGRAM_SPARSE_SLOWLY( - "Bluetooth.Web.RequestDevice.OptionalServices.Services", - HashUUID(service.canonical_value())); - } -} - -void RecordUnionOfServices( - const std::vector<content::BluetoothScanFilter>& filters, - const std::vector<BluetoothUUID>& optional_services) { - std::set<BluetoothUUID> union_of_services(optional_services.begin(), - optional_services.end()); - - for (const content::BluetoothScanFilter& filter : filters) - union_of_services.insert(filter.services.begin(), filter.services.end()); - - UMA_HISTOGRAM_COUNTS_100("Bluetooth.Web.RequestDevice.UnionOfServices.Count", - union_of_services.size()); -} - -enum class UMAGetPrimaryServiceOutcome { - SUCCESS, - NO_DEVICE, - NOT_FOUND, - // Note: Add new GetPrimaryService outcomes immediately above this line. Make - // sure to update the enum list in tools/metrics/histograms/histograms.xml - // accordingly. - COUNT -}; - -void RecordGetPrimaryServiceService(const BluetoothUUID& service) { - UMA_HISTOGRAM_SPARSE_SLOWLY("Bluetooth.Web.GetPrimaryService.Services", - HashUUID(service.canonical_value())); -} - -void RecordGetPrimaryServiceOutcome(UMAGetPrimaryServiceOutcome outcome) { - UMA_HISTOGRAM_ENUMERATION( - "Bluetooth.Web.GetPrimaryService.Outcome", static_cast<int>(outcome), - static_cast<int>(UMAGetPrimaryServiceOutcome::COUNT)); -} - -enum class UMAConnectGATTOutcome { - SUCCESS, - NO_DEVICE, - UNKNOWN, - IN_PROGRESS, - FAILED, - AUTH_FAILED, - AUTH_CANCELED, - AUTH_REJECTED, - AUTH_TIMEOUT, - UNSUPPORTED_DEVICE, - // Note: Add new ConnectGATT outcomes immediately above this line. Make sure - // to update the enum list in tools/metrisc/histogram/histograms.xml - // accordingly. - COUNT -}; - -void RecordConnectGATTOutcome(UMAConnectGATTOutcome outcome) { - UMA_HISTOGRAM_ENUMERATION("Bluetooth.Web.ConnectGATT.Outcome", - static_cast<int>(outcome), - static_cast<int>(UMAConnectGATTOutcome::COUNT)); -} - -void RecordConnectGATTTimeSuccess(const base::TimeDelta& duration) { - UMA_HISTOGRAM_MEDIUM_TIMES("Bluetooth.Web.ConnectGATT.TimeSuccess", duration); -} - -void RecordConnectGATTTimeFailed(const base::TimeDelta& duration) { - UMA_HISTOGRAM_MEDIUM_TIMES("Bluetooth.Web.ConnectGATT.TimeFailed", duration); -} - -enum class UMAWebBluetoothFunction { - REQUEST_DEVICE, - CONNECT_GATT, - GET_PRIMARY_SERVICE, - GET_CHARACTERISTIC, - CHARACTERISTIC_READ_VALUE, - CHARACTERISTIC_WRITE_VALUE, - // NOTE: Add new actions immediately above this line. Make sure to update the - // enum list in tools/metrics/histogram/histograms.xml accordingly. - COUNT -}; +namespace content { -void RecordWebBluetoothFunctionCall(UMAWebBluetoothFunction function) { - UMA_HISTOGRAM_ENUMERATION("Bluetooth.Web.FunctionCall.Count", - static_cast<int>(function), - static_cast<int>(UMAWebBluetoothFunction::COUNT)); -} +namespace { // TODO(ortuno): Once we have a chooser for scanning and the right // callback for discovered services we should delete these constants. @@ -220,11 +66,6 @@ bool MatchesFilters(const device::BluetoothDevice& device, return false; } -void AddToHistogram(BluetoothGATTError error) { - UMA_HISTOGRAM_ENUMERATION("Bluetooth.GATTErrors", static_cast<int>(error), - static_cast<int>(BluetoothGATTError::MAX_ERROR)); -} - WebBluetoothError TranslateConnectError( device::BluetoothDevice::ConnectErrorCode error_code) { switch (error_code) { @@ -261,13 +102,13 @@ blink::WebBluetoothError TranslateGATTError( BluetoothGattService::GattErrorCode error_code) { switch (error_code) { case BluetoothGattService::GATT_ERROR_UNKNOWN: - AddToHistogram(BluetoothGATTError::UNKNOWN); + RecordGATTError(UMAGATTError::UNKNOWN); return blink::WebBluetoothError::GATTUnknownError; case BluetoothGattService::GATT_ERROR_FAILED: - AddToHistogram(BluetoothGATTError::FAILED); + RecordGATTError(UMAGATTError::FAILED); return blink::WebBluetoothError::GATTUnknownFailure; case BluetoothGattService::GATT_ERROR_IN_PROGRESS: - AddToHistogram(BluetoothGATTError::IN_PROGRESS); + RecordGATTError(UMAGATTError::IN_PROGRESS); return blink::WebBluetoothError::GATTOperationInProgress; case BluetoothGattService::GATT_ERROR_INVALID_LENGTH: return blink::WebBluetoothError::GATTInvalidAttributeLength; @@ -276,7 +117,7 @@ blink::WebBluetoothError TranslateGATTError( case BluetoothGattService::GATT_ERROR_NOT_AUTHORIZED: return blink::WebBluetoothError::GATTNotAuthorized; case BluetoothGattService::GATT_ERROR_NOT_PAIRED: - AddToHistogram(BluetoothGATTError::NOT_PAIRED); + RecordGATTError(UMAGATTError::NOT_PAIRED); return blink::WebBluetoothError::GATTNotPaired; case BluetoothGattService::GATT_ERROR_NOT_SUPPORTED: return blink::WebBluetoothError::GATTNotSupported; @@ -287,8 +128,6 @@ blink::WebBluetoothError TranslateGATTError( } // namespace -namespace content { - BluetoothDispatcherHost::BluetoothDispatcherHost(int render_process_id) : BrowserMessageFilter(BluetoothMsgStart), render_process_id_(render_process_id), @@ -385,9 +224,7 @@ void BluetoothDispatcherHost::OnRequestDevice( const std::vector<BluetoothUUID>& optional_services) { DCHECK_CURRENTLY_ON(content::BrowserThread::UI); RecordWebBluetoothFunctionCall(UMAWebBluetoothFunction::REQUEST_DEVICE); - RecordRequestDeviceFilters(filters); - RecordRequestDeviceOptionalServices(optional_services); - RecordUnionOfServices(filters, optional_services); + RecordRequestDeviceArguments(filters, optional_services); VLOG(1) << "requestDevice called with the following filters: "; for (const BluetoothScanFilter& filter : filters) { @@ -444,7 +281,6 @@ void BluetoothDispatcherHost::OnRequestDevice( // with a message. // https://crbug.com/517237 if (!adapter_->IsPowered()) { - VLOG(1) << "Bluetooth Adapter is not powered. Can't serve requestDevice."; RecordRequestDeviceOutcome( UMARequestDeviceOutcome::BLUETOOTH_ADAPTER_OFF); Send(new BluetoothMsg_RequestDeviceError( @@ -482,7 +318,6 @@ void BluetoothDispatcherHost::OnConnectGATT( device::BluetoothDevice* device = adapter_->GetDevice(device_instance_id); if (device == nullptr) { // See "NETWORK_ERROR Note" above. RecordConnectGATTOutcome(UMAConnectGATTOutcome::NO_DEVICE); - VLOG(1) << "Bluetooth Device no longer in range."; Send(new BluetoothMsg_ConnectGATTError( thread_id, request_id, WebBluetoothError::DeviceNoLongerInRange)); return; @@ -747,7 +582,6 @@ void BluetoothDispatcherHost::OnDiscoverySessionStopped(int thread_id, CHECK(session != request_device_sessions_.end()); BluetoothAdapter::DeviceList devices = adapter_->GetDevices(); for (device::BluetoothDevice* device : devices) { - // Remove VLOG when stable. http://crbug.com/519010 VLOG(1) << "Device: " << device->GetName(); VLOG(1) << "UUIDs: "; for (BluetoothUUID uuid : device->GetUUIDs()) @@ -773,7 +607,6 @@ void BluetoothDispatcherHost::OnDiscoverySessionStopped(int thread_id, } RecordRequestDeviceOutcome( UMARequestDeviceOutcome::NO_MATCHING_DEVICES_FOUND); - VLOG(1) << "No matching Bluetooth Devices found"; Send(new BluetoothMsg_RequestDeviceError(thread_id, request_id, WebBluetoothError::NoDevicesFound)); request_device_sessions_.erase(session); @@ -828,7 +661,6 @@ void BluetoothDispatcherHost::OnServicesDiscovered( device::BluetoothDevice* device = adapter_->GetDevice(device_instance_id); if (device == nullptr) { // See "NETWORK_ERROR Note" above. RecordGetPrimaryServiceOutcome(UMAGetPrimaryServiceOutcome::NO_DEVICE); - VLOG(1) << "Bluetooth Device is no longer in range."; Send(new BluetoothMsg_GetPrimaryServiceError( thread_id, request_id, WebBluetoothError::DeviceNoLongerInRange)); return; @@ -852,7 +684,6 @@ void BluetoothDispatcherHost::OnServicesDiscovered( } } RecordGetPrimaryServiceOutcome(UMAGetPrimaryServiceOutcome::NOT_FOUND); - VLOG(1) << "No GATT services with UUID: " << service_uuid; Send(new BluetoothMsg_GetPrimaryServiceError( thread_id, request_id, WebBluetoothError::ServiceNotFound)); } diff --git a/content/browser/bluetooth/bluetooth_metrics.cc b/content/browser/bluetooth/bluetooth_metrics.cc new file mode 100644 index 0000000..fcb8199 --- /dev/null +++ b/content/browser/bluetooth/bluetooth_metrics.cc @@ -0,0 +1,136 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "content/browser/bluetooth/bluetooth_metrics.h" + +#include <map> +#include <set> +#include "base/hash.h" +#include "base/metrics/histogram_macros.h" +#include "base/metrics/sparse_histogram.h" +#include "content/common/bluetooth/bluetooth_scan_filter.h" +#include "device/bluetooth/bluetooth_uuid.h" + +using device::BluetoothUUID; + +namespace { +// TODO(ortuno): Remove once we have a macro to histogram strings. +// http://crbug.com/520284 +int HashUUID(const std::string& uuid) { + uint32 data = base::SuperFastHash(uuid.data(), uuid.size()); + + // Strip off the signed bit because UMA doesn't support negative values, + // but takes a signed int as input. + return static_cast<int>(data & 0x7fffffff); +} +} // namespace + +namespace content { + +// General + +void RecordWebBluetoothFunctionCall(UMAWebBluetoothFunction function) { + UMA_HISTOGRAM_ENUMERATION("Bluetooth.Web.FunctionCall.Count", + static_cast<int>(function), + static_cast<int>(UMAWebBluetoothFunction::COUNT)); +} + +// requestDevice() + +void RecordRequestDeviceOutcome(UMARequestDeviceOutcome outcome) { + UMA_HISTOGRAM_ENUMERATION("Bluetooth.Web.RequestDevice.Outcome", + static_cast<int>(outcome), + static_cast<int>(UMARequestDeviceOutcome::COUNT)); +} + +static void RecordRequestDeviceFilters( + const std::vector<content::BluetoothScanFilter>& filters) { + UMA_HISTOGRAM_COUNTS_100("Bluetooth.Web.RequestDevice.Filters.Count", + filters.size()); + for (const content::BluetoothScanFilter& filter : filters) { + UMA_HISTOGRAM_COUNTS_100("Bluetooth.Web.RequestDevice.FilterSize", + filter.services.size()); + for (const BluetoothUUID& service : filter.services) { + // TODO(ortuno): Use a macro to histogram strings. + // http://crbug.com/520284 + UMA_HISTOGRAM_SPARSE_SLOWLY( + "Bluetooth.Web.RequestDevice.Filters.Services", + HashUUID(service.canonical_value())); + } + } +} + +static void RecordRequestDeviceOptionalServices( + const std::vector<BluetoothUUID>& optional_services) { + UMA_HISTOGRAM_COUNTS_100("Bluetooth.Web.RequestDevice.OptionalServices.Count", + optional_services.size()); + for (const BluetoothUUID& service : optional_services) { + // TODO(ortuno): Use a macro to histogram strings. + // http://crbug.com/520284 + UMA_HISTOGRAM_SPARSE_SLOWLY( + "Bluetooth.Web.RequestDevice.OptionalServices.Services", + HashUUID(service.canonical_value())); + } +} + +static void RecordUnionOfServices( + const std::vector<content::BluetoothScanFilter>& filters, + const std::vector<BluetoothUUID>& optional_services) { + std::set<BluetoothUUID> union_of_services(optional_services.begin(), + optional_services.end()); + + for (const content::BluetoothScanFilter& filter : filters) + union_of_services.insert(filter.services.begin(), filter.services.end()); + + UMA_HISTOGRAM_COUNTS_100("Bluetooth.Web.RequestDevice.UnionOfServices.Count", + union_of_services.size()); +} + +void RecordRequestDeviceArguments( + const std::vector<content::BluetoothScanFilter>& filters, + const std::vector<device::BluetoothUUID>& optional_services) { + RecordRequestDeviceFilters(filters); + RecordRequestDeviceOptionalServices(optional_services); + RecordUnionOfServices(filters, optional_services); +} + +// connectGATT + +void RecordConnectGATTOutcome(UMAConnectGATTOutcome outcome) { + UMA_HISTOGRAM_ENUMERATION("Bluetooth.Web.ConnectGATT.Outcome", + static_cast<int>(outcome), + static_cast<int>(UMAConnectGATTOutcome::COUNT)); +} + +void RecordConnectGATTTimeSuccess(const base::TimeDelta& duration) { + UMA_HISTOGRAM_MEDIUM_TIMES("Bluetooth.Web.ConnectGATT.TimeSuccess", duration); +} + +void RecordConnectGATTTimeFailed(const base::TimeDelta& duration) { + UMA_HISTOGRAM_MEDIUM_TIMES("Bluetooth.Web.ConnectGATT.TimeFailed", duration); +} + +// getPrimaryService + +void RecordGetPrimaryServiceService(const 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())); +} + +void RecordGetPrimaryServiceOutcome(UMAGetPrimaryServiceOutcome outcome) { + UMA_HISTOGRAM_ENUMERATION( + "Bluetooth.Web.GetPrimaryService.Outcome", static_cast<int>(outcome), + static_cast<int>(UMAGetPrimaryServiceOutcome::COUNT)); +} + +// read/write characteristic + +void RecordGATTError(UMAGATTError error) { + UMA_HISTOGRAM_ENUMERATION("Bluetooth.GATTErrors", static_cast<int>(error), + static_cast<int>(UMAGATTError::MAX_ERROR)); +} + +} // namespace content diff --git a/content/browser/bluetooth/bluetooth_metrics.h b/content/browser/bluetooth/bluetooth_metrics.h new file mode 100644 index 0000000..3483d4c --- /dev/null +++ b/content/browser/bluetooth/bluetooth_metrics.h @@ -0,0 +1,135 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_METRICS_H_ +#define CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_METRICS_H_ + +#include <vector> + +namespace base { +class TimeDelta; +} + +namespace device { +class BluetoothUUID; +} + +namespace content { +struct BluetoothScanFilter; + +// General Metrics + +// Enumaration of each Web Bluetooth API entry point. +enum class UMAWebBluetoothFunction { + REQUEST_DEVICE = 0, + CONNECT_GATT = 1, + GET_PRIMARY_SERVICE = 2, + GET_CHARACTERISTIC = 3, + CHARACTERISTIC_READ_VALUE = 4, + CHARACTERISTIC_WRITE_VALUE = 5, + // NOTE: Add new actions immediately above this line. Make sure to update + // the enum list in tools/metrics/histograms/histograms.xml accordingly. + COUNT +}; + +// There should be a call to this function for every call to the Web Bluetooth +// API. +void RecordWebBluetoothFunctionCall(UMAWebBluetoothFunction function); + +// requestDevice() Metrics +enum class UMARequestDeviceOutcome { + SUCCESS = 0, + NO_BLUETOOTH_ADAPTER = 1, + NO_RENDER_FRAME = 2, + DISCOVERY_START_FAILED = 3, + DISCOVERY_STOP_FAILED = 4, + NO_MATCHING_DEVICES_FOUND = 5, + BLUETOOTH_ADAPTER_NOT_PRESENT = 6, + BLUETOOTH_ADAPTER_OFF = 7, + // NOTE: Add new requestDevice() outcomes immediately above this line. Make + // sure to update the enum list in + // tools/metrics/histograms/histograms.xml accordingly. + COUNT +}; +// There should be a call to this function before every +// Send(BluetoothMsg_RequestDeviceSuccess...) or +// Send(BluetoothMsg_RequestDeviceError...). +void RecordRequestDeviceOutcome(UMARequestDeviceOutcome outcome); + +// Records stats about the arguments used when calling requestDevice. +// - The number of filters used. +// - The size of each filter. +// - UUID of the services used in filters. +// - Number of optional services used. +// - UUID of the optional services. +// - Size of the union of all services. +void RecordRequestDeviceArguments( + const std::vector<content::BluetoothScanFilter>& filters, + const std::vector<device::BluetoothUUID>& optional_services); + +// connectGATT() Metrics +enum class UMAConnectGATTOutcome { + SUCCESS = 0, + NO_DEVICE = 1, + UNKNOWN = 2, + IN_PROGRESS = 3, + FAILED = 4, + AUTH_FAILED = 5, + AUTH_CANCELED = 6, + AUTH_REJECTED = 7, + AUTH_TIMEOUT = 8, + UNSUPPORTED_DEVICE = 9, + // Note: Add new ConnectGATT outcomes immediately above this line. Make sure + // to update the enum list in tools/metrics/histograms/histograms.xml + // accordingly. + COUNT +}; +// There should be a call to this function before every +// Send(BluetoothMsg_ConnectGATTSuccess) and +// Send(BluetoothMsg_ConnectGATTError). +void RecordConnectGATTOutcome(UMAConnectGATTOutcome outcome); +// Records how long it took for the connection to succeed. +void RecordConnectGATTTimeSuccess(const base::TimeDelta& duration); +// Records how long it took for the connection to fail. +void RecordConnectGATTTimeFailed(const base::TimeDelta& duration); + +// getPrimaryService() Metrics +enum class UMAGetPrimaryServiceOutcome { + SUCCESS = 0, + NO_DEVICE = 1, + NOT_FOUND = 2, + // Note: Add new GetPrimaryService outcomes immediately above this line. + // Make sure to update the enum list in + // tools/metrics/histograms/histograms.xml accordingly. + COUNT +}; +// Record the service uuid used when calling getPrimaryService. +void RecordGetPrimaryServiceService(const device::BluetoothUUID& service); +// There should be a call to this function for every call to +// Send(BluetoothMsg_GetPrimaryServiceSuccess) and +// Send(BluetoothMsg_GetPrimaryServiceError). +void RecordGetPrimaryServiceOutcome(UMAGetPrimaryServiceOutcome outcome); + +// read/write characteristics Metrics +// TODO(ortuno): For now we are just copying over the code to record these +// errors but a follow up CL will add a function for each operation. + +// These types of errors aren't as common. We log them to understand +// how common they are and if we need to investigate more. +enum class UMAGATTError { + UNKNOWN = 0, + FAILED = 1, + IN_PROGRESS = 2, + NOT_PAIRED = 3, + // Note: Add new GATT Errors immediately above this line. + // Make sure to update the enum list in + // tools/metrics/histograms/histograms.xml accordingly. + MAX_ERROR, +}; +// Records the GATT Error the function returned. +void RecordGATTError(UMAGATTError error); + +} // namespace content + +#endif // CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_METRICS_H_ diff --git a/content/content_browser.gypi b/content/content_browser.gypi index fe21c3f..2ed310e 100644 --- a/content/content_browser.gypi +++ b/content/content_browser.gypi @@ -486,6 +486,8 @@ 'browser/bad_message.h', 'browser/bluetooth/bluetooth_dispatcher_host.cc', 'browser/bluetooth/bluetooth_dispatcher_host.h', + 'browser/bluetooth/bluetooth_metrics.cc', + 'browser/bluetooth/bluetooth_metrics.h', 'browser/bootstrap_sandbox_mac.cc', 'browser/bootstrap_sandbox_mac.h', 'browser/browser_child_process_host_impl.cc', |